Make request with no schema
I am trying to make a request from an endpoint for which I do not have the schema available. Additionally, the endpoint is configured not to respond to introspection requests. Whenever I try to initialize a client with a nil schema, I get an error:
gems/ruby-2.5.1/gems/graphql-1.9.6/lib/graphql/schema/loader.rb:16:in `fetch': key not found: "data" (KeyError)
I know the fields I want to request; is there a way to make the request without having to specify a schema?
There are several parts of this client that rely on the schema being present. Once the client is initialized, you must then register the queries with the client before you're allowed to use them. The registration process validates the query against the schema and disallows the query if it doesn't match.
If you don't have the schema available with a local file, and the API doesn't respond to introspection, you probably can't use this client. You can always serialize the requests as normal HTTP Posts - the only major difference is you won't get the nice serialization that this client provides (e.g. response.data.my_query.my_data is much nicer than response.body['data']['myQuery']['myData'] - but the latter is a good fallback if you need to get around the schema requirements)
Yeah.. but seems like this client is also based on https://github.com/rmosolgo/graphql-ruby which 'just' released their 'disable_introspective_query_in_production' thing... (which is the root of the reported error) -> https://github.com/rmosolgo/graphql-ruby/pull/2327...
Any update to this issue? The production server cannot be run with introspection turned on.
I just ran into the same issue. We are using Apollo Gateway and have introspection queries disabled in production.
As @leoGalani said since this client so closely related to graphql-ruby it makes sense to be able to handle this feature in the client as well.
I don't like the idea of removing this gem in my application and doing the requests without an abstraction layer. The local file also doesn't sound appealing as its a workaround creating maintenance overhead.
My question at this point is if you consider changing the client into that direction or if its out of scope?
In my opinion it's an overkill to use graphql-client if you cannot fetch the schema, except you are using graphql-client for other hosts which do have an schema. Otherwise you can just use/extract a simple HTTP client like the one in graphql/client/http.rb and build the requests yourself in an easy manner.
Regarding the nice serialization of the response, you can simply use HashDot or Hashie or any other similar gem.
You can run dump_schema and store it in a shared bucket.