Skip to content
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

network-only fetchPolicy delivers empty data when loading #6941

Open
kliakos opened this issue Aug 30, 2020 · 4 comments
Open

network-only fetchPolicy delivers empty data when loading #6941

kliakos opened this issue Aug 30, 2020 · 4 comments

Comments

@kliakos
Copy link

kliakos commented Aug 30, 2020

The behavior changed after 3.1.0 release.

Previously, when data was defined, it was guaranteed that a complete result was included in the object. This was I only had to check if data was defined. Now, with fetchPolicy network-only, after the initial search and while the second search is in-flight, I am getting an empty object from data.

Possibly has to do with #6710

@stoically
Copy link
Contributor

Hitting this issue as well, while trying to get a minimal reproduction case it seems that only the combination of

      notifyOnNetworkStatusChange: true,
      fetchPolicy: "network-only",

is affected.

Minimal repo: https://github.com/stoically/apollo-empty-data-object
Simple, probably hackish, fix: stoically@e6088e5

@kliakos
Copy link
Author

kliakos commented Dec 12, 2020

fetchPolicy: 'no-cache' also has the same issue.

@longzheng
Copy link

Just bumping this issue because this issue leads some Cannot read property 'success' of undefined exceptions when using optional chaining data?..

@ShannonLCapper
Copy link

ShannonLCapper commented Oct 22, 2021

FWIW, I'm not seeing this crash anymore on the latest @apollo/client version 3.4.16 (but could easily reproduce it via the combo of fetchPolicy: 'network-only' + notifyOnNetworkStatusChange: true on version 3.3.14)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants