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
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Relation Question
How do I create a relation from table y to an others x.$id. in my example I have a users table where I use Appwrites unique User IDs and I want other tables fo...
- Unknown attribute type: varchar / text
Since the `string` type is deprecated I tried using `varchar` and `text` in some newer tables, but when running `appwrite pull tables && appwrite types ./src/li...