Skip to content

Paused query fired twice on variable update #219

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
arkandias opened this issue Mar 19, 2025 · 0 comments
Open

Paused query fired twice on variable update #219

arkandias opened this issue Mar 19, 2025 · 0 comments

Comments

@arkandias
Copy link

Hi! Thank you for your work on Villus. I made the switch recently and I'm delighted!

I just noticed that if I have a paused query, with a reactive pause depending on a reactive variable, like

const count = ref(0);

const GetTodos = `
  GetTodos ($count: Int!) {
    todos {
      id
      title
    }
  }
`;

const { data } = useQuery({
  query: GetTodos,
  variables: ref({ count }),
  paused: () => count.value === 0,
});

then when the value of the variable is update so that paused.value becomes false, the query is fired twice (I guess the update of variables and of paused both trigger a refetch, or there might be some race condition). This also happens using paused: ({ count }) => count === 0.

Here is a MWE (click on the button and check the console logs): https://stackblitz.com/edit/vitejs-vite-xejziegs?file=src%2Fcomponents%2FHelloWorld.vue

I do not know if this behavior is expected (it is not a big deal in my case, because the second fetch uses the cache).

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

No branches or pull requests

1 participant