Query Batching: batch many documents deletes operations in one GraphQL request
- 0
- Databases
- GraphQL
I attempted to batch multiple document deletion operations into a single GraphQL request, as shown in the following code:
queries = []
count = 0
for message_id in body["delete"]:
temp = {}
count += 1
query = (
f"mutation DeleteDocument{count}"
+ """($databaseId: String!, $collectionId: String!, $documentId: String!){
databasesDeleteDocument(
databaseId: $databaseId,
collectionId: $collectionId,
documentId: $documentId
) {
status
}
}
"""
)
variables = {
"databaseId": "651f17af2552b5dc8126",
"collectionId": "651f17d6a1d4cdf7c76a",
"documentId": "{}".format(message_id),
}
temp["query"] = query
temp["operationName"] = f"DeleteDocument{count}"
temp["variables"] = variables
queries.append(temp)
result = graphql.mutation(queries)
print(f"result = > {result}")
for re in result:
print(re)```
However, it only deleted one document and returned a single response. Is this issue caused by the Appwrite GraphQL Delete operation? I ask because I tried a different operation, like batching many create operations, and it worked. So, what is the problem and how can I solve it in the GraphQL batching?
Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting
??
What exactly was the full response?
It just return one response of deleting one message only:
b''
hmmmm this is sort of expected....the regular deleteDocument() doesn't return anything
Does deleting a document disrupt the GraphQL request, and is this the reason for only deleting one document only?
??
As far as I know, it shouldn't
So why does it delete only one document and return a single response for all queries?
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Edit ID of an existing collection
Hi there. Is it possible to edit an ID of an existing collection? Right now it looks impossible from AppWrite cloud at least.
- Seed db
hello there... is this correct way to seed appwrite