apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.34k stars 2.66k forks source link

`useQuery`: `skip` does not stop polling. #11120

Open phryneas opened 1 year ago

phryneas commented 1 year ago

@phryneas I could narrow it a little bit down:

  • It seems that in my case the problem appears when combined with polling. In my case the 1st call should not skip but later ones should. It looks like the polling ignores the skip property.
  • It seems that this was introduced in 3.7.11. Below is a small repro. The logs and the network requests show that the requests are fired even though skip is true. When switching to 3.7.10, the requests are not fired.

https://codesandbox.io/s/skip-does-not-work-forked-sdr7d2?file=/src/App.js

Originally posted by @tobiaswaltl in https://github.com/apollographql/apollo-client/issues/6190#issuecomment-1630980185

Additionally, setting pollInterval to undefined doesn't seem to help:

As a workaround I tried to set the pollInterval to undefined when the condition for skip evaluates to true. But, like skip, this is ignored and the polling is continued. I.e. it seems it's nothing skip-specific causing this bug.

phryneas commented 9 months ago

Probably related: #9431

andreimatei commented 2 weeks ago

I have also run into both problems mentioned here:

  1. changing the value of skip does not have the intended effect
  2. changing the value of pollInterval to undefined does not have the intended effect (*)

Should we leave the two problems bundled together in this issue, or create a new one for the second?

(*) however, changing the value of pollInterval to a really large number does work