Skip to content

[3.13.1] Refetch handler stop being executed on refresh #12440

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

Open
jrg091 opened this issue Mar 14, 2025 · 2 comments
Open

[3.13.1] Refetch handler stop being executed on refresh #12440

jrg091 opened this issue Mar 14, 2025 · 2 comments

Comments

@jrg091
Copy link

jrg091 commented Mar 14, 2025

Issue Description

In our component we have the following mutation with a refetch option set for a previously executed query.

const [result, { loading: loadingResult }] =
  useSyncDataMutation({
    awaitRefetchQueries: true,
    onError: (error: ApolloError) => {
      // Log and show messages
    },
    onCompleted: (data) => {
      // Show some messages   
    },
    refetchQueries: [CHANGELIST_QUERY],
  });

const { data, loading, error } = useQueryJustChangelistQuery({
  fetchPolicy: "cache-and-network",
  variables: {
    id: changelistId,
  },
  onCompleted: (data) => {
    console.log("WORKING");
  },
});

The useSyncDataMutation is executed in a button handler and in 3.13.0 and previous versions, the onCompleted from useQueryJustChangelistQuery was executed with the new data. Starting from 3.13.1 I see the request to the server being made but the handler is not being executed.

Note: I'll try to create a codesandbox and I'll update this description

Link to Reproduction

WIP

Reproduction Steps

No response

@apollo/client version

3.13.1

@jerelmiller
Copy link
Member

jerelmiller commented Mar 14, 2025

Hey @jrg091 👋

A reproduction would be great. The only change I see 3.13.1 that could possibly be related is #12369 which uses a network-only fetch policy for refetches if the fetch policy is cache-and-network (previously it would refetch with a cache-and-network fetch policy).

This shouldn't affect anything in regards to onCompleted though so this is a bit odd. By chance, do you see the same issue if you switch your fetch policy to network-only in 3.13.0 and/or 3.13.1?

@jrg091
Copy link
Author

jrg091 commented Mar 14, 2025

Hey @jerelmiller ! Thanks for your quick response!

I tested several values for the fetch policy, including network-only and it didn't worked.
Regarding the reproduction I'm still working on it I'll update the original message and add a new comment with it once I finish it

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

No branches or pull requests

2 participants