Skip to content

Instantly share code, notes, and snippets.

@lowsky
Created June 21, 2016 18:16
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 lowsky/057704adaa1868f7e5ac7226a624b107 to your computer and use it in GitHub Desktop.
Save lowsky/057704adaa1868f7e5ac7226a624b107 to your computer and use it in GitHub Desktop.
Create a new GraphQL schema.json file for GraphQLHub
#!/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