graphql-client
graphql-client copied to clipboard
Feature: print raw JSON received
It'd be handy to have a way to print out the raw JSON from the response, for debugging purposes.
Looks like it'd be pretty easy to add that, depending on the preferred method for doing so.
Is this not covered by the original_hash method?
e.g.
require 'graphql'
require 'graphql/client'
require 'graphql/client/http'
url = 'https://gitlab.com/api/graphql'
http = GraphQL::Client::HTTP.new(url)
schema = GraphQL::Client.load_schema(http)
client = GraphQL::Client.new(schema:schema, execute: http)
QUERY = client.parse "query($id: ID!) { group(fullPath: $id) { id } }"
client.query(QUERY, variables: {}).original_hash
# => {"errors"=>[{"message"=>"Variable id of type ID! was provided invalid value", "locations"=>[{"line"=>1, "column"=>14}], "value"=>nil, "problems"=>[{"path"=>[], "explanation"=>"Expected value to not be null"}]}]}
Close enough I guess, but it still might be nice to be able to view the actual JSON?
Hm, I'm not sure I get what the difference is. For the above request, what kind of JSON are you expecting? Could you use JSON.generate or JSON.pretty_generate to get "true JSON" format?