Delete Objects
Introduction
Deleting objects is handled by the delete<Object Name>
mutation. For example: deleteEpisode
.
As well as deleting entire objects, you can also delete different parts of an object, specifically:
- A language
- A specific language version
- A specific global version
The delete episode query returns a array of object deletion objects:
[
{
"uid" # The affected UID
"language" # The affected language
"language_version" # The deleted language version
"global_version" # The deleted global version
"messages" # Any additional message
}
]
For each object in the array:
-
If the
language
attribute is returned and thelanguage_version
is null then the entire language has been deleted -
If the
language
attribute andlanguage_version
attribute is returned then a specific language version has been deleted -
If the
global_version
attribute is returned then a specific global version has been deleted
Delete Entire Object
By passing the UID as the only argument the entire object with all its languages, versions and field config will be deleted.
mutation deleteEpisode {
deleteEpisode(uid: "4220f2b2-db6c-4c26-b870-204066bf534a") {
uid
}
}
Response:
[
{
"uid": "4220f2b2-db6c-4c26-b870-204066bf534a"
}
]
Batch Deleting Many Objects
You can delete up to 100 objects or translations in a single request using the batchDeleteObjects
mutation.
All batch deleting is done via background tasks, and the response of the mutation is just the background task ID Because of this, after the request has been made, the deletes will take some time to finish processing.
Exceptions during batch delete
If any exceptions are thrown during a batch delete, for example if the UID or language can't be found, that object in the batch will be ignored and the other objects will continue to be processed.
An exception message will be sent to the task messages.
This request will delete 3 entire objects:
mutation {
batchDeleteObjects(objects: [
{
uid: "01HEAMD69Q4A0B8KDA9V2D67KA"
},
{
uid: "01HEAKASKWVE766NPX1B0PD8RD"
}
{
uid: "01HEAK9MC0QJ1DY83ZSET1D26M"
}
]) {
task_id
}
}
It's also possible to delete a translation as part of a batch delete mutation. This example deletes both the French and German translation of the same object:
mutation {
batchDeleteObjects(objects: [
{
uid: "01HEAMD69Q4A0B8KDA9V2D67KA"
},
{
uid: "01HEAKASKWVE766NPX1B0PD8RD",
language: "fr-FR"
}
{
uid: "01HEAKASKWVE766NPX1B0PD8RD",
language: "de-DE"
}
]) {
task_id
}
}
Unlike a normal delete request, if the language attempting to be deleted is the only language, the entire object will be deleted.
Updated 4 months ago