create valid relay schema.json
This commit is contained in:
@@ -2,28 +2,35 @@
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { Schema } from '../data/schema';
|
||||
import { graphql } from 'graphql';
|
||||
import schema from '../config/graphql/schema';
|
||||
import { graphql, GraphQLSchema } from 'graphql';
|
||||
import { introspectionQuery, printSchema } from 'graphql/utilities';
|
||||
import DB from './../config/database';
|
||||
|
||||
// Save JSON of full schema introspection for Babel Relay Plugin to use
|
||||
(async () => {
|
||||
var 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)
|
||||
);
|
||||
}
|
||||
})();
|
||||
DB.sync().then(()=>{
|
||||
|
||||
// Save user readable type system shorthand of schema
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, '../data/schema.graphql'),
|
||||
printSchema(Schema)
|
||||
);
|
||||
var Schema = schema();
|
||||
|
||||
// Save JSON of full schema introspection for Babel Relay Plugin to use
|
||||
(async () => {
|
||||
var 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, '../config/graphql/schema.json'),
|
||||
JSON.stringify(result, null, 2)
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
||||
// Save user readable type system shorthand of schema
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, '../config/graphql/schema.graphql'),
|
||||
printSchema(Schema)
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user