graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

Can't easily add "event" or override for what happens after reading the HttpClient response.

Open wizofaus opened this issue 3 years ago • 0 comments
trafficstars

As part of using the the GraphQLHttpClient, I need to be able to log the full request sent and response received. I can do the former by subclassing GraphQLRequest (which isn't the obvious way to do it, but no matter), but I can't see any obvious way of doing the latter, given the way that SendQueryAsync is written. In particular I need to be able to log the response regardless of any errors processing the response (parsing or otherwise). It seems that the only way I can really do it is override SendQueryAsync and replace it with a copy of the base implementation that adds in the logging hooks, which doesn't seem too nice, esp. because SendQueryAsync is not declared virtual in GraphQLHttpClient, meaning I can't even use the SendQueryAsync in GraphQLClientExtensions. Is there any plan to add such a facility?

I will say the need to read the entire response as a string and log it does mean you have to copy to, say, a MemoryStream first, so it would require quite some change to the current implementation of SendQueryAsync.

wizofaus avatar Mar 03 '22 03:03 wizofaus