graphql-client
graphql-client copied to clipboard
Experiment with client executor extra return information
Following https://github.com/github/graphql-client/issues/160 and https://github.com/github/graphql-client/pull/249 I've decided to experiment a bit with the stack see what could be done.
After digging it a bit more, I understood the purpose of injecting the execute
param to the client initialization as a way to have multiple backends.
In my case I was going after information from the HTTP call, but I understand it need to be more generic to adapt to any backend that might use the lib. This is what I was exploring:
result = SWAPI::Client.query(Hero::Query)
result.data
result.client_extras # Hash controlled by the execute statement of `GraphQL::Client::HTTP`
result.client_extras.response # Http response object
result.client_extras.response.headers # Http response headers
I hit a blocker and hoping some quick feedback could unlock me from finishing the proposition.
Typically this is used this way:
Client = GraphQL::Client.new(schema: Schema, execute: HTTP)
That being said, in tests we sometimes use it this way:
@client = GraphQL::Client.new(schema: Schema, execute: Schema)
https://github.com/github/graphql-client/blob/5d9f9d36b34d77c6afafbba6a0a6a3c5e575e81e/test/test_client_errors.rb#L69 https://github.com/github/graphql-client/blob/5d9f9d36b34d77c6afafbba6a0a6a3c5e575e81e/test/test_query_result.rb#L229
With my limited experience with this library and GraphQL I was not able to determine why we use Schema
as the execute
param and what exactly is the real life usage here. Could it be this is only for test purposes, only working because of some reason out of my understanding and these tests can be safely changed?
@jhawthorn something you can pitch in? 😸 💚
We just run into this problem and noticed this PR - is there anything in particular blocking this?