Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useMutations onDone Event hook gets triggered too early #1558

Open
mobsean opened this issue Jun 7, 2024 · 0 comments · May be fixed by #1559
Open

useMutations onDone Event hook gets triggered too early #1558

mobsean opened this issue Jun 7, 2024 · 0 comments · May be fixed by #1559

Comments

@mobsean
Copy link
Contributor

mobsean commented Jun 7, 2024

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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant