Hi all!
Please tell me is it possible to somehow get information about response headers in SyncGraphQlClientInterceptor?
The problem we are trying to solve:
There is a certain graphql server provider that returns apollo-trace-id in the response headers. On our side, we need to log this traceID to improve observability. We can get the response header at the ClientHttpRequestInterceptor level, but we want to log this identifier in two cases:
If the provider's server returned an incorrect HTTP status.
If the provider’s server returned incorrect data in the response (for example, there are some errors in the errors block of the response that do not allow this response to be considered valid).
And if the first point can be solved quite simply using ClientHttpRequestInterceptor, then the second point can be more difficult to solve using it. The problem is that ClientHttpRequestInterceptordoes not have a deserialized response body and there is no easy way to parse it. And if we take SyncGraphQlClientInterceptor, then there is no access to response headers due to the lack of such data in GraphQlResponse and the transfer of this information to HttpSyncGraphQlTransport. There are essentially two options:
Create a certain context for storing apollo-trace-id at the ClientHttpRequestInterceptor level (a class with the ThreadLocal field) and then pick it up at the SyncGraphQlClientInterceptor level.
Additionally deserialize the response body at the ClientHttpRequestInterceptor level and log information about traceID there.
But both options, to be honest, look so-so. Maybe there are some better options that we haven't noticed?
Hi all! Please tell me is it possible to somehow get information about response headers in
SyncGraphQlClientInterceptor
? The problem we are trying to solve: There is a certain graphql server provider that returnsapollo-trace-id
in the response headers. On our side, we need to log this traceID to improve observability. We can get the response header at theClientHttpRequestInterceptor
level, but we want to log this identifier in two cases:And if the first point can be solved quite simply using
ClientHttpRequestInterceptor
, then the second point can be more difficult to solve using it. The problem is thatClientHttpRequestInterceptor
does not have a deserialized response body and there is no easy way to parse it. And if we takeSyncGraphQlClientInterceptor
, then there is no access to response headers due to the lack of such data inGraphQlResponse
and the transfer of this information toHttpSyncGraphQlTransport
. There are essentially two options:ClientHttpRequestInterceptor
level (a class with theThreadLocal
field) and then pick it up at theSyncGraphQlClientInterceptor
level.ClientHttpRequestInterceptor
level and log information abouttraceID
there.But both options, to be honest, look so-so. Maybe there are some better options that we haven't noticed?