Skip to content

useMutations onDone Event hook gets triggered too early #1558

@mobsean

Description

@mobsean

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions