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

Fix issue where no-cache fetch policy causes empty query results #3777

Merged
merged 3 commits into from
Aug 3, 2018

Conversation

hwillson
Copy link
Member

@hwillson hwillson commented Aug 3, 2018

When QueryManager.getCurrentQueryResult is called, it first tries to get the current data from a newData property stored alongside a previously created query (using getQuery). If data can't be found, it then tries to load data from the cache. When a no-cache fetch policy is used however, the newData property is being improperly removed before getCurrentQueryResult has a chance to get it. Then when it tries to fallback on loading data from the cache, it finds no matching data, since the no-cache fetch policy means the cache isn't being used.

This commit adjusts QueryManager.queryListenerForObserver such that is doesn't remove the newData that is stored with a query, if a no-cache fetch policy is being used. This allows QueryManager.getCurrentQueryResult to return the loaded no-cache data.

Related to the following issue comments:
#3256 (comment)
#3452 (comment)

P.S. > This PR also includes a few test file CRLF to LF conversions, so please ignore the crazy diffs.

When `QueryManager.getCurrentQueryResult` is called, it first
tries to get the current data from a `newData` property stored
alongside a previously created query (using `getQuery`). If data
can't be found, it then tries to load data from the cache. When a
`no-cache` fetch policy is used however, the `newData` property is
being improperly removed before `getCurrentQueryResult` has a chance
to get it. Then when it tries to fallback on loading data from the
cache, it finds no matching data, since the `no-cache` fetch policy
means the cache isn't being used.

This commit adjusts `QueryManager.queryListenerForObserver` such
that is doesn't remove the `newData` that is stored with a query,
if a `no-cache` fetch policy is being used. This allows
`QueryManager.getCurrentQueryResult` to return the loaded
`no-cache` data.
@apollo-cla
Copy link

apollo-cla commented Aug 3, 2018

Warnings
⚠️

❗ Big PR

Generated by 🚫 dangerJS

@hwillson hwillson merged commit 4d7b3ea into master Aug 3, 2018
@hwillson hwillson deleted the hwillson/default-options-fix branch August 3, 2018 17:08
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants