GraphQL Cookbook
Deleting an object
10 min
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 https //www back4app com/docs/parse graphql/graphql mutation delete object#mutation generic this is the mutation that you can use to delete an object of any class using class mutation https //www back4app com/docs/parse graphql/graphql mutation delete object#mutation class 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 delete generic mutation, you send the object’s classname classname and objectid objectid , and parse server will delete this object therefore, the objects’ delete 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 https //www back4app com/docs/parse graphql/graphql mutation delete object#mutation class this example will only work if you use a classname classname and an objectid objectid of an existing object you can create an object using the creating an object recipe parse 3 8 0 request 1 mutation deleteobject { 2 delete(classname "hero", objectid "rr8jmfrnks") 3 } response 1 { 2 "data" { 3 "delete" true 4 } 5 } 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 https //www back4app com/docs/parse graphql/graphql mutation create object#mutation generic recipe), parse server instantly adds to your graphql api a new delete\<classname> 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 objectid or id id of an existing object you can create an object using the creating an object recipe parse 3 10 0 and later request 1 mutation deleteobject { 2 deletehero(input { 3 id "sgvybzpvrm5tvdm1ynbp" 4 }){ 5 hero{ 6 id 7 } 8 } 9 } response 1 { 2 "data" { 3 "deletehero" { 4 "hero" { 5 "id" "sgvybzpvrm5tvdm1ynbp" 6 } 7 } 8 } 9 } older parse server versions parse 3 9 0 class mutation request 1 mutation deleteobject { 2 deletehero(id "ckhurmmjzw"){ 3 id 4 } 5 } response 1 { 2 "data" { 3 "deletehero" { 4 "id" "ckhurmmjzw" 5 } 6 } 7 } parse 3 8 0 class mutation request 1 mutation deleteobject { 2 deletehero(objectid "rr8jmfrnks"){ 3 objectid 4 } 5 } response 1 { 2 "data" { 3 "deletehero" { 4 "objectid" "rr8jmfrnks" 5 } 6 } 7 } parse 3 7 2 generic mutation parse server 3 7 2 1 mutation deleteobject { 2 objects { 3 delete(classname "hero", objectid "ffyobotk85") 4 } 5 } result parse 3 7 2 1 { 2 "data" { 3 "objects" { 4 "delete" true 5 } 6 } 7 } class mutation parse server 3 7 2 1 mutation deletehero { 2 objects { 3 deletehero(objectid "jjh0aqqjfs") 4 } 5 } result parse 3 7 2 1 { 2 "data" { 3 "objects" { 4 "delete" true 5 } 6 } 7 }