After refetch fails, successful fetchMore sends updateQuery undefined previousResults
See original GitHub issueIntended outcome:
After server downtime, during which a call to refetch
fails, I would expect future successful queries using fetchMore
to call the updateQuery
function with previousResults
from before the downtime.
Actual outcome:
After failed calls to refetch
, successful calls to fetchMore
call the updateQuery
function with a first argument (previousResults
) value of undefined
. At that point, there is no way to use the existing results.
A log looks something like this:
Server online, screen loading
Component rendering with data: {loading: true, networkStatus: 1, error: undefined}
Component rendering with data: {names: ["a", "b", "c", "d", "e"], loading: false, networkStatus: 7, error: undefined}
Server going offline
Attempting to sort (using `refetch` with variables as a promise)
Component rendering with data: {names: ["a", "b", "c", "d", "e"], loading: true, networkStatus: 2, error: undefined}
Component rendering with data: {names: ["a", "b", "c", "d", "e"], loading: false, networkStatus: 7, error: "Error: GraphQL error: ..."}
Sort failed
Server going online
Attempting to paginate
fetchMore's updateQuery method called with previousResults: undefined
How to reproduce the issue:
Set up a repo that uses both refetch
for sorting and fetchMore
for pagination.
- Load the initial results successfully
- Go offline
- Try sorting the results (which should fail)
- Go online
- Try paginating
The
updateQuery
method is called with a first argument,previousResults
, ofundefined
.
I’ve created a branch to demonstrate the behavior: https://github.com/treyp/react-apollo-error-template/tree/previousresults-undefined
This can also be found on CodeSandbox: https://codesandbox.io/s/github/treyp/react-apollo-error-template/tree/previousresults-undefined
Follow the steps above, just like the screen recording here, to reproduce.
Versions
System:
OS: macOS 10.14.6
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
npm: 6.10.3 - ~/.nvm/versions/node/v10.15.3/bin/npm
Browsers:
Chrome: 76.0.3809.100
Safari: 12.1.2
npmPackages:
apollo-cache-inmemory: ^1.6.3 => 1.6.3
apollo-client: ^2.6.4 => 2.6.4
apollo-link-batch-http: ^1.2.12 => 1.2.12
react-apollo: ^3.0.0 => 3.0.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:12 (2 by maintainers)
i have the same issue, that fetchMore is for some queries very buggy.
when I fetch more directly it’s undefined. after ignoring this and run refetch the and then fetchMore/updateQuery it works fine. 🧐
Can someone confirm if this is still an issue with
@apollo/client@latest
? I’ll close this for now, but happy to re-open if this is still happening. Thanks!