Stylianos Gakis
05/17/2022, 1:41 PMCacheOnly
refetchPolicy instead CACHE_FIRST
. To keep behavior unchanged, set a refetchPolicy
on your watchers:”
But the snippet directly under it shows subscribe
instead of watch()
. Is this wrong in the sense that it should be .watch()
instead, or should the title of the section be subscriptions
? I am kinda confused at that part of the document.mbonnin
05/17/2022, 6:32 PM.query(query).watch()
...
Fix there: https://github.com/apollographql/apollo-kotlin/pull/4118/filesStylianos Gakis
05/18/2022, 6:31 AMwatch
just do nothing?mbonnin
05/18/2022, 6:58 AMLooking at the code, watch internally does a toFlow() and then emits the response directly.That's for the initial response only. If you follow the code, you'll see another lower level
watch
that watches for changed keys in the store
if we had not configured any cache (http or normalized) would aIt would return thejust do nothing?watch
NetworkOnly
response once and that's it.And only after that it does the copy() with the cache_only policy.Ah, sorry I missed that part. There are 2 things:
fetchPolicy
and refetchPolicy
refetchPolicy
is CacheOnly by default Stylianos Gakis
05/18/2022, 7:03 AMmbonnin
05/18/2022, 7:03 AMStylianos Gakis
05/18/2022, 7:05 AMmbonnin
05/18/2022, 7:07 AMStylianos Gakis
05/18/2022, 7:15 AMdata: D?
used in that function? Just looking at the function signature I assume you pass what the first emission of watch will return, and from then on it will return all cache changes, but I am not sure.
And as a side note, In all the times I had to use a watch myself, I did in fact want the behavior of fetch once, and listen after, but I imagine there are other use-cases that don’t have the same requirements. But we’re not relying super much on caching in general, so there’s that.mbonnin
05/18/2022, 7:41 AMdata
is used to get the initial set of keys to watch for