-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Support for Batching Mutations #517
Comments
For the time being one can use: const batchRequests = async (requests) => Promise.all(requests.map((request) => mutationClient.request(request.document, request.variables))) |
The downside with this workaround is that it's not really batching requests since multiple requests are sent albeit in parallel. |
The idea is to use this in the meanwhile there is no graphql-request working feature that contemplates batching mutations. Once graphql-request develops the feature, it is just the matter of using graphql-request's |
Graffle has batch support in the sense that graphQL does. For example you can do this in GraphQL: mutation {
deleteUser1: deleteUser(id:"abc1")
deleteUser2: deleteUser(id:"abc2")
deleteUser3: deleteUser(id:"abc3")
deleteUser4: deleteUser(id:"abc4")
# ...
} This is run serially on the server which may not be what you want. Interestingly you could run them in parallel by using nested fields: mutation {
delete: {
user1: user(id:"abc1")
user2: user(id:"abc2")
user3: user(id:"abc3")
user4: user(id:"abc4")
# ...
}
} Now those deletes would be executed in parallel by the server. I understand there is also the concept of HTTP Request batching wherein multiple GraphQL documents are sent in ONE HTTP body. My understanding is Apollo originally pioneered this approach or at least popularized it. Graffle should eventually support this but not immediately unless there is major user requests. The new feature is being tracked at #1017. |
Perceived Problem
I was trying to delete multiple records at once but I noticed my "documents" are sent as queries
Ideas / Proposed Solution(s)
It'd be nice to let
batchRequests
work for mutations as well.For now, this is what I did
Thanks
The text was updated successfully, but these errors were encountered: