question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[3.0.0-beta.27] Querying data that is already in the cache sets loading to true

See original GitHub issue

This is a repeat of issue #5757 created by @od1k about this a few weeks back and marked as fixed in beta.23: unfortunately, it’s still reproing in beta.27.

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.

I’ve updated @od1k’s original repro to beta.27 and published it as a code sandbox here for easier debugging.

The repro code, in essence, first fetches all data in ALL_DATA_QUERY and then fetches a subset in CLOCK_SPEED_QUERY. The expected behavior is that the second query (triggered when the button is clicked) only renders once with loading: false, but it actually renders twice (see console log).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
BrendonSledcommented, Aug 4, 2020

When using {ssr:true} this issue is not fixed. The client is set to loading while the data is there.

3reactions
hwillsoncommented, Aug 3, 2020

I’ve verified this is no longer an issue with @apollo/client@3.1.2. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[3.0] Querying data that is already in the cache sets loading to ...
Click Show clock speed button. The app will crash and the Console will contain a log showing that loading is set to true...
Read more >
Reading and writing data to the cache - Apollo GraphQL Docs
You can read and write cache data using GraphQL queries that are similar (or even identical) to queries that you execute on your...
Read more >
React Query, Solid Query, Svelte Query, Vue Query - TanStack
Tell TanStack Query where to get your data and how fresh you need it to be and the rest is automatic. It handles...
Read more >
Changelog - UIkit
Fix error in console if image can't be loaded in Svg component with stroke-animation: true. Fixed. Fix scrollIntoView() no longer considers ...
Read more >
'loading' remains true when loading data with 'useQuery' using ...
Version 3.6 implements useQuery using useSyncExternalStore API from React 18. Since expo currently supports React 17 you can solve the issue ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found