Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env babel-node --optional es7.asyncFunctions
import fs from 'fs'
import path from 'path'
import { Schema } from '../data/schema.js'
import { graphql } from 'graphql'
import { introspectionQuery, printSchema } from 'graphql/utilities'
(async () => {
let result = await (graphql(Schema, introspectionQuery))
if(result.errors) {
console.error(
'ERROR introspecting schema: ',
JSON.stringify(result.errors, null, 2)
)
} else {
fs.writeFileSync(
path.join(__dirname, '../data/schema.json'),
JSON.stringify(result, null, 2)
)
}
})()
fs.writeFileSync(
path.join(__dirname, '../data/schema.graphql'),
printSchema(Schema)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment