Make A Mutation Call Multiple Times Depending On Length Of Variable
Is there a way for me to call a mutation multiple times from the front-end? I have an array of users I need to add to an app and the mutation currently only allows to add one user
Solution 1:
The Mutation
component, the useMutation
hook and the graphql
HOC all give you a method that can be used as many times as you like.
const [share] = useMutation(SHARE_APP)
awaitPromise.all(appIds.map((appId) =>share({
variables: {
userId,
appId,
},
})))
As far as batching these requests, Apollo does not support that out of the box so you would have to use a link like apollo-link-batch-http.
Post a Comment for "Make A Mutation Call Multiple Times Depending On Length Of Variable"