Created
July 1, 2016 13:41
-
-
Save chuck0523/058d74de4bd86bc96043096b2bc0156f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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