Skip to content

Commit bffde92

Browse files
committed
CLI options now working for GraphQL
1 parent fe16406 commit bffde92

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

src/GraphQL/ParseGraphQLServer.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ class ParseGraphQLServer {
7676
renderPlaygroundPage({
7777
endpoint: this.config.graphQLPath,
7878
subscriptionEndpoint: this.config.subscriptionsPath,
79+
tabs: [
80+
{
81+
endpoint: this.config.graphQLPath,
82+
query: `query {
83+
health
84+
}`,
85+
headers: {
86+
'X-Parse-Application-Id': this.parseServer.config.appId,
87+
'X-Parse-Master-Key': this.parseServer.config.masterKey,
88+
},
89+
},
90+
],
7991
})
8092
);
8193
res.end();

src/Options/Definitions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ module.exports.ParseServerOptions = {
365365
},
366366
mountPlayground: {
367367
env: 'PARSE_SERVER_MOUNT_PLAYGROUND',
368-
help: 'Mounts the GraphQL Playground',
368+
help: 'Mounts the GraphQL Playground. Never use this option in production.',
369369
action: parsers.booleanParser,
370370
default: false,
371371
},

src/ParseServer.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ import { UsersRouter } from './Routers/UsersRouter';
3434
import { PurgeRouter } from './Routers/PurgeRouter';
3535
import { AudiencesRouter } from './Routers/AudiencesRouter';
3636
import { AggregateRouter } from './Routers/AggregateRouter';
37-
3837
import { ParseServerRESTController } from './ParseServerRESTController';
3938
import * as controllers from './Controllers';
39+
import { ParseGraphQLServer } from './GraphQL/ParseGraphQLServer';
40+
4041
// Mutate the Parse object to add the Cloud Code handlers
4142
addParseCloud();
4243

@@ -264,6 +265,22 @@ class ParseServer {
264265
}
265266

266267
app.use(options.mountPath, this.app);
268+
269+
if (options.mountGraphQL === true || options.mountPlayground === true) {
270+
const parseGraphQLServer = new ParseGraphQLServer(this, {
271+
graphQLPath: options.graphQLPath,
272+
playgroundPath: options.playgroundPath,
273+
});
274+
275+
if (options.mountGraphQL) {
276+
parseGraphQLServer.applyGraphQL(app);
277+
}
278+
279+
if (options.mountPlayground) {
280+
parseGraphQLServer.applyPlayground(app);
281+
}
282+
}
283+
267284
const server = app.listen(options.port, options.host, callback);
268285
this.server = server;
269286

src/cli/parse-server.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,39 @@ runner({
8484
});
8585
} else {
8686
ParseServer.start(options, () => {
87-
console.log(
88-
'[' + process.pid + '] parse-server running on ' + options.serverURL
89-
);
87+
printSuccessMessage();
9088
});
9189
}
9290
} else {
9391
ParseServer.start(options, () => {
9492
logOptions();
9593
console.log('');
94+
printSuccessMessage();
95+
});
96+
}
97+
98+
function printSuccessMessage() {
99+
console.log(
100+
'[' + process.pid + '] parse-server running on ' + options.serverURL
101+
);
102+
if (options.mountGraphQL) {
96103
console.log(
97-
'[' + process.pid + '] parse-server running on ' + options.serverURL
104+
'[' +
105+
process.pid +
106+
'] GraphQL running on http://localhost:' +
107+
options.port +
108+
options.graphQLPath
98109
);
99-
});
110+
}
111+
if (options.mountPlayground) {
112+
console.log(
113+
'[' +
114+
process.pid +
115+
'] Playground running on http://localhost:' +
116+
options.port +
117+
options.playgroundPath
118+
);
119+
}
100120
}
101121
},
102122
});

0 commit comments

Comments
 (0)