-
-
Notifications
You must be signed in to change notification settings - Fork 521
Description
Describe the bug
docs state this: onDone(handler): Event hook called when the mutation successfully completes.
But in some cases the onDone is called too early and the globalTracking of mutations fails (does not get reduced to 0).
For example, when the component, who triggered the mutation, gets refetched by onDone, then
useGlobalMutationLoading
and useMutationLoading
would be still in loading state and will never recover. App keeps "loading" even when the requests clearly ended in the network tab of the browser.
Several issues with this behaviour have been reported:
useMutationLoading
returnstrue
inonDone
hook #1387- onDone typing for data includes null | undefined #1317
- Invoking "useMutation" with onDone hook does not decrement global mutation loading #1484
To Reproduce
Steps to reproduce the behavior:
const { result, refetch } = useQuery(GETSOMETHING, variables)
const { mutate, onDone} = useMutation(UPDATESOMETHING, variables)
onDone(() => {
refetch()
})
Expected behavior
useGlobalMutationLoading()
and useMutationLoading()
should be already 0 when onDone gets called.
Versions
vue: 3.4.27
vue-apollo: 3.1.2
@apollo/client: 3.10.4