Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created July 1, 2016 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chuck0523/058d74de4bd86bc96043096b2bc0156f to your computer and use it in GitHub Desktop.
Save chuck0523/058d74de4bd86bc96043096b2bc0156f to your computer and use it in GitHub Desktop.
#!/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