Replies: 1 comment 6 replies
-
oh that's interesting. yeah we don't offer something to continue non-paused mutations out of the box, but your code should work fine. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We're working on a react native app in combination with react query that follows the offline first approach. In our app we have the use case of a long running mutation. If a user starts this mutation and kills the app from the background before the mutation was successful we would still want to resume this mutation as soon as the user reopens the app.
In the point in time when the user kills the app the mutation is in the following state:
Since the
defaultShouldDehydrateMutation
function makes sure that only paused mutations are being persisted our mutation would get ignored.In order to persist it anyways we customized the
shouldDehydrateMutation
of the PersistQueryClientProvider:(m: Mutation) => defaultShouldDehydrateMutation(m) || m.state.status === 'pending'
When reopening the app, the mutation will get hydrated but it won't continue it's mutationFn.
Do you think this should be handled by react query internally or do you see this case as too specific so that we'd need to call continue on them again manually in the onSuccess handler of the PersistQueryClientProvider?
Beta Was this translation helpful? Give feedback.
All reactions