Replies: 1 comment
-
So with invalidation, it should be enough to check if any other mutation is currently running before you perform the update? So:
note that inside of With manual cache updates however, it’s more tricky because you can’t know if the data you’re getting is the latest. If you have concurrent mutations for the same key, then yes, you have to check
We also expose a |
Beta Was this translation helpful? Give feedback.
-
I have a highly reactive use case for mutations, where I want to make the optimistic update and also update cache with mutation response, exactly like in documentation.
My problem is, that mutations happen too fast, and quite often the response from the first mutation overwrites optimistic updates from the second mutation.
I'm looking for a way to conditionally update the cache from mutation response, only if no newer mutations exist with the same mutation key.
I ended up for now with this solution:
But it depends on mutation.submittedAt, which I'm not sure how works with multiple mutations from the same hook call. And also I feel like I'm reinventing the wheel. So probably I don't see a better, more straightforward and declarative solution
Beta Was this translation helpful? Give feedback.
All reactions