-
-
Notifications
You must be signed in to change notification settings - Fork 514
GraphQL Docs for Parse Server 3.10.0 #688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 31 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
5446d2c
wip
Moumouls 8b86952
wip
Moumouls 101b599
first version
Moumouls 8ee7334
Add nested Query & Mutation
Moumouls d46021c
Update _includes/graphql/users.md
Moumouls 6973cb9
Update _includes/graphql/classes.md
Moumouls 655f7a0
Update _includes/graphql/relay.md
Moumouls a981385
Update _includes/graphql/files.md
Moumouls 2fc85d3
Update _includes/graphql/files.md
Moumouls 80ae6be
Update _includes/graphql/getting-started.md
Moumouls 74dbbbe
Update _includes/graphql/relay.md
Moumouls 4cf995f
Update _includes/graphql/graphql.md
Moumouls 0445972
Update _includes/graphql/relay.md
Moumouls dceac2f
Update _includes/graphql/relay.md
Moumouls 4ad78dd
Update _includes/graphql/getting-started.md
Moumouls 93b4aa9
Update _includes/graphql/graphql.md
Moumouls e76b5db
Update _includes/graphql/objects.md
Moumouls 0b91812
Update _includes/graphql/objects.md
Moumouls 54782cc
Update _includes/graphql/queries.md
Moumouls e0e3171
Update _includes/graphql/objects.md
Moumouls bfeec9c
Update _includes/graphql/objects.md
Moumouls 59efa78
Update _includes/graphql/queries.md
Moumouls df55fb7
Fix
Moumouls 43a48ba
Add Relational Query
Moumouls 415c48c
Apply suggestions from code review
Moumouls ba8fc5c
Update _includes/graphql/queries.md
Moumouls a6c05ed
Update _includes/graphql/queries.md
Moumouls f6feced
Apply suggestions from code review
Moumouls baaf5cc
Wip optimization
Moumouls 08ffb1c
Merge branch 'original/gh-pages' into graphql
Moumouls 75e69a5
GraphQL Api second position + remove beta + fix conflicts
Moumouls d67699a
Apply suggestions from code review
Moumouls 559ccd8
Update _includes/graphql/optimization.md
Moumouls 3f8298f
Update queries.md
TomWFox 2fd6b2d
minor changes
TomWFox f28d38c
change from previous review comment
TomWFox e5f2854
Update objects.md
TomWFox ff65f65
Update users.md
TomWFox f889f63
Update graphql.md
TomWFox a7fd38c
Update queries.md
TomWFox 906e9ba
change from Omair review
TomWFox 950efe6
changes from earlier review
TomWFox 273f7bc
Update optimization.md
TomWFox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# API Doc | ||
|
||
GraphQL is a self documented API, to learn all available operations on the **GraphQL API** it's recommended to start the Parse GraphQL Server and visit the "Docs" tab on the GraphQL Playground. | ||
|
||
```bash | ||
$ npm install -g parse-server mongodb-runner | ||
$ mongodb-runner start | ||
$ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test --mountGraphQL --mountPlayground | ||
``` | ||
|
||
Visit your [Local GraphQL Playground](http://localhost:1337/playground) | ||
|
||
<img alt="GraphQL Playground" data-echo="{{ '/assets/images/graphql/graphql-playground.png' | prepend: site.baseurl }}"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Classes | ||
|
||
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: | ||
```js | ||
// Header | ||
{ | ||
"X-Parse-Application-Id": "APPLICATION_ID", | ||
"X-Parse-Master-Key": "MASTER_KEY" | ||
} | ||
``` | ||
|
||
```graphql | ||
# GraphQL | ||
mutation createGameScoreClass { | ||
createClass( | ||
input: { | ||
clientMutationId: "anFrontId" | ||
name: "GameScore" | ||
schemaFields: { | ||
addStrings: [{ name: "playerName" }] | ||
addNumbers: [{ name: "score" }] | ||
addBooleans: [{ name: "cheatMode" }] | ||
} | ||
} | ||
) { | ||
clientMutationId | ||
class { | ||
name | ||
schemaFields { | ||
name | ||
__typename | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
```js | ||
// Response | ||
{ | ||
"data": { | ||
"createClass": { | ||
"clientMutationId": "anFrontId", | ||
"class": { | ||
"name": "GameScore", | ||
"schemaFields": [ | ||
{ | ||
"name": "objectId", | ||
"__typename": "SchemaStringField" | ||
}, | ||
{ | ||
"name": "updatedAt", | ||
"__typename": "SchemaDateField" | ||
}, | ||
{ | ||
"name": "createdAt", | ||
"__typename": "SchemaDateField" | ||
}, | ||
{ | ||
"name": "playerName", | ||
"__typename": "SchemaStringField" | ||
}, | ||
{ | ||
"name": "score", | ||
"__typename": "SchemaNumberField" | ||
}, | ||
{ | ||
"name": "cheatMode", | ||
"__typename": "SchemaBooleanField" | ||
}, | ||
{ | ||
"name": "ACL", | ||
"__typename": "SchemaACLField" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# Files | ||
|
||
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 [Apollo Upload Client](https://github.com/jaydenseric/apollo-upload-client). | ||
|
||
## Add a File field | ||
First of all we will update our `GameScore` class with a `screenshot` field of type `File` | ||
Moumouls marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```js | ||
// Header | ||
{ | ||
"X-Parse-Application-Id": "APPLICATION_ID", | ||
"X-Parse-Master-Key": "MASTER_KEY" | ||
} | ||
``` | ||
```graphql | ||
# GraphQL | ||
mutation updateGameScoreClass { | ||
updateClass( | ||
input: { | ||
name: "GameScore", | ||
schemaFields: { | ||
addFiles: [{ name: "screenshot" }] | ||
} | ||
} | ||
) { | ||
class { | ||
name | ||
} | ||
} | ||
} | ||
``` | ||
```js | ||
// Response | ||
{ | ||
"data": { | ||
"updateClass": { | ||
"class": { | ||
"name": "GameScore" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Create and add File | ||
|
||
Currently the GraphQL API does not support nested mutation for `File` type, so we need to send the file and then create/update the `GameScore` with the returned information. | ||
Moumouls marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```js | ||
// Header | ||
{ | ||
"X-Parse-Application-Id": "APPLICATION_ID", | ||
"X-Parse-Master-Key": "MASTER_KEY" // (optional) | ||
} | ||
``` | ||
```graphql | ||
# GraphQL | ||
# $file is a GraphQL Variable, see https://github.com/jaydenseric/apollo-upload-client | ||
mutation createFile($file: Upload!) { | ||
createFile(input: { upload: $file }) { | ||
fileInfo { | ||
name | ||
url | ||
} | ||
} | ||
} | ||
``` | ||
```js | ||
// Response | ||
{ | ||
"data": { | ||
"createFile": { | ||
"fileInfo": { | ||
"name": "6a4d43c3f0512bcb6bf05b6b0e7db47d_file.png", | ||
"url": "http://localhost:1337/graphq/files/APPLICATION_ID/6a4d43c3f0512bcb6bf05b6b0e7db47d_file.png" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Then add the file to a new `GameScore` object. | ||
```js | ||
// Header | ||
{ | ||
"X-Parse-Application-Id": "APPLICATION_ID", | ||
"X-Parse-Master-Key": "MASTER_KEY" // (optional) | ||
} | ||
``` | ||
```graphql | ||
# GraphQL | ||
mutation createGameScore { | ||
createGameScore( | ||
input: { | ||
fields: { | ||
playerName: "John" | ||
screenshot: { | ||
__type: "File", | ||
name: "6a4d43c3f0512bcb6bf05b6b0e7db47d_file.png" | ||
url: "http://localhost:1337/graphq/files/APPLICATION_ID/6a4d43c3f0512bcb6bf05b6b0e7db47d_file.png" | ||
} | ||
} | ||
} | ||
) { | ||
gameScore { | ||
screenshot { | ||
name | ||
url | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
```js | ||
// Response | ||
{ | ||
"data": { | ||
"createGameScore": { | ||
"gameScore": { | ||
"screenshot": { | ||
"name": "6a4d43c3f0512bcb6bf05b6b0e7db47d_file.png", | ||
"url": "http://localhost:1337/graphq/files/APPLICATION_ID/6a4d43c3f0512bcb6bf05b6b0e7db47d_file.png" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# GraphQL | ||
|
||
Before continuing, it is recommended to study some of the GraphQL documentation: | ||
|
||
A GraphQL API contains 3 main concepts: | ||
* `Query`: Allow to fetch data | ||
TomWFox marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* `Mutation`: Create/Modify data | ||
TomWFox marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* `Subscription`: Listen data changes | ||
TomWFox marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Learn Query & Mutation | ||
To learn how to query data and execute operation on a GraphQL API, just follow this link: [Learn Query & Mutation](https://graphql.org/learn/queries/). |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.