Wednesday, May 17, 2017

How to generate schema.graphql from introspection Query

To generate a graphql schema from a running Graphql server. The following script use buildClientSchema, printSchema and introspectionQuery from "graphql" module to introspect, build and print the schema to graphql format.

In my case I was running a graphql-ruby server in a Rails application, but it doesn't matter what server is running.

Then run the script and if the graphql server is running and properly configured you should find two schema files one in JSON and the other in graphql format.

$ node generate_schema.js 

No comments:

The Y Combinator (Slight Return)

Tiger got to hunt, Bird got to fly; Lisper got to sit and wonder, (Y (Y Y))? Tiger got to sleep, Bird got to land; Lisper got to tell hims...