Generate schema.json with GraphiQL or GraphQL endpoint

I am having problems creating a schema.json file that can be processed using the babel-relay-plugin module without triggering an error. Having looked at the schema.json file included in the relay examples folder, I tried to copy the query into GraphiQL, but I can’t get it right. I use Laravel as a backend. Can I do this via GraphiQL or send a query to the GraphQL endpoint and save the response?

An error occurred while trying to parse the schema.json file:

Cannot read property 'reduce' of undefined while parsing file: /Users/username/Sites/Homestead/Code/ineedmg-graphql/resources/assets/js/app.js 

Last attempt to use GraphiQL:

 { __schema { queryType { name }, types { kind, name, description, fields { name, description, type { name, kind, ofType { name description } } isDeprecated, deprecationReason, }, inputFields { name description } interfaces { kind name description }, enumValues { name description isDeprecated deprecationReason } }, mutationType { name }, directives { name, description, onOperation, onFragment, onField, args { name description defaultValue } } } } 
+6
source share
1 answer

Yes! If you look at the examples, you will see that they generate the schema.json file by executing the request: https://github.com/relayjs/relay-starter-kit/blob/84da9351d100f97e6ed4f08bc70a893779e61c29/scripts/updateSchema.js#L11

This query is actually this particular query from graphql-js: https://github.com/graphql/graphql-js/blob/v0.4.12/src/utilities/introspectionQuery.js#L11-L89 .

+13
source

All Articles