Hey, many thanks for this library!
I ran into an issue when trying to trigger multiple mutations in parallel with different variables.
Here's an example of what I mean:
const [mutate] = createMutation(MUTATION);
const res = await Promise.all([
mutate({ variables: { id: "1" } }),
mutate({ variables: { id: "2" } }),
]);
The Promise.all does not get resolved, because only the last mutation promise is resolved.
I also reproduced the issue here: https://codesandbox.io/s/misty-snow-6fhw59?file=/src/App.jsx
I see here https://github.com/merged-js/solid-apollo/blob/main/src/createMutation.ts#L64 that resolveResultPromise is overwritten any time the mutate function is called.
I'm not sure what a good approach would be to fix this. Maybe the resolve and reject promises kept track of could instead be arrays so that each new call to mutate would add its own promises to the arrays and then remember the index of the call?
I wouldn't mind trying to set up a PR, but I'm not quite sure what the best approach would be to resolve the issue since the returned resource still needs to keep working somehow.
What do you think?
Hey, many thanks for this library!
I ran into an issue when trying to trigger multiple mutations in parallel with different variables.
Here's an example of what I mean:
The
Promise.alldoes not get resolved, because only the last mutation promise is resolved.I also reproduced the issue here: https://codesandbox.io/s/misty-snow-6fhw59?file=/src/App.jsx
I see here https://github.com/merged-js/solid-apollo/blob/main/src/createMutation.ts#L64 that
resolveResultPromiseis overwritten any time themutatefunction is called.I'm not sure what a good approach would be to fix this. Maybe the resolve and reject promises kept track of could instead be arrays so that each new call to
mutatewould add its own promises to the arrays and then remember the index of the call?I wouldn't mind trying to set up a PR, but I'm not quite sure what the best approach would be to resolve the issue since the returned
resourcestill needs to keep working somehow.What do you think?