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

[3.0] Querying data that is already in the cache sets loading to true #5757

Closed
olgertse opened this issue Jan 6, 2020 · 1 comment
Closed

Comments

@olgertse
Copy link

olgertse commented Jan 6, 2020

We pre-cache a lot of data in our app so that switching between different screens can be instantaneous - without flickering and loading states.

Intended outcome:
When running some query:

  const {
    loading,
    data
  } = useQuery(SOME_QUERY);

we expect that loading will be false if data is already in the cache (with default or cache-only fetchPolicy).

Actual outcome:
loading is true even when the requested data is in the cache.

I cannot tell if this is expected behaviour or not but it is definitely different from Apollo Client 2.6.

How to reproduce the issue:
I've created a reproduction that demonstrates this issue https://github.com/od1k/apollo-client-issue-1.

master branch contains a reference implementation with Apollo Client 2.6 which works as expected.
Branch 3.0 is updated to use Apollo Client 3 and exhibits the aforementioned behaviour.

Checkout branch 3.0, start the app, verify that the data is in the cache using Apollo DevTools.
Click Show clock speed button. The app will crash and the Console will contain a log showing that loading is set to true.

Verify that the app works as expected with Apollo Client 2.6 by checking out the master branch and repeating the procedure.

Versions

  System:
    OS: macOS 10.15.1
  Binaries:
    Node: 11.10.1 - /usr/local/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  Browsers:
    Chrome: 79.0.3945.88
    Firefox: 59.0.1
    Safari: 13.0.3
  npmPackages:
    @apollo/client: ^3.0.0-beta.19 => 3.0.0-beta.19 
@benjamn
Copy link
Member

benjamn commented Jan 17, 2020

This appears to be fixed in the latest version, @apollo/[email protected], likely due to #5791. Please feel free to reopen if the problem persists, and thanks for the reproduction!

@benjamn benjamn closed this as completed Jan 17, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants