loading flag should be true on initial network request of cache-first policy
See original GitHub issueIntended outcome:
Using the default ‘cache-first’ fetchPolicy, the client will need to load data from the network since the cache is empty initially. In order to display loading indicators, I need to be able to distinguish a network response from a cache response via the loading
flag.
Actual outcome:
All responses using the cache-first
policy have loading
set to false. Hence no distinction is possible.
How to reproduce the issue: Create a query with ‘cache-first’ fetchPolicy and inspect the loading prop of the response object.
Version
- apollo-client@1.2.2
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Local state management - Apollo GraphQL Docs
Ideally, we would like the Apollo cache to be the single source of truth for all data ... You can even request local...
Read more >React Apollo: Understanding Fetch Policy with useQuery
I googled for that and I got to know that apollo client uses cache-first as a default fetch policy. I changed the fetch...
Read more >Interfaces: ApolloQuery - Apollo Elements
If data was read from the cache with missing fields, partial will be true. ... Set to prevent subsequent network requests when the...
Read more >Cache asset via freshness in Angular 6 Service Worker
Having this service worker flag, Angular CLI 1.6 will do some automation ... For network-first strategy, it's freshness , for cache-first ...
Read more >workbox-strategies - Chrome Developers
An implementation of a cache-first request strategy. ... If the network request fails, and there is no cache match, this will throw a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having exactly the same issue on 2.4.2 and could only get it to work using
cache-and-network
too.The docs at https://www.apollographql.com/docs/angular/basics/queries.html#basics state “The observable will only emit once when the query is complete, and loading will be set to false unless you set the watchQuery parameters notifyOnNetworkStatusChange or returnPartialData to true.”, but I’ve found that even when setting
notifyOnNetworkStatusChange
to true, it does not. Also, the propertyreturnPartialData
doesn’t exist. Using apollo-client 2.4.2. SettingfetchPolicy
tocache-and-network
made it work. But as this issue states, it should now. 😕