Skip to content

Commit 6fb0efb

Browse files
davimacedoTomWFox
andauthored
Update GraphQL guide (#674)
* Update GraphQL guide * Update _includes/graphql/objects.md Co-Authored-By: Tom Fox <[email protected]>
1 parent fcfed9f commit 6fb0efb

File tree

5 files changed

+254
-287
lines changed

5 files changed

+254
-287
lines changed

_includes/graphql/getting-started.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The easiest way to run the Parse GraphQL Server is using the CLI:
77
```bash
88
$ npm install -g parse-server mongodb-runner
99
$ mongodb-runner start
10-
$ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test --mountGraphQL --mountPlayground
10+
$ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test --publicServerURL http://localhost:1337/parse --mountGraphQL --mountPlayground
1111
```
1212

1313
Notes:
@@ -32,7 +32,7 @@ $ git clone https://github.com/parse-community/parse-server
3232
$ cd parse-server
3333
$ docker build --tag parse-server .
3434
$ docker run --name my-mongo -d mongo
35-
$ 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
35+
$ docker run --name my-parse-server --link my-mongo:mongo -p 1337:1337 -d parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://mongo/test --publicServerURL http://localhost:1337/parse --mountGraphQL --mountPlayground
3636
```
3737

3838
After starting the server, you can visit [http://localhost:1337/playground](http://localhost:1337/playground) in your browser to start playing with your GraphQL API.
@@ -41,7 +41,15 @@ After starting the server, you can visit [http://localhost:1337/playground](http
4141

4242
## Using Express.js
4343

44-
You can also mount the GraphQL API in an Express.js application together with the REST API or solo:
44+
You can also mount the GraphQL API in an Express.js application together with the REST API or solo. You first need to create a new project and install the required dependencies:
45+
46+
```bash
47+
$ mkdir my-app
48+
$ cd my-app
49+
$ npm install parse-server express --save
50+
```
51+
52+
Then, create an `index.js` file with the following content:
4553

4654
```js
4755
const express = require('express');
@@ -53,7 +61,8 @@ const parseServer = new ParseServer({
5361
databaseURI: 'mongodb://localhost:27017/test',
5462
appId: 'APPLICATION_ID',
5563
masterKey: 'MASTER_KEY',
56-
serverURL: 'http://localhost:1337/parse'
64+
serverURL: 'http://localhost:1337/parse',
65+
publicServerURL: 'http://localhost:1337/parse'
5766
});
5867

5968
const parseGraphQLServer = new ParseGraphQLServer(
@@ -75,7 +84,14 @@ app.listen(1337, function() {
7584
});
7685
```
7786

78-
After starting the server, you can visit [http://localhost:1337/playground](http://localhost:1337/playground) in your browser to start playing with your GraphQL API.
87+
And finally start your app:
88+
89+
```bash
90+
$ npx mongodb-runner start
91+
$ node index.js
92+
```
93+
94+
After starting the app, you can visit [http://localhost:1337/playground](http://localhost:1337/playground) in your browser to start playing with your GraphQL API.
7995

8096
⚠️ Please do not mount the GraphQL Playground in production as anyone could access your API Playground and read or change your application's data. [Parse Dashboard](#running-parse-dashboard) has a built-in GraphQL Playground and it is the recommended option for production apps.
8197

0 commit comments

Comments
 (0)