UNPKG

tix-react-ssr

Version:

Tiket.com React Project Scripts

35 lines (30 loc) 951 B
#!/usr/bin/env babel-node --optional es7.asyncFunctions const fs = require('fs'); const path = require('path'); const { graphql } = require('graphql'); const { introspectionQuery, printSchema } = require('graphql/utilities'); const { schema } = require('../src/graphql'); (async () => { // Save JSON of full schema introspection for Babel Relay Plugin to use const 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, '../graphql.schema.json'), JSON.stringify(result, null, 2) ); } // Save user readable type system shorthand of schema fs.writeFile( path.join(__dirname, '../graphql.schema.graphql'), printSchema(schema), () => { console.log('GraphQL schema files generated.'); process.exit(0); } ); })();