ashkan18 / graphlient

Ruby GraphQL Client
MIT License
250 stars 43 forks source link

disable schema dump #64

Open leoGalani opened 5 years ago

leoGalani commented 5 years ago

Hi, is there a way to avoid automatic schema dump/introspection query?

Graphql for ruby (v1.9.7 ++) have the ability to disable those for production and I couldn't find a way of disabling the automatic fetch locally.

This is the message I'm getting and trying to client.schema or any operation (which in the end hits https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/schema/loader.rb#L16 )

(byebug) client.schema
*** KeyError Exception: key not found: "data"

Any thoughts besides mocking the schema?

yuki24 commented 5 years ago

Disabling them in production makes sense to me, but I do not think there is an easy way to do so at this point.

@ashkan18 Perhaps something we could accept with a PR?

yuki24 commented 5 years ago

Just quickly skimming the commit logs in graphql-client, but it doesn't seem to have support for it yet.

graphlient depends on graphql-client which depends on graphql-ruby, so it needs to be implemented in graphql-client first.

ashkan18 commented 5 years ago

thanks @leoGalani for opening the issue, yes i think at the moment the easiest approach would be either mocking the schema, or (maybe better?) use a local dump of your target schema locally and pass it to the client:

Client.new(url, schema_path: 'config/your_graphql_schema.json')

would this help you out?