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

Inconsistent results with cache-only between useLazyQuery and client.query #10236

Open
leepowelldev opened this issue Oct 27, 2022 · 0 comments

Comments

@leepowelldev
Copy link

leepowelldev commented Oct 27, 2022

Intended outcome:
Usage of useLazyQuery (and likely useQuery) and client.query differ in the results given to fetching a query with fetchPolicy set to cache-only and the cached record missing fields. According to the docs it should throw an error - this doesn't happen, and different data is returned depending on which implementation is used.

I would expect to be given an error if a complete query could not be returned from cache - and consistent behaviour on whether to return a partial query or undefined for data.

Actual outcome:

useLazyQuery - returns undefined for data and undefined for error.
client.query - returns partial data query and undefined for error.

The lack of errors here can mean silent bugs creeping into applications.

How to reproduce the issue:

https://github.com/leepowelldev/apollo-client-bug

Versions

System:
OS: macOS 12.6
Binaries:
Node: 18.10.0 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.19.2 - /usr/local/bin/npm
Browsers:
Chrome: 106.0.5249.119
Edge: 106.0.1370.52
Firefox: 106.0.2
Safari: 16.0
npmPackages:
@apollo/client: ^3.7.1 => 3.7.1

Update: Adding returnPartialData: true to the hook allows it to remain consistent with the result returned from client.query however, when adding returnPartialData: false to client.query seems to make no difference and it still returns partial data. And oddly if I set returunPartialData: true to client.query I get a Invariant Violation: returnPartialData option only supported on watchQuery error - when according to the docs it should be possible to set

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

No branches or pull requests

2 participants