diff --git a/README.md b/README.md index c3720c4138..b3de664674 100644 --- a/README.md +++ b/README.md @@ -41,36 +41,7 @@ Parse Server works with the Express web application framework. It can be added to existing web applications, or run by itself. -The full documentation for Parse Server is available in the [wiki](https://github.com/parse-community/parse-server/wiki). The [Parse Server guide](http://docs.parseplatform.org/parse-server/guide/) is a good place to get started. An [API reference](http://parseplatform.org/parse-server/api/) and [Cloud Code guide](https://docs.parseplatform.org/cloudcode/guide/) are also available. If you're interested in developing for Parse Server, the [Development guide](http://docs.parseplatform.org/parse-server/guide/#development-guide) will help you get set up. - -- [Getting Started](#getting-started) - - [Running Parse Server](#running-parse-server) - - [Locally](#locally) - - [Docker](#inside-a-docker-container) - - [Saving an Object](#saving-your-first-object) - - [Connect an SDK](#connect-your-app-to-parse-server) - - [Running elsewhere](#running-parse-server-elsewhere) - - [Sample Application](#parse-server-sample-application) - - [Parse Server + Express](#parse-server--express) - - [Configuration](#configuration) - - [Basic Options](#basic-options) - - [Client Key Options](#client-key-options) - - [Email Verification & Password Reset](#email-verification-and-password-reset) - - [Custom Pages](#custom-pages) - - [Using Environment Variables](#using-environment-variables-to-configure-parse-server) - - [Available Adapters](#available-adapters) - - [Configuring File Adapters](#configuring-file-adapters) - - [Logging](#logging) -- [Live Queries](#live-queries) -- [GraphQL](#graphql) -- [Upgrading to 3.0.0](#upgrading-to-300) -- [Support](#support) -- [Ride the Bleeding Edge](#want-to-ride-the-bleeding-edge) -- [Contributing](#contributing) -- [Contributors](#contributors) -- [Sponsors](#sponsors) -- [Backers](#backers) - +The full documentation for Parse Server is available [here](https://docs.parseplatform.org/parse-server/guide/). An [API reference](http://parseplatform.org/parse-server/api/) and [Cloud Code guide](https://docs.parseplatform.org/cloudcode/guide/) are also available. # Getting Started @@ -116,71 +87,22 @@ That's it! You are now running a standalone version of Parse Server on your mach **Using a remote MongoDB?** Pass the `--databaseURI DATABASE_URI` parameter when starting `parse-server`. Learn more about configuring Parse Server [here](#configuration). For a full list of available options, run `parse-server --help`. -### Saving your first object - -Now that you're running Parse Server, it is time to save your first object. We'll use the [REST API](http://docs.parseplatform.org/rest/guide), but you can easily do the same using any of the [Parse SDKs](http://parseplatform.org/#sdks). Run the following: - -```bash -$ curl -X POST \ --H "X-Parse-Application-Id: APPLICATION_ID" \ --H "Content-Type: application/json" \ --d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \ -http://localhost:1337/parse/classes/GameScore -``` - -You should get a response similar to this: +### Getting started with SDKs -```js -{ - "objectId": "2ntvSpRGIK", - "createdAt": "2016-03-11T23:51:48.050Z" -} -``` - -You can now retrieve this object directly (make sure to replace `2ntvSpRGIK` with the actual `objectId` you received when the object was created): +Now that you're running Parse Server, it is time to save your first object. Parse Server has a broad range of [SDKs](http://parseplatform.org/#sdks) you can use to connect to your server. -```bash -$ curl -X GET \ - -H "X-Parse-Application-Id: APPLICATION_ID" \ - http://localhost:1337/parse/classes/GameScore/2ntvSpRGIK -``` -```json -// Response -{ - "objectId": "2ntvSpRGIK", - "score": 1337, - "playerName": "Sean Plott", - "cheatMode": false, - "updatedAt": "2016-03-11T23:51:48.050Z", - "createdAt": "2016-03-11T23:51:48.050Z" -} -``` - -Keeping tracks of individual object ids is not ideal, however. In most cases you will want to run a query over the collection, like so: - -```bash -$ curl -X GET \ - -H "X-Parse-Application-Id: APPLICATION_ID" \ - http://localhost:1337/parse/classes/GameScore -``` -```json -// The response will provide all the matching objects within the `results` array: -{ - "results": [ - { - "objectId": "2ntvSpRGIK", - "score": 1337, - "playerName": "Sean Plott", - "cheatMode": false, - "updatedAt": "2016-03-11T23:51:48.050Z", - "createdAt": "2016-03-11T23:51:48.050Z" - } - ] -} - -``` - -To learn more about using saving and querying objects on Parse Server, check out the [Parse documentation](http://docs.parseplatform.org). +Getting started with: +- [REST API](https://docs.parseplatform.org/rest/guide/#your-configuration) +- [GraphQL API](https://docs.parseplatform.org/graphql/guide/#getting-started) +- [iOS SDK](https://docs.parseplatform.org/ios/guide/#getting-started) +- [Android SDK](https://docs.parseplatform.org/android/guide/#getting-started) +- [JavaScript SDK](https://docs.parseplatform.org/js/guide/#getting-started) +- [.NET + Xamarin SDK](https://docs.parseplatform.org/dotnet/guide/#getting-started) +- [macOS SDK](https://docs.parseplatform.org/macos/guide/#getting-started) +- [Unity SDK](https://docs.parseplatform.org/unity/guide/#getting-started) +- [PHP SDK](https://docs.parseplatform.org/php/guide/#getting-started) +- [Arduino SDK](https://docs.parseplatform.org/arduino/guide/#getting-started) +- [Embedded C SDK](https://docs.parseplatform.org/embedded_c/guide/#getting-started) ### Connect your app to Parse Server @@ -210,11 +132,11 @@ We have provided a basic [Node.js application](https://github.com/parse-communit You can also create an instance of Parse Server, and mount it on a new or existing Express website: ```js -var express = require('express'); -var ParseServer = require('parse-server').ParseServer; -var app = express(); +const express = require('express'); +const ParseServer = require('parse-server').ParseServer; +const app = express(); -var api = new ParseServer({ +const api = new ParseServer({ databaseURI: 'mongodb://localhost:27017/dev', // Connection string for your MongoDB database cloud: './cloud/main.js', // Path to your Cloud Code appId: 'myAppId', @@ -231,557 +153,11 @@ app.listen(1337, function() { }); ``` -For a full list of available options, run `parse-server --help` or take a look at [Parse Server Configurations](http://parseplatform.org/parse-server/api/master/ParseServerOptions.html). - -## Configuration - -Parse Server can be configured using the following options. You may pass these as parameters when running a standalone `parse-server`, or by loading a configuration file in JSON format using `parse-server path/to/configuration.json`. If you're using Parse Server on Express, you may also pass these to the `ParseServer` object as options. - -For the full list of available options, run `parse-server --help` or take a look at [Parse Server Configurations](http://parseplatform.org/parse-server/api/master/ParseServerOptions.html). - -### Basic options - -* `appId` **(required)** - The application id to host with this server instance. You can use any arbitrary string. For migrated apps, this should match your hosted Parse app. -* `masterKey` **(required)** - The master key to use for overriding ACL security. You can use any arbitrary string. Keep it secret! For migrated apps, this should match your hosted Parse app. -* `databaseURI` **(required)** - The connection string for your database, i.e. `mongodb://user:pass@host.com/dbname`. Be sure to [URL encode your password](https://app.zencoder.com/docs/guides/getting-started/special-characters-in-usernames-and-passwords) if your password has special characters. -* `port` - The default port is 1337, specify this parameter to use a different port. -* `serverURL` - URL to your Parse Server (don't forget to specify http:// or https://). This URL will be used when making requests to Parse Server from Cloud Code. -* `cloud` - The absolute path to your cloud code `main.js` file. -* `push` - Configuration options for APNS and GCM push. See the [Push Notifications quick start](http://docs.parseplatform.org/parse-server/guide/#push-notifications_push-notifications-quick-start). - -### Client key options - -The client keys used with Parse are no longer necessary with Parse Server. If you wish to still require them, perhaps to be able to refuse access to older clients, you can set the keys at initialization time. Setting any of these keys will require all requests to provide one of the configured keys. - -* `clientKey` -* `javascriptKey` -* `restAPIKey` -* `dotNetKey` - -### Email verification and password reset - -Verifying user email addresses and enabling password reset via email requires an email adapter. As part of the `parse-server` package we provide an adapter for sending email through Mailgun. To use it, sign up for Mailgun, and add this to your initialization code: - -```js -var server = ParseServer({ - ...otherOptions, - // Enable email verification - verifyUserEmails: true, - - // if `verifyUserEmails` is `true` and - // if `emailVerifyTokenValidityDuration` is `undefined` then - // email verify token never expires - // else - // email verify token expires after `emailVerifyTokenValidityDuration` - // - // `emailVerifyTokenValidityDuration` defaults to `undefined` - // - // email verify token below expires in 2 hours (= 2 * 60 * 60 == 7200 seconds) - emailVerifyTokenValidityDuration: 2 * 60 * 60, // in seconds (2 hours = 7200 seconds) - - // set preventLoginWithUnverifiedEmail to false to allow user to login without verifying their email - // set preventLoginWithUnverifiedEmail to true to prevent user from login if their email is not verified - preventLoginWithUnverifiedEmail: false, // defaults to false - - // The public URL of your app. - // This will appear in the link that is used to verify email addresses and reset passwords. - // Set the mount path as it is in serverURL - publicServerURL: 'https://example.com/parse', - // Your apps name. This will appear in the subject and body of the emails that are sent. - appName: 'Parse App', - // The email adapter - emailAdapter: { - module: '@parse/simple-mailgun-adapter', - options: { - // The address that your emails come from - fromAddress: 'parse@example.com', - // Your domain from mailgun.com - domain: 'example.com', - // Your API key from mailgun.com - apiKey: 'key-mykey', - } - }, - - // account lockout policy setting (OPTIONAL) - defaults to undefined - // if the account lockout policy is set and there are more than `threshold` number of failed login attempts then the `login` api call returns error code `Parse.Error.OBJECT_NOT_FOUND` with error message `Your account is locked due to multiple failed login attempts. Please try again after minute(s)`. After `duration` minutes of no login attempts, the application will allow the user to try login again. - accountLockout: { - duration: 5, // duration policy setting determines the number of minutes that a locked-out account remains locked out before automatically becoming unlocked. Set it to a value greater than 0 and less than 100000. - threshold: 3, // threshold policy setting determines the number of failed sign-in attempts that will cause a user account to be locked. Set it to an integer value greater than 0 and less than 1000. - }, - // optional settings to enforce password policies - passwordPolicy: { - // Two optional settings to enforce strong passwords. Either one or both can be specified. - // If both are specified, both checks must pass to accept the password - // 1. a RegExp object or a regex string representing the pattern to enforce - validatorPattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})/, // enforce password with at least 8 char with at least 1 lower case, 1 upper case and 1 digit - // 2. a callback function to be invoked to validate the password - validatorCallback: (password) => { return validatePassword(password) }, - validationError: 'Password must contain at least 1 digit.' // optional error message to be sent instead of the default "Password does not meet the Password Policy requirements." message. - doNotAllowUsername: true, // optional setting to disallow username in passwords - maxPasswordAge: 90, // optional setting in days for password expiry. Login fails if user does not reset the password within this period after signup/last reset. - maxPasswordHistory: 5, // optional setting to prevent reuse of previous n passwords. Maximum value that can be specified is 20. Not specifying it or specifying 0 will not enforce history. - //optional setting to set a validity duration for password reset links (in seconds) - resetTokenValidityDuration: 24*60*60, // expire after 24 hours - } -}); -``` - -You can also use other email adapters contributed by the community such as: -- [parse-smtp-template (Multi Language and Multi Template)](https://www.npmjs.com/package/parse-smtp-template) -- [parse-server-postmark-adapter](https://www.npmjs.com/package/parse-server-postmark-adapter) -- [parse-server-sendgrid-adapter](https://www.npmjs.com/package/parse-server-sendgrid-adapter) -- [parse-server-mandrill-adapter](https://www.npmjs.com/package/parse-server-mandrill-adapter) -- [parse-server-simple-ses-adapter](https://www.npmjs.com/package/parse-server-simple-ses-adapter) -- [parse-server-mailgun-adapter-template](https://www.npmjs.com/package/parse-server-mailgun-adapter-template) -- [parse-server-sendinblue-adapter](https://www.npmjs.com/package/parse-server-sendinblue-adapter) -- [parse-server-mailjet-adapter](https://www.npmjs.com/package/parse-server-mailjet-adapter) -- [simple-parse-smtp-adapter](https://www.npmjs.com/package/simple-parse-smtp-adapter) -- [parse-server-generic-email-adapter](https://www.npmjs.com/package/parse-server-generic-email-adapter) - -### Custom Pages - -It’s possible to change the default pages of the app and redirect the user to another path or domain. - -```js -var server = ParseServer({ - ...otherOptions, - - customPages: { - passwordResetSuccess: "http://yourapp.com/passwordResetSuccess", - verifyEmailSuccess: "http://yourapp.com/verifyEmailSuccess", - parseFrameURL: "http://yourapp.com/parseFrameURL", - linkSendSuccess: "http://yourapp.com/linkSendSuccess", - linkSendFail: "http://yourapp.com/linkSendFail", - invalidLink: "http://yourapp.com/invalidLink", - invalidVerificationLink: "http://yourapp.com/invalidVerificationLink", - choosePassword: "http://yourapp.com/choosePassword" - } -}) -``` - -### Using environment variables to configure Parse Server - -You may configure the Parse Server using environment variables: - -```bash -PORT -PARSE_SERVER_APPLICATION_ID -PARSE_SERVER_MASTER_KEY -PARSE_SERVER_DATABASE_URI -PARSE_SERVER_URL -PARSE_SERVER_CLOUD -``` - -The default port is 1337, to use a different port set the PORT environment variable: - -```bash -$ PORT=8080 parse-server --appId APPLICATION_ID --masterKey MASTER_KEY -``` - -For the full list of configurable environment variables, run `parse-server --help` or take a look at [Parse Server Configuration](https://github.com/parse-community/parse-server/blob/master/src/Options/Definitions.js). - -### Available Adapters - -All official adapters are distributed as scoped pacakges on [npm (@parse)](https://www.npmjs.com/search?q=scope%3Aparse). - -Some well maintained adapters are also available on the [Parse Server Modules](https://github.com/parse-server-modules) organization. - -You can also find more adapters maintained by the community by searching on [npm](https://www.npmjs.com/search?q=parse-server%20adapter&page=1&ranking=optimal). - -### Configuring File Adapters - -Parse Server allows developers to choose from several options when hosting files: - -* `GridFSBucketAdapter`, which is backed by MongoDB; -* `S3Adapter`, which is backed by [Amazon S3](https://aws.amazon.com/s3/); or -* `GCSAdapter`, which is backed by [Google Cloud Storage](https://cloud.google.com/storage/) - -`GridFSBucketAdapter` is used by default and requires no setup, but if you're interested in using S3 or Google Cloud Storage, additional configuration information is available in the [Parse Server guide](http://docs.parseplatform.org/parse-server/guide/#configuring-file-adapters). - -### Idempodency Enforcement - -**Caution, this is an experimental feature that may not be appropriate for production.** - -This feature deduplicates identical requests that are received by Parse Server mutliple times, typically due to network issues or network adapter access restrictions on mobile operating systems. - -Identical requests are identified by their request header `X-Parse-Request-Id`. Therefore a client request has to include this header for deduplication to be applied. Requests that do not contain this header cannot be deduplicated and are processed normally by Parse Server. This means rolling out this feature to clients is seamless as Parse Server still processes request without this header when this feature is enbabled. - -> This feature needs to be enabled on the client side to send the header and on the server to process the header. Refer to the specific Parse SDK docs to see whether the feature is supported yet. - -Deduplication is only done for object creation and update (`POST` and `PUT` requests). Deduplication is not done for object finding and deletion (`GET` and `DELETE` requests), as these operations are already idempotent by definition. - -#### Configuration example -``` -let api = new ParseServer({ - idempotencyOptions: { - paths: [".*"], // enforce for all requests - ttl: 120 // keep request IDs for 120s - } -} -``` -#### Parameters - -| Parameter | Optional | Type | Default value | Example values | Environment variable | Description | -|-----------|----------|--------|---------------|-----------|-----------|-------------| -| `idempotencyOptions` | yes | `Object` | `undefined` | | PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_OPTIONS | Setting this enables idempotency enforcement for the specified paths. | -| `idempotencyOptions.paths`| yes | `Array` | `[]` | `.*` (all paths, includes the examples below),
`functions/.*` (all functions),
`jobs/.*` (all jobs),
`classes/.*` (all classes),
`functions/.*` (all functions),
`users` (user creation / update),
`installations` (installation creation / update) | PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_PATHS | An array of path patterns that have to match the request path for request deduplication to be enabled. The mount path must not be included, for example to match the request path `/parse/functions/myFunction` specifiy the path pattern `functions/myFunction`. A trailing slash of the request path is ignored, for example the path pattern `functions/myFunction` matches both `/parse/functions/myFunction` and `/parse/functions/myFunction/`. | -| `idempotencyOptions.ttl` | yes | `Integer` | `300` | `60` (60 seconds) | PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_TTL | The duration in seconds after which a request record is discarded from the database. Duplicate requests due to network issues can be expected to arrive within milliseconds up to several seconds. This value must be greater than `0`. | - -#### Notes - -- This feature is currently only available for MongoDB and not for Postgres. - -### Logging - -Parse Server will, by default, log: -* to the console -* daily rotating files as new line delimited JSON - -Logs are also viewable in Parse Dashboard. - -**Want to log each request and response?** Set the `VERBOSE` environment variable when starting `parse-server`. Usage :- `VERBOSE='1' parse-server --appId APPLICATION_ID --masterKey MASTER_KEY` - -**Want logs to be in placed in a different folder?** Pass the `PARSE_SERVER_LOGS_FOLDER` environment variable when starting `parse-server`. Usage :- `PARSE_SERVER_LOGS_FOLDER='' parse-server --appId APPLICATION_ID --masterKey MASTER_KEY` - -**Want to log specific levels?** Pass the `logLevel` parameter when starting `parse-server`. Usage :- `parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --logLevel LOG_LEVEL` - -**Want new line delimited JSON error logs (for consumption by CloudWatch, Google Cloud Logging, etc)?** Pass the `JSON_LOGS` environment variable when starting `parse-server`. Usage :- `JSON_LOGS='1' parse-server --appId APPLICATION_ID --masterKey MASTER_KEY` - -# Live Queries - -Live queries are meant to be used in real-time reactive applications, where just using the traditional query paradigm could cause several problems, like increased response time and high network and server usage. Live queries should be used in cases where you need to continuously update a page with fresh data coming from the database, which often happens in (but is not limited to) online games, messaging clients and shared to-do lists. - -Take a look at [Live Query Guide](https://docs.parseplatform.org/parse-server/guide/#live-queries), [Live Query Server Setup Guide](https://docs.parseplatform.org/parse-server/guide/#scalability) and [Live Query Protocol Specification](https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification). You can setup a standalone server or multiple instances for scalability (recommended). - -# GraphQL - -[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, Parse Server automatically generates a GraphQL API based on your current application schema. Parse Server also allows you to define your custom GraphQL queries and mutations, whose resolvers can be bound to your cloud code functions. - -## Running - -### Using the CLI - -The easiest way to run the Parse GraphQL API is through the CLI: - -```bash -$ npm install -g parse-server mongodb-runner -$ mongodb-runner start -$ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test --publicServerURL http://localhost:1337/parse --mountGraphQL --mountPlayground -``` - -After starting the server, you can visit http://localhost:1337/playground in your browser to start playing with your GraphQL API. - -***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. - -### Using Docker - -You can also run the Parse GraphQL API inside a Docker container: - -```bash -$ git clone https://github.com/parse-community/parse-server -$ cd parse-server -$ docker build --tag parse-server . -$ docker run --name my-mongo -d mongo -``` - -#### Running the Parse Server Image - -```bash -$ docker run --name my-parse-server --link my-mongo:mongo -v config-vol:/parse-server/config -p 1337:1337 -d parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://mongo/test --publicServerURL http://localhost:1337/parse --mountGraphQL --mountPlayground -``` - -***Note:*** *If you want to use [Cloud Code](https://docs.parseplatform.org/cloudcode/guide/) feature, please add `-v cloud-code-vol:/parse-server/cloud --cloud /parse-server/cloud/main.js` to command above. Make sure the `main.js` file is available in the `cloud-code-vol` directory before run this command. Otherwise, an error will occur.* - -After starting the server, you can visit http://localhost:1337/playground in your browser to start playing with your GraphQL API. - -***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. - -### Using Express.js - -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: - -```bash -$ mkdir my-app -$ cd my-app -$ npm install parse-server express --save -``` - -Then, create an `index.js` file with the following content: - -```js -const express = require('express'); -const { default: ParseServer, ParseGraphQLServer } = require('parse-server'); - -const app = express(); - -const parseServer = new ParseServer({ - databaseURI: 'mongodb://localhost:27017/test', - appId: 'APPLICATION_ID', - masterKey: 'MASTER_KEY', - serverURL: 'http://localhost:1337/parse', - publicServerURL: 'http://localhost:1337/parse' -}); - -const parseGraphQLServer = new ParseGraphQLServer( - parseServer, - { - graphQLPath: '/graphql', - playgroundPath: '/playground' - } -); - -app.use('/parse', parseServer.app); // (Optional) Mounts the REST API -parseGraphQLServer.applyGraphQL(app); // Mounts the GraphQL API -parseGraphQLServer.applyPlayground(app); // (Optional) Mounts the GraphQL Playground - do NOT use in Production - -app.listen(1337, function() { - console.log('REST API running on http://localhost:1337/parse'); - console.log('GraphQL API running on http://localhost:1337/graphql'); - console.log('GraphQL Playground running on http://localhost:1337/playground'); -}); -``` - -And finally start your app: - -```bash -$ npx mongodb-runner start -$ node index.js -``` - -After starting the app, you can visit http://localhost:1337/playground in your browser to start playing with your GraphQL API. - -***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. - -## Checking the API health - -Run the following: - -```graphql -query Health { - health -} -``` - -You should receive the following response: - -```json -{ - "data": { - "health": true - } -} -``` - -## Creating your first class - -Since your application does not have any schema yet, you can use the `createClass` mutation to create your first class. Run the following: - -```graphql -mutation CreateClass { - createClass( - name: "GameScore" - schemaFields: { - addStrings: [{ name: "playerName" }] - addNumbers: [{ name: "score" }] - addBooleans: [{ name: "cheatMode" }] - } - ) { - name - schemaFields { - name - __typename - } - } -} -``` - -You should receive the following response: - -```json -{ - "data": { - "createClass": { - "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" - } - ] - } - } -} -``` - -## Using automatically generated operations - -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! - -Run the following to create your first object: - -```graphql -mutation CreateGameScore { - createGameScore( - fields: { - playerName: "Sean Plott" - score: 1337 - cheatMode: false - } - ) { - id - updatedAt - createdAt - playerName - score - cheatMode - ACL - } -} -``` - -You should receive a response similar to this: - -```json -{ - "data": { - "createGameScore": { - "id": "XN75D94OBD", - "updatedAt": "2019-09-17T06:50:26.357Z", - "createdAt": "2019-09-17T06:50:26.357Z", - "playerName": "Sean Plott", - "score": 1337, - "cheatMode": false, - "ACL": null - } - } -} -``` - -You can also run a query to this new class: - -```graphql -query GameScores { - gameScores { - results { - id - updatedAt - createdAt - playerName - score - cheatMode - ACL - } - } -} -``` - -You should receive a response similar to this: - -```json -{ - "data": { - "gameScores": { - "results": [ - { - "id": "XN75D94OBD", - "updatedAt": "2019-09-17T06:50:26.357Z", - "createdAt": "2019-09-17T06:50:26.357Z", - "playerName": "Sean Plott", - "score": 1337, - "cheatMode": false, - "ACL": null - } - ] - } - } -} -``` - -## Customizing your GraphQL Schema - -Parse GraphQL Server allows you to create a custom GraphQL schema with own queries and mutations to be merged with the auto-generated ones. You can resolve these operations using your regular cloud code functions. - -To start creating your custom schema, you need to code a `schema.graphql` file and initialize Parse Server with `--graphQLSchema` and `--cloud` options: - -```bash -$ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test --publicServerURL http://localhost:1337/parse --cloud ./cloud/main.js --graphQLSchema ./cloud/schema.graphql --mountGraphQL --mountPlayground -``` - -### Creating your first custom query - -Use the code below for your `schema.graphql` and `main.js` files. Then restart your Parse Server. - -```graphql -# schema.graphql -extend type Query { - hello: String! @resolve -} -``` - -```js -// main.js -Parse.Cloud.define('hello', async () => { - return 'Hello world!'; -}); -``` - -You can now run your custom query using GraphQL Playground: +## Documentation -```graphql -query { - hello -} -``` - -You should receive the response below: - -```json -{ - "data": { - "hello": "Hello world!" - } -} -``` - -## Learning more - -The [Parse GraphQL Guide](http://docs.parseplatform.org/graphql/guide/) is a very good source for learning how to use the Parse GraphQL API. +For more information as to how to configure your Parse Server, [check out our Parse Server guide.](https://docs.parseplatform.org/parse-server/guide/#usage) -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. -Additionally, the [GraphQL Learn Section](https://graphql.org/learn/) is a very good source to learn more about the power of the GraphQL language. - -# Upgrading to 3.0.0 - -Starting 3.0.0, parse-server uses the JS SDK version 2.0. -In short, parse SDK v2.0 removes the backbone style callbacks as well as the Parse.Promise object in favor of native promises. -All the Cloud Code interfaces also have been updated to reflect those changes, and all backbone style response objects are removed and replaced by Promise style resolution. - -We have written up a [migration guide](3.0.0.md), hoping this will help you transition to the next major release. # Want to ride the bleeding edge? @@ -853,7 +229,3 @@ Support this project by becoming a sponsor. Your logo will show up here with a l Support us with a monthly donation and help us continue our activities. [Become a backer!](https://opencollective.com/parse-server#backer) - ------ - -As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.