GraphQL works with Mongoose

This commit is contained in:
Riccardo
2021-01-03 10:31:08 +01:00
parent c752e3ec80
commit b5129342e3
17 changed files with 3588 additions and 261 deletions

View File

@@ -0,0 +1,31 @@
import fs from 'fs-extra';
import path from 'path';
import { graphql } from 'graphql';
import { introspectionQuery, printSchema } from 'graphql/utilities';
import Schema from '../schema';
async function buildSchema() {
await fs.ensureFile('../data/schema.graphql.json');
await fs.ensureFile('../data/schema.graphql');
fs.writeFileSync(
path.join(__dirname, '../data/schema.graphql.json'),
JSON.stringify(await graphql(Schema, introspectionQuery), null, 2)
);
fs.writeFileSync(
path.join(__dirname, '../data/schema.graphql.txt'),
printSchema(Schema)
);
}
async function run() {
await buildSchema();
console.log('Schema build complete!');
}
run().catch(e => {
console.log(e);
process.exit(0);
});