Calling refetch fires off a network request when skip is true
See original GitHub issueCalling refetch
ignores the skip: true
option for the query hook. The full config of the query hook is:
fetchPolicy: "cache-and-network",
nextFetchPolicy: "cache-first",
notifyOnNetworkStatusChange: true,
variables: { ... },
skip: true
Intended outcome:
Calling refetch
when skip
is true
should not produce a network request.
Actual outcome:
Calling refetch
when skip
is true
produces a network request. While the request is in flight the loading state is false, when the data is fetched it’s not rendered (not passed to the data prop). The reason why skip is true in this case is lack of certain variables, that would filter a large data set. There’s a button on the page that can “refresh” the data, which calls the refetch
function. Previously (on v3.1.3) refetch was throwing an error, instead of firing off a network request (which was also a bad behavior and was something that we handled in a weird way). It would be nice if it can just respect the skip
property and not do anything if it’s true
.
Versions
npmPackages: @apollo/client: ^3.3.19 => 3.3.19
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:8 (3 by maintainers)
Top GitHub Comments
This is exactly what I’m doing at the moment. That said, the current behavior is clearly broken even if we ignore the fact that it fires off a network request when skip is true (the data is never received by the hook even though a request was in flight and has completed). Plus the behavior was different in the previous minor version (it threw an error instead of firing off a request)…
What’s the point of versioning if things aren’t getting fixed because someone might rely on a non-sensical/buggy behavior?
@brainkim @hwillson Is there not a difference between
skip
and thestandby
fetchPolicy? I tend to think that if skip is true, requests are all skipped, but if it is in standby, the user can still manually update the cache or refetch Either this or the documentation needs updating 😃Uses the same logic as cache-first, except this query does not automatically update when underlying field values change. You can still manually update this query with refetch and updateQueries.