GraphQL Cookbook

Deleting an object

10min

Deleting an object through the Parse GraphQL API

Problem

You want to delete an existing object in your database through the Parse GraphQL API.

Solution

Using the parse GraphQL, there are two different ways to delete an existing object in your database:

  • Using generic mutation - this is the mutation that you can use to delete an object of any class.
  • Using class mutation - this is the recommended mutation that you should use to delete an object of a specific class.

Version Information

Depending on the version of Parse you choose to run, the GraphQL queries, mutations and results will be slightly different. Please choose the correct example along with the Parse version you are running.

Using generic mutation

When you use the delete generic mutation, you send the object’s className and objectId, and Parse Server will delete this object.

Therefore, the objects’ delete generic mutation is the one that you can use for deleting an existing object of any class. If you want to delete an existing object of a specific class, we recommend using the class mutation.

This example will only work if you use a className and an objectId of an existing object. You can create an object using the creating an object recipe.

Parse 3.8.0

Request
Response


Example Parse 3.9.0 and later:

Parse 3.9.0 and later does not have the generic method DELETE. You must use the specific methods below to delete objects.

Using class mutation

Once you have already created your object’s class in your application’s schema (for instance, using the creating an object recipe), Parse Server instantly adds to your GraphQL API a new delete<ClassName> mutation to delete an existing object of this class.

Therefore, the object’s class mutation is the recommended method for deleting an existing object of a specific class.

This example will only work if you use a objectId or id of an existing object. You can create an object using the creating an object recipe.

Parse 3.10.0 and later

Request
Response


Older Parse Server Versions