Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josemarluedke/062cec8fa351b88281af3d659d5c84ab to your computer and use it in GitHub Desktop.
Save josemarluedke/062cec8fa351b88281af3d659d5c84ab to your computer and use it in GitHub Desktop.
Generate a SDL graphql string from a introspection schema result
const { buildClientSchema, printSchema } = require('graphql');
const fs = require('fs');
const introspectionSchemaResult = JSON.parse(
fs.readFileSync('./graphql.schema.json')
);
const graphqlSchemaObj = buildClientSchema(introspectionSchemaResult);
const sdlString = printSchema(graphqlSchemaObj);
console.log(sdlString);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment