-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
useQuery
with network-only
fetch policy renders data from cache when notifyOnNetworkStatusChange
is true
#12229
Comments
No dupes found! |
Hey @levrik 👋 I would agree that I would expect that That was released 3 years ago so at this point it has the potential to be of a spicier change. We will likely target a fix for this in the next minor so we can call this out a bit more prominently. In the mean time, I've opened #12230 which contains a failing test. Would you mind looking at the test I've written to make sure it adequately demonstrates the behavior you'd expect if this were fixed? |
@jerelmiller Failing test case looks like I would expect it to behave. Please let me know if there's a fix available in a PR. I would add this as a local patch to the latest stable release in my project then so I don't have to wait on a formal release. |
Unfortunately it looks like this might be a bit more complicated than meets the eye. I've got a patch in mind, but when trying it out, it breaks some I'm going to take this issue to our team meeting on Wednesday to discuss what we'd like to do here and how |
@jerelmiller No problem. Take your time! |
@jerelmiller Any updates on this? |
@levrik no updates on this specific issue. I have been working to refactor our tests over the last week or two to more accurately check the emitted values from both our core API and our hooks to really help identify areas where we have these types of inconsistencies. We will be addressing most if not all of these inconsistencies in v4 so I'm tagging this issue with the v4 milestone. This should give us the ability to break anything necessary to make this work. |
Issue Description
When using
useQuery
with fetch policynetwork-only
andnotifyOnNetworkStatusChange
set totrue
, it behaves likenetwork-and-cache
, returning data from cache instead of ignoring the cache.I'm using
notifyOnNetworkStatusChange
to get a re-render when recovering from an errored error by callingrefetch
so this is rather annoying that it breaks thenetwork-only
fetch policy for successful fetches.Link to Reproduction
https://codesandbox.io/p/devbox/still-bash-52hmpn
Reproduction Steps
Without
notifyOnNetworkStatusChange
:specific
It flashes
No Data
all
It flashes
No Data
With
notifyOnNetworkStatusChange
:specific
It flashes
No Data
all
No flash of
No Data
, instead renders data from cache@apollo/client
version3.12.3
The text was updated successfully, but these errors were encountered: