wasyl
10/18/2023, 8:37 AMmbonnin
10/18/2023, 8:41 AMMap<String, Any>
. These Record
s are then read with MapJsonReader
which exposes them through a JSON API but under the hood it's not serialized to utf8wasyl
10/18/2023, 8:45 AMmbonnin
10/18/2023, 8:48 AMwasyl
10/18/2023, 8:49 AMwatch
callswatch
call in Apollo for a given Query<Query.Data>
, I want to attach to a SharedFlow
that I'd manage, backed by apollo's watchmbonnin
10/18/2023, 8:51 AMwasyl
10/18/2023, 8:52 AMmbonnin
10/18/2023, 8:52 AMshareIn
?wasyl
10/18/2023, 8:52 AMval query = SomeQuery
val foo = apollo.watch(SomeQuery)
apolloStore.remove(deeplyNestedIdOfObjectInSomeQueryResponse)
val bar = apollo.watch(SomeQuery)
// foo.value = some response
// bar.value = null
mbonnin
10/18/2023, 8:54 AMwasyl
10/18/2023, 8:55 AMwatch
(bar
) will try to read from cache, realize it can't satisfy all objects, return null
The existing watch
(foo
) will not be notified of the deeply nested object removal because remove
doesn't publish cache changes for SomeQuery
watch
anymore, so the app behavior changedmbonnin
10/18/2023, 8:56 AMwasyl
10/18/2023, 8:58 AMmbonnin
10/18/2023, 9:00 AMwasyl
10/18/2023, 9:01 AMmbonnin
10/18/2023, 9:01 AMwasyl
10/18/2023, 9:02 AMHow does SQL do it?Seems like it doesn't https://stackoverflow.com/a/24713124
mbonnin
10/18/2023, 9:27 AMwasyl
10/18/2023, 9:29 AMor passing a list of affected queries that need to be refetched from the networkthat crossed my mind as a workaround, I realized it may not be reasonable to expect Apollo to determine all places to invalidate
SharedFlow
-like cache would be out of scope for Apollo itself?mbonnin
10/18/2023, 9:41 AMApolloStore.refetchAllWatchers()
or sowasyl
10/18/2023, 9:43 AMApolloStore.publish(rootKey)
?mbonnin
10/18/2023, 9:43 AMwasyl
10/18/2023, 9:47 AMrefetchAllWatchers
-like functionality)
About
I'm not sure what that would look likesame, just wanted to check it's not on the roadmap somewhere
mbonnin
10/18/2023, 9:48 AMApolloStore.publish(rootKey)
won't work. The watchers only listen to scalar (leaf) fields, not object fields. Typically in the root key case, we don't want to get notified every time a new query queries a new root field
• The web has also a garbage collector. From what I understand, this works by scanning the whole cache. If we can make it fast enough, that could maybe work. Trigger a GC and notify all dependents.
• Another approach is to have every mutation return the modified objects (but requires care when writing the mutation as well as backend support)wasyl
10/18/2023, 2:09 PMor passing a list of affected queries that need to be refetched from the networkbut realized I don't know what I can pass to
publish
even if I know the query that should be affected 😕 And I don't really want to refetch from network at this point, just make Apollo emit null
for currently observed queriesmbonnin
10/18/2023, 2:15 PMI don't know what I can pass toLooks like we need to keep track of query names that have an active watcher. Then you could call something likeeven if I know the query that should be affectedpublish
apolloStore.invalidate("GetProduct")