Created
June 21, 2016 18:16
-
-
Save lowsky/057704adaa1868f7e5ac7226a624b107 to your computer and use it in GitHub Desktop.
Create a new GraphQL schema.json file for GraphQLHub
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 node_modules/.bin/babel-node | |
// when converting to a shell script, uncomment the line above | |
// This creates a new schema.json file which is needed, for using with a | |
// relay client | |
// use it together within | |
// | |
// https://github.com/clayallsopp/graphqlhub | |
var fs = require('fs'); | |
var path = require('path'); | |
var graphql = require('graphql').graphql; | |
var introspectionQuery = require('graphql/utilities').introspectionQuery; | |
import { GraphQLSchema } from 'graphql'; | |
import { GraphQLHub } from './graphqlhub-schemas'; | |
let schema = new GraphQLSchema({ | |
query : GraphQLHub.QueryObjectType, | |
mutation : GraphQLHub.MutationsType, | |
}); | |
graphql(schema, introspectionQuery).then(function(result) { | |
if (result.errors) return console.error('ERRRROR!', result.errors); | |
fs.writeFileSync(path.join(__dirname, './schema.json'), JSON.stringify(result, null, 2)) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment