Open viico opened 2 weeks ago
As far as I understand it, standby
was added at some point to enable the skip
use case of useQuery
, but no additional networkStatus
was added for it - instead, the networkStatus
with "no data and no error" was used for it - loading.
The React hooks work around that outside the core as you can see here: https://github.com/apollographql/apollo-client/blob/4115129ea88262740ee5fa5628d91f1e51c80fee/src/react/hooks/useQuery.ts#L817-L823
This is something that - while confusing - could break a lot of apps if we were to change it. I'll bring it up internally, but short-term I have little hope that we can change it.
Your best bet is probably to work around it in a similar fashion for now.
Issue Description
We want to use the
standby
fetch policy to call our API only when we use refetch.The problem is that the
loading
field ofApolloQueryResult
is true before any HTTP call. The issue was discussed here : #7564, but the solution is to useuseLazyQuery
which is not available forapollo-angular
.I don't understand why the field loading is initialized to true if there is no loading yet ?
Link to Reproduction
https://github.com/viico/apollo-fetch-policy-standby-loading
Reproduction Steps
We create a repo for reproduction here : https://github.com/viico/apollo-fetch-policy-standby-loading.
When you start the angular application you will see that there is no HTTP request before we refetch (that's ok) but the loading field is true anyway.
@apollo/client
version3.0.0