How to use Graghql

My Graghql is up and running. When I enter the following code in the playground
query Health {
, it returns
“data”: {
“health”: true

However, when I tried to create an object by using:

mutation CreateObject {
  objects {
    create(className: "GameScore" fields: { score: 1337 playerName: "Sean Plott" cheatMode: false }) {

it returns errors:
“error”: {
“errors”: [
“message”: “Cannot query field “objects” on type “Mutation”.”,
“locations”: [
“line”: 2,
“column”: 3
“extensions”: {
“exception”: {
“stacktrace”: [
“GraphQLError: Cannot query field “objects” on type “Mutation”.”,
" at Object.Field (/private/var/www/parse_server_example/Parse-Server-example-latest/node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.js:46:31)",
" at Object.enter (/private/var/www/parse_server_example/Parse-Server-example-latest/node_modules/graphql/language/visitor.js:323:29)",
" at Object.enter (/private/var/www/parse_server_example/Parse-Server-example-latest/node_modules/graphql/utilities/TypeInfo.js:370:25)",
" at visit (/private/var/www/parse_server_example/Parse-Server-example-latest/node_modules/graphql/language/visitor.js:243:26)",
" at Object.validate (/private/var/www/parse_server_example/Parse-Server-example-latest/node_modules/graphql/validation/validate.js:69:24)",
" at validate (/private/var/www/parse_server_example/Parse-Server-example-latest/node_modules/apollo-server-core/dist/requestPipeline.js:233:34)",
" at Object. (/private/var/www/parse_server_example/Parse-Server-example-latest/node_modules/apollo-server-core/dist/requestPipeline.js:119:42)",
" at ()",
" at fulfilled (/private/var/www/parse_server_example/Parse-Server-example-latest/node_modules/apollo-server-core/dist/requestPipeline.js:5:58)",
" at processTicksAndRejections (internal/process/task_queues.js:97:5)"

Could anyone explain to me what is wrong here? Thanks

What is the version of Parse Server that you are running?

How could I tell which version of Parse Server I am running? I looked at my git history. I cloned the parse server example repo on Mar 22, 2021.
This is the repo I cloned:

Check in your local package.json file.

Right. I jus realize I can find the info at package.json. Here are the versions:
“parse”: “2.19.0”,
“parse-server”: “4.5.0”,

The API changed in Parse 4.5.0 in order to turn it Relay compliant. There is no generic mutation anymore. You need to create the class beforehand and then use the mutate to create the object: GraphQL API Guide | Parse

1 Like

Thanks. I looked at the link you said. Where do you enter the X-Parse-Application-Id in playground?
// Header { "X-Parse-Application-Id": "APPLICATION_ID", "X-Parse-Master-Key": "MASTER_KEY" // (optional) }
You know that in the curl command, one can specify APPLICATION_ID this way:
curl -X POST
-H “X-Parse-Application-Id: APPLICATION_ID”
-H “Content-Type: application/json”
-d ‘{“score”:123,“playerName”:“Sean Plott”,“cheatMode”:false}’

Do I need to specify Application-Id in playground?


Yes. You need to add. But if you spin up playground using parse-server or use the playground built in parse dashboard, the headers are automatically loaded for you.

I see. But, do you have an example about how the headers are used in Swift? Thanks

It depends on the client library that you are using. Which one are you using?

I am using this one:


This one is not for the GraphQL API but for the REST API.

Then, which one is for the GraphQL API for Swift?

I’d recommend either Apollo Client or Relay.

To supplement @davimacedo comments, you should use Apollo or Relay only if you are set on using GraphQL with the parse server.

Since the Swift SDK you referenced uses REST, you don’t need to do anything special to enable REST on the parse-server, it just works out-of-the box. If you already began writing your client app with the Parse Swift SDK, you should weigh the trade-offs and decode if you want to change it.

Also, you should look for the tradeoffs between the Parse Swift client and the Apollo/Relay clients. The Swift SDK implements most of the REST functionality for the server (that I know of) and designed using the latest Swift and SwiftUI features. Because of this, you will end up finding the Swift SDK easier to use with Swift based OS’s than the other SDKs (if you are familiar with Swift). I don’t know all of the features of GraphQL on the parse-sever, but I would imagine they are not at parity with the REST yet, though Graph may be getting close with all of the development that has been occurring there. I also imagine that with Graph, you have to worry about a lot more on the client side. With the Swift SDK, you don’t think about “REST”, you just code using Parse Objects, Queries, etc. as REST is used under the hood and is agnostic to the developer.

@cbaker6 Thanks for your comments. I actually don’t understand how Apollo works here. It looks like Apollo is a state management tool and I understand it can be used to manage states in the front-end.
I come from front-end background. But how does Apollo fit here? Even if you use Apollo, you still need the Swift SDK, right? Otherwise, how does your swift code communicate with Graghql?

No, if you use the Swift SDK, you don’t need GraphQL, you just add the SDK to your Xcode project via SPM, cocoapods, etc. and you are done.

For Graph, I’m no expert and @davimacedo can provide better explanations than I can, but there are a number of tutorials online that show how to integrate Apollo and use it directly. A detailed one is below:

You don’t need the ParseSwift SDK when using Apollo as it can do everything by itself with it’s own dependencies.

So, do you mean if I use Apollo, I no longer need any Parse client side software? So, Apollo can handle user authentication, push notification and all other functions provided by ParseSwift SDK? If this is true, then Apollo is pretty amazing.

Both are awesome solutions. If, for whatever reason, you prefer to use the GraphQL API, you should go with Apollo Client or Relay or any other third-party GraphQL client. In the case you prefer to use the REST API, ParseSwift SDK is the way to go.

Thanks. But if I choose Apollo, can it handle user authentication, push notification and all other functions as easy as ParseSwift SDK? Apollo is not specifically built for mobile apps. So, I feel it possibly will lack some features ParseSwift SDK provides.