Replies: 2 comments 4 replies
-
You can define which mutations to persist, and there, you can decide to deduplicate mutations that you think are the same. |
Beta Was this translation helpful? Give feedback.
-
@TkDodo I understand the problem of mutationFn serialization, but because of the default mutation function being with one common key has it own limitations
this kinda limits the way how we identify mutations for each item. We lose the ability to deduplicate multiple EDIT requests which are not idempotent. Even if mutation guarantees that proper sequence of events, still i think this is not correct behaviour in my case. It could update duplicate EDIT requests by our ID that we set(mutation Key or some other type of ID). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
Is it possible to deduplicate identical mutations? Or a workaround? I saw that the
mutationCache
has a.remove()
method, but I cannot really see this documented anywhere.Context: We are creating a PWA with a form. The form can be edited offline, and the same cell can be changed after initial change. One request is typically sent after a field is blurred, so that change is stored on the server asap. Thus identical mutations will be created (and stored using
PersistQueryClientProvider
). Once the user goes online again, all these requests are sent. They are sent in order, so the data ends up being correct (unless user loses connection between mutations). However all the different values of the mutation is sent to the server, which is unnecessary when I'm just interested in the value/effect of the last mutation.TLDR:
I would like only the last mutation to be stored in the cache. So if a new mutation with a key that is identical to one already in the cache, I want to replace that mutation with the new one.
Update:
I've managed to implement this, but maybe there's a better way?
Beta Was this translation helpful? Give feedback.
All reactions