-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Documentation on cache-and-network fetchPolicy is unclear #8123
Comments
@insidewhy You might find this comment useful regarding what You can think of As I'm typing this explanation, I'm reminded of a potential complicating factor, which is that the original |
This aligns with what we expected, i.e.
... but then after reading this next paragraph, I'm confused again :D Are you describing a potential bug here? Also, do you think it's worth updating the documentation? |
@benjamn Also when I read the comment you linked to, I see that the |
I'm referring to this documentation https://www.apollographql.com/docs/react/data/queries/#cache-and-network
We've had a discussion among our whole team and none of us can work out what the intention of this is. It's especially confusing since our tests seem to act differently with respect to this option since upgrading to apollo client 3. We decided it has to be one of the following:
With apollo client 3, it seems that on every render we get a network request sent
(1)
, with apollo 2, it seems, we only get the network request sent on the first render after a mount(2)
. BTW these behaviors we noticed when using the mocked provider.So we aren't sure when the network requests are supposed to be triggered.
Following on from this, we aren't sure when
nextFetchPolicy
triggers. Is this on subsequent renders after the first mount? Or does this "next" policy get remembered across re-renders and thusfetchPolicy
only applies once until the entire app is reloaded?In our testing with apollo client 3, when we set
fetchPolicy
tocache-and-network
andnextFetchPolicy
tocache-first
we seem to get the "hit network once after hook is first mounted, then use the cache on rerenders"(2)
behavior.At any rate, if ten developers on our team who've been using apollo client extensively for many years can't work out the semantics from the documentation, I think it's likely that the documentation could do with some more details.
The text was updated successfully, but these errors were encountered: