[3.0.0-beta.27] Querying data that is already in the cache sets loading to true
See original GitHub issueThis 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:
- Created 4 years ago
- Reactions:11
- Comments:11 (2 by maintainers)
Top GitHub Comments
When using
{ssr:true}
this issue is not fixed. The client is set to loading while the data is there.I’ve verified this is no longer an issue with
@apollo/client@3.1.2
. Thanks!