GraphQL custom schema on CLI (#5828)

* Add --graphQLSchema to CLI

* Add custom graphql schema instructions to readme file

* Update README.md

Co-Authored-By: Tom Fox <tomfox@surprises.io>

* Update src/Options/Definitions.js

Co-Authored-By: Tom Fox <tomfox@surprises.io>

* Update src/Options/docs.js

Co-Authored-By: Tom Fox <tomfox@surprises.io>

* Update src/Options/index.js

Co-Authored-By: Tom Fox <tomfox@surprises.io>
This commit is contained in:
Antonio Davi Macedo Coelho de Castro
2019-07-19 12:29:45 -07:00
committed by GitHub
parent 6d5f6b4c94
commit a6f441248b
5 changed files with 65 additions and 2 deletions

View File

@@ -5,7 +5,9 @@ var batch = require('./batch'),
express = require('express'),
middlewares = require('./middlewares'),
Parse = require('parse/node').Parse,
path = require('path');
{ parse } = require('graphql'),
path = require('path'),
fs = require('fs');
import { ParseServerOptions, LiveQueryServerOptions } from './Options';
import defaults from './defaults';
@@ -267,9 +269,17 @@ class ParseServer {
app.use(options.mountPath, this.app);
if (options.mountGraphQL === true || options.mountPlayground === true) {
let graphQLCustomTypeDefs = undefined;
if (options.graphQLSchema) {
graphQLCustomTypeDefs = parse(
fs.readFileSync(options.graphQLSchema, 'utf8')
);
}
const parseGraphQLServer = new ParseGraphQLServer(this, {
graphQLPath: options.graphQLPath,
playgroundPath: options.playgroundPath,
graphQLCustomTypeDefs,
});
if (options.mountGraphQL) {