You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* wip
* wip
* first version
* Add nested Query & Mutation
* Update _includes/graphql/users.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/classes.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/relay.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/files.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/files.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/getting-started.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/relay.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/graphql.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/relay.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/relay.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/getting-started.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/graphql.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/objects.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/objects.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/queries.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/objects.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/objects.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/queries.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Fix
* Add Relational Query
* Apply suggestions from code review
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/queries.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/queries.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Apply suggestions from code review
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Wip optimization
* GraphQL Api second position + remove beta + fix conflicts
* Apply suggestions from code review
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update _includes/graphql/optimization.md
Co-Authored-By: Tom Fox <13188249+TomWFox@users.noreply.github.com>
* Update queries.md
* minor changes
* change from previous review comment
* Update objects.md
* Update users.md
* Update graphql.md
* Update queries.md
* change from Omair review
* changes from earlier review
* Update optimization.md
Co-authored-by: Tom Fox <13188249+TomWFox@users.noreply.github.com>
GraphQL is a self documented API, to learn all available operations, it's recommended to start the Parse GraphQL Server and visit the Docs tab on the GraphQL Playground.
Since your application does not have a schema yet, you can use the `createClass` mutation to create your first class through the GraphQL API. Run the following:
4
+
```js
5
+
// Header
6
+
{
7
+
"X-Parse-Application-Id":"APPLICATION_ID",
8
+
"X-Parse-Master-Key":"MASTER_KEY"
9
+
}
10
+
```
11
+
12
+
```graphql
13
+
# GraphQL
14
+
mutationcreateGameScoreClass {
15
+
createClass(
16
+
input: {
17
+
clientMutationId: "anFrontId"
18
+
name: "GameScore"
19
+
schemaFields: {
20
+
addStrings: [{ name: "playerName" }]
21
+
addNumbers: [{ name: "score" }]
22
+
addBooleans: [{ name: "cheatMode" }]
23
+
}
24
+
}
25
+
) {
26
+
clientMutationId
27
+
class {
28
+
name
29
+
schemaFields {
30
+
name
31
+
__typename
32
+
}
33
+
}
34
+
}
35
+
}
36
+
```
37
+
```js
38
+
// Response
39
+
{
40
+
"data": {
41
+
"createClass": {
42
+
"clientMutationId":"anFrontId",
43
+
"class": {
44
+
"name":"GameScore",
45
+
"schemaFields": [
46
+
{
47
+
"name":"objectId",
48
+
"__typename":"SchemaStringField"
49
+
},
50
+
{
51
+
"name":"updatedAt",
52
+
"__typename":"SchemaDateField"
53
+
},
54
+
{
55
+
"name":"createdAt",
56
+
"__typename":"SchemaDateField"
57
+
},
58
+
{
59
+
"name":"playerName",
60
+
"__typename":"SchemaStringField"
61
+
},
62
+
{
63
+
"name":"score",
64
+
"__typename":"SchemaNumberField"
65
+
},
66
+
{
67
+
"name":"cheatMode",
68
+
"__typename":"SchemaBooleanField"
69
+
},
70
+
{
71
+
"name":"ACL",
72
+
"__typename":"SchemaACLField"
73
+
}
74
+
]
75
+
}
76
+
}
77
+
}
78
+
}
79
+
```
80
+
81
+
Parse Server learned from the first class that you created and now you have the `GameScore` class in your schema. You can now start using the automatically generated operations!
Copy file name to clipboardExpand all lines: _includes/graphql/customisation.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Customisation
2
2
3
-
Although we automtically generate a GraphQL schema based on your Parse Server database, we have provided a number of ways in which to configure and extend this schema.
3
+
Although we automatically generate a GraphQL schema based on your Parse Server database, we have provided a number of ways in which to configure and extend this schema.
The GraphQL API supports file upload via [GraphQL Upload](https://github.com/jaydenseric/graphql-upload), to send a `File` through `GraphQL` it's recommended to use the [Apollo Upload Client](https://github.com/jaydenseric/apollo-upload-client).
4
+
5
+
## Add a File field
6
+
First of all we will update our `GameScore` class with a `screenshot` field of type `File`.
7
+
8
+
```js
9
+
// Header
10
+
{
11
+
"X-Parse-Application-Id":"APPLICATION_ID",
12
+
"X-Parse-Master-Key":"MASTER_KEY"
13
+
}
14
+
```
15
+
```graphql
16
+
# GraphQL
17
+
mutationupdateGameScoreClass {
18
+
updateClass(
19
+
input: {
20
+
name: "GameScore",
21
+
schemaFields: {
22
+
addFiles: [{ name: "screenshot" }]
23
+
}
24
+
}
25
+
) {
26
+
class {
27
+
name
28
+
}
29
+
}
30
+
}
31
+
```
32
+
```js
33
+
// Response
34
+
{
35
+
"data": {
36
+
"updateClass": {
37
+
"class": {
38
+
"name":"GameScore"
39
+
}
40
+
}
41
+
}
42
+
}
43
+
```
44
+
45
+
## Create and add File
46
+
47
+
Currently the GraphQL API does not support nested mutation for the `File` type, so we need to send the file and then create/update the `GameScore` object with the returned information.
48
+
49
+
```js
50
+
// Header
51
+
{
52
+
"X-Parse-Application-Id":"APPLICATION_ID",
53
+
"X-Parse-Master-Key":"MASTER_KEY"// (optional)
54
+
}
55
+
```
56
+
```graphql
57
+
# GraphQL
58
+
# $file is a GraphQL Variable, see https://github.com/jaydenseric/apollo-upload-client
[GraphQL](https://graphql.org/), developed by Facebook, is an open-source data query and manipulation language for APIs. In addition to the traditional [REST API](/rest/guide/), Parse Server automatically generates a GraphQL API based on your current application schema.
3
+
[GraphQL](https://graphql.org/), developed by Facebook, is an open-source data query and manipulation language for APIs. In addition to the traditional [REST API](/rest/guide/), Parse Server automatically generates a GraphQL API based on your current application schema. Specifically, Parse has opted for the [Relay](https://relay.dev/docs/en/introduction-to-relay) specification in-line with industry best-practices.
4
4
5
+
## Fast launch
5
6
The easiest way to run the Parse GraphQL Server is using the CLI:
* Run `parse-server --help` or refer to [Parse Server Options](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html) for a complete list of Parse Server configuration options.
15
-
* ⚠️ Please do not use `--mountPlayground` option 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.
16
-
* ⚠️ The Parse GraphQL ```beta``` implementation is fully functional but discussions are taking place on how to improve it. So new versions of Parse Server can bring breaking changes to the current API.
16
+
* ⚠️ Please do not use `--mountPlayground` option 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. If you want to secure your API in production take a look at [Class Level Permissions](/js/guide/#class-level-permissions)
17
17
18
18
After running the CLI command, you should have something like this in your terminal:
[35071] parse-server running on http://localhost:1337/parse
23
+
[35071] GraphQL running on http://localhost:1337/graphql
24
+
[35071] Playground running on http://localhost:1337/playground
25
+
```
21
26
22
27
Since you have already started your Parse GraphQL Server, you can now visit [http://localhost:1337/playground](http://localhost:1337/playground) in your web browser to start playing with your GraphQL API.
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.
39
-
40
-
⚠️ Please do not use `--mountPlayground` option 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.
41
-
42
31
## Using Express.js
43
32
44
33
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
34
46
-
```bash
35
+
```sh
47
36
$ mkdir my-app
48
37
$ cd my-app
38
+
$ npm init
49
39
$ npm install parse-server express --save
50
40
```
51
41
52
42
Then, create an `index.js` file with the following content:
@@ -65,6 +58,7 @@ const parseServer = new ParseServer({
65
58
publicServerURL:'http://localhost:1337/parse'
66
59
});
67
60
61
+
// Create the GraphQL Server Instance
68
62
constparseGraphQLServer=newParseGraphQLServer(
69
63
parseServer,
70
64
{
@@ -73,10 +67,14 @@ const parseGraphQLServer = new ParseGraphQLServer(
73
67
}
74
68
);
75
69
76
-
app.use('/parse', parseServer.app); // (Optional) Mounts the REST API
77
-
parseGraphQLServer.applyGraphQL(app); // Mounts the GraphQL API
78
-
parseGraphQLServer.applyPlayground(app); // (Optional) Mounts the GraphQL Playground - do NOT use in Production
70
+
// (Optional) Mounts the REST API
71
+
app.use('/parse', parseServer.app);
72
+
// Mounts the GraphQL API using graphQLPath: '/graphql'
73
+
parseGraphQLServer.applyGraphQL(app);
74
+
// (Optional) Mounts the GraphQL Playground - do NOT use in Production
75
+
parseGraphQLServer.applyPlayground(app);
79
76
77
+
// Start the server
80
78
app.listen(1337, function() {
81
79
console.log('REST API running on http://localhost:1337/parse');
82
80
console.log('GraphQL API running on http://localhost:1337/graphql');
@@ -86,22 +84,22 @@ app.listen(1337, function() {
86
84
87
85
And finally start your app:
88
86
89
-
```bash
87
+
```sh
90
88
$ npx mongodb-runner start
91
89
$ node index.js
92
90
```
93
91
94
92
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.
95
93
96
-
⚠️ 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.
94
+
⚠️ 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. If you want to secure your API in production take a look at [Class Level Permissions](/js/guide/#class-level-permissions).
97
95
98
96
## Running Parse Dashboard
99
97
100
-
[Parse Dashboard](https://github.com/parse-community/parse-dashboard) is a standalone dashboard for managing your Parse Server apps, including your objects' schema and data, logs, jobs, and push notifications. Parse Dashboard also has a built-in GraphQL Playground that you can use to play around with your auto-generated Parse GraphQL API. It is the recommended option for production applications.
98
+
[Parse Dashboard](https://github.com/parse-community/parse-dashboard) is a standalone dashboard for managing your Parse Server apps, including your objects' schema and data, logs, jobs, CLPs, and push notifications. Parse Dashboard also has a built-in GraphQL Playground that you can use to play around with your auto-generated Parse GraphQL API. It is the recommended option for **production** applications.
101
99
102
100
The easiest way to run the Parse Dashboard is through its CLI:
To learn more about Parse Dashboard and its setup options, please visit [Parse Dashboard Repository](https://github.com/parse-community/parse-dashboard).
111
+
To learn more about Parse Dashboard and its setup options, please visit the [Parse Dashboard Repository](https://github.com/parse-community/parse-dashboard).
0 commit comments