You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using a lazy query with caching. I need to know when the query is complete whether it used the network or the cache.
Here is the basics of the code, which uses cache-first network policy
//manually track loading stateconst[isLoading,setIsLoading]=useState(false)const[loadQuery,{ data, error, loading }]=useLoanListLazyQuery({onCompleted: data=>{//when the query is done, turn off manual loading statesetIsLoading(false)},})//when the input changesuseEffect(()=>{//load the data using the queryloadQuery({variables: { queryTrigger }})//manually turn on loading statesetIsLoading(true)},[queryTrigger])
a. Note that loading is no longer changed when retrieving from the cache.
b. The manual isLoading state is still being set correctly.
c. Everything up until this point is ok.
Set Count = 3 (backspace to clear the existing 3, then type 3 again)
loadQuery: 3
IsLoading: true
a. Notice the query is called, the data still displays, but the onCompleted is never called.
b. This feels like a bug to me. I would expect the same output as Step 3.
c. This sample is using 3.5.0-beta12. 3.4.11 shows something different... Step 4 results actually happen in Step 3.
c. Notably, this prevents me from accurately tracking start and end states for the data load.
Does anyone have a good idea on how to reliably know if the data is done being accessed from the cache after a lazy load?
As an addendum, due to other parts of my UI, I do need this loading true->false mechanism, so just displaying the cached data without knowing the start and end state is not an option for me.
The text was updated successfully, but these errors were encountered:
My workaround is to track the previous query in my code to see if it is the same as the new query and if it is, I do not call loadQuery. This works ok, but I do not like it. Even if I didn't need to, I did request a load and if I do, I should be told it is finished.
I am using a lazy query with caching. I need to know when the query is complete whether it used the network or the cache.
Here is the basics of the code, which uses
cache-first
network policyA working repro of my issue explained below:
https://codesandbox.io/s/apollo-client-beta-fetchmore-bug-forked-k5bip
Steps:
Does anyone have a good idea on how to reliably know if the data is done being accessed from the cache after a lazy load?
As an addendum, due to other parts of my UI, I do need this loading true->false mechanism, so just displaying the cached data without knowing the start and end state is not an option for me.
The text was updated successfully, but these errors were encountered: