`refetch` promise with `fetchPolicy` 'cache-and-network' immediately resolves
See original GitHub issueIntended outcome:
Calling refetch()
on a query result that has fetchPolicy: 'cache-and-network'
should return a promise that resolves once the request to the network has completed.
Actual outcome:
The promise resolves immediately, while the request to the network is still fired.
How to reproduce the issue:
Call refetch
on a query with cache-and-network
fetch policy and compare when the promise resolves and when the network request comes back.
I guess this happens because of these lines: https://github.com/apollographql/apollo-client/blob/c00252f2d923d23285b76a24a2b5c151f9e87b96/packages/apollo-client/src/core/QueryManager.ts#L440-L444
However even for the cache-first
fetch policy, the promise resolves after a network roundtrip:
Would you be open to a PR that fixes this?
Versions
System:
OS: macOS Mojave 10.14.6
Binaries:
Node: 12.3.1 - /usr/local/bin/node
Yarn: 1.19.1 - ~/.yarn/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Browsers:
Chrome: 78.0.3904.97
Firefox: 69.0.3
Safari: 13.0.3
npmPackages:
@apollo/react-testing: ^3.1.3 => 3.1.3
apollo-cache-inmemory: 1.6.3 => 1.6.3
apollo-client: 2.6.4 => 2.6.4
apollo-link: 1.2.13 => 1.2.13
apollo-link-error: 1.1.12 => 1.1.12
apollo-link-http: 1.5.16 => 1.5.16
apollo-link-token-refresh: 0.2.7 => 0.2.7
react-apollo: ^3.1.3 => 3.1.3
react-apollo-network-status: 3.0.0 => 3.0.0
npmGlobalPackages:
apollo-client: 2.5.1
react-apollo: 3.1.3
Issue Analytics
- State:
- Created 4 years ago
- Reactions:16
- Comments:15 (6 by maintainers)
Top GitHub Comments
@hwillson this is still a problem
@hsavit1 We’re doing a little spring cleaning because a lot of issues refer to old versions and are slightly outdated. I’ll make sure to look into this.