-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved middleware handling #567
Labels
Comments
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perceived Problem
I tried to use graphql-request to replace a custom request client we use, and OTEL plus some metrics is a requirement for doing this.
Unfortunately the middleware right now lacked a few things, especially in how it works for us. As we would be initialising
GraphQLClient
once, and re-using it to make queries.I suspect these improvements would simplify your code somewhat, as you are exposing the internal elements more directly to be implement by developers.
Ideas / Proposed Solution(s)
As all things like this, there are many options to solve this. I am keenly aware that it is important to keep the basic principle of a light-weight graphql client.
My key elements to solve are:
I think the first is easy enough to solve, by including a consistent context object to both request and response middleware calls.
The second I still think could be solved with either:
Where a contrived implementation could look like
Additionally, I think the design of the response middleware needing to infer the error response could be improved by explicitly passing error objects, as well as the response object itself to the handler.
maybe context looks like:
The text was updated successfully, but these errors were encountered: