You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The 'getSdk' wrapper comes from "@graphql-codegen" which generates TS types from the backend's graphql schema.
We use that exported graphQLClient in hundreds of places allover the application UI.
Why
I need to access the response headers in all the places that consume the GraphQLClient instance. If there is something to be logged or an error in the data, I need to use the "traceparent" header from the client and display it.
How
I thought that responseMiddleware could help with that, the headers are in there as the response: GraphQLClientResponse<T> argument to the responseMiddleware method.
But as the responseMiddleware doesn't get to return anything, I don't get to modify what is passed down the line. Sure, I can modify the 'data' part but that's a hack. Ideally, I'd like the client to return both data and headers.
The text was updated successfully, but these errors were encountered:
I later found out, that using rawRequest provides response headers and all other data. Unfortunately, the auto generated "getSdk" has TS errors in that case, plus some other issues. I don't have access to that code anymore, so I don't recall the exact issues.
What
I am looking for a way to append the response headers to all responses from my GraphQLClient instance.
Does anyone know how to do that?
I have this setup in a very large application:
The 'getSdk' wrapper comes from "@graphql-codegen" which generates TS types from the backend's graphql schema.
We use that exported
graphQLClient
in hundreds of places allover the application UI.Why
I need to access the response headers in all the places that consume the GraphQLClient instance. If there is something to be logged or an error in the data, I need to use the "traceparent" header from the client and display it.
How
I thought that
responseMiddleware
could help with that, the headers are in there as theresponse: GraphQLClientResponse<T>
argument to theresponseMiddleware
method.But as the responseMiddleware doesn't get to return anything, I don't get to modify what is passed down the line. Sure, I can modify the 'data' part but that's a hack. Ideally, I'd like the client to return both data and headers.
The text was updated successfully, but these errors were encountered: