Skip to content

Commit 7222bb6

Browse files
authored
Running GraphQL (#5810)
* Improving GraphQL running instruction * Improving GraphQL learning more section * Fixing typo
1 parent f91034a commit 7222bb6

File tree

1 file changed

+65
-3
lines changed

1 file changed

+65
-3
lines changed

README.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ Take a look at [Live Query Guide](https://docs.parseplatform.org/parse-server/gu
363363

364364
## Running
365365

366+
### Using the CLI
367+
368+
The easiest way to run the Parse GraphQL API is through the CLI:
369+
366370
```
367371
$ npm install -g parse-server mongodb-runner
368372
$ mongodb-runner start
@@ -371,7 +375,63 @@ $ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongo
371375

372376
After starting the server, you can visit http://localhost:1337/playground in your browser to start playing with your GraphQL API.
373377

374-
***Note:*** Do ***NOT*** use --mountPlayground option in production.
378+
***Note:*** Do ***NOT*** use --mountPlayground option in production. [Parse Dashboard](https://github.com/parse-community/parse-dashboard) has a built-in GraphQL Playground and it is the recommended option for production apps.
379+
380+
### Using Docker
381+
382+
You can also run the Parse GraphQL API inside a Docker container:
383+
384+
```
385+
$ git clone https://github.com/parse-community/parse-server
386+
$ cd parse-server
387+
$ docker build --tag parse-server .
388+
$ docker run --name my-mongo -d mongo
389+
$ docker run --name my-parse-server --link my-mongo:mongo -d parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://mongo/test --mountGraphQL --mountPlayground
390+
```
391+
392+
After starting the server, you can visit http://localhost:1337/playground in your browser to start playing with your GraphQL API.
393+
394+
***Note:*** Do ***NOT*** use --mountPlayground option in production. [Parse Dashboard](https://github.com/parse-community/parse-dashboard) has a built-in GraphQL Playground and it is the recommended option for production apps.
395+
396+
### Using Express.js
397+
398+
You can also mount the GraphQL API in an Express.js application together with the REST API or solo:
399+
400+
```
401+
const express = require('express');
402+
const { default: ParseServer, ParseGraphQLServer } = require('parse-server');
403+
404+
const app = express();
405+
406+
const parseServer = new ParseServer({
407+
databaseURI: 'mongodb://localhost:27017/test',
408+
appId: 'APPLICATION_ID',
409+
masterKey: 'MASTER_KEY',
410+
serverURL: 'http://localhost:1337/parse'
411+
});
412+
413+
const parseGraphQLServer = new ParseGraphQLServer(
414+
parseServer,
415+
{
416+
graphQLPath: '/graphql',
417+
playgroundPath: '/playground'
418+
}
419+
);
420+
421+
app.use('/parse', parseServer.app); // (Optional) Mounts the REST API
422+
parseGraphQLServer.applyGraphQL(app); // Mounts the GraphQL API
423+
parseGraphQLServer.applyPlayground(app); // (Optional) Mounts the GraphQL Playground - do NOT use in Production
424+
425+
app.listen(1337, function() {
426+
console.log('REST API running on http://localhost:1337/parse');
427+
console.log('GraphQL API running on http://localhost:1337/graphql');
428+
console.log('GraphQL Playground running on http://localhost:1337/playground');
429+
});
430+
```
431+
432+
After starting the server, you can visit http://localhost:1337/playground in your browser to start playing with your GraphQL API.
433+
434+
***Note:*** Do ***NOT*** mount the GraphQL Playground in production. [Parse Dashboard](https://github.com/parse-community/parse-dashboard) has a built-in GraphQL Playground and it is the recommended option for production apps.
375435

376436
## Checking the API health
377437

@@ -495,9 +555,11 @@ You should receive a response similar to this:
495555

496556
## Learning more
497557

498-
Please look at the right side of your GraphQL Playground. You will see the `DOCS` and `SCHEMA` menus. They are automatically generated by analysing your application schema. Please refer to them and learn more about everything that you can do with your Parse GraphQL API.
558+
The [Parse GraphQL Guide](http://docs.parseplatform.org/graphql/guide/) is a very good source for learning how to use the Parse GraphQL API.
559+
560+
You also have a very powerful tool inside your GraphQL Playground. Please look at the right side of your GraphQL Playground. You will see the `DOCS` and `SCHEMA` menus. They are automatically generated by analyzing your application schema. Please refer to them and learn more about everything that you can do with your Parse GraphQL API.
499561

500-
Additionally, the [GraphQL Learn Section](https://graphql.org/learn/) is a very good source to start learning about the power of the GraphQL language.
562+
Additionally, the [GraphQL Learn Section](https://graphql.org/learn/) is a very good source to learn more about the power of the GraphQL language.
501563

502564
# Upgrading to 3.0.0
503565

0 commit comments

Comments
 (0)