wasyl
05/22/2023, 11:20 AMFooQuery
fetches list of items [a, b, c]
(with `ID`s normalized, so the items have their own entries in the cache). If I manually remove an item from the cache (using apolloClient.apolloStore.remove(CacheKey(itemId), cascade = false)
), should I expect FooQuery
to
a) trigger refetcher
b) emit null
while b
is missing in the cache and re-emit non-null value only when b
is fetched, either by refetcher or some other query
?mbonnin
05/22/2023, 11:22 AMremove()
doesn't publish by default so you'd at least have to call publish(setOf(a, b, c))
publish()
, the refetcher will be called and try to fetch according to refetchPolicynull
or throws
depends a bunch of factors like the refetchThrows
parameter you've passed and/or whether you're on 3.x or 4.xwasyl
05/22/2023, 11:29 AMapolloClient.apolloStore.remove(CacheKey(contentId), cascade = false)
apolloClient.apolloStore.publish(setOf(contentId))
make sense or the publish
wouldn't do anything in such case?mbonnin
05/22/2023, 11:32 AMcascade
is false
that should be alright. But there's definitely a blind spot if cascade
is true
wasyl
05/22/2023, 11:32 AMmbonnin
05/22/2023, 11:33 AMwasyl
05/22/2023, 11:37 AMcascade=false
), and frankly I'd love to get rid of manipulating cache manually in the first place, only for reasons we can't do that. But the issue looks valid anyway, as the current behavior is just surprising because observing cache for the same query twice can yield different results (if you do observe — delete item — observe)