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 utf8mbonnin
10/18/2023, 8:42 AMwasyl
10/18/2023, 8:45 AMmbonnin
10/18/2023, 8:48 AMwasyl
10/18/2023, 8:49 AMwatch callswasyl
10/18/2023, 8:50 AMwatch 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 AMwasyl
10/18/2023, 8:53 AMval query = SomeQuery
val foo = apollo.watch(SomeQuery)
apolloStore.remove(deeplyNestedIdOfObjectInSomeQueryResponse)
val bar = apollo.watch(SomeQuery)
// foo.value = some response
// bar.value = nullmbonnin
10/18/2023, 8:54 AMwasyl
10/18/2023, 8:55 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 SomeQuerywasyl
10/18/2023, 8:56 AMwatch anymore, so the app behavior changedmbonnin
10/18/2023, 8:56 AMmbonnin
10/18/2023, 8:58 AMwasyl
10/18/2023, 8:58 AMwasyl
10/18/2023, 9:00 AMmbonnin
10/18/2023, 9:00 AMmbonnin
10/18/2023, 9:00 AMwasyl
10/18/2023, 9:01 AMwasyl
10/18/2023, 9:01 AMmbonnin
10/18/2023, 9:01 AMmbonnin
10/18/2023, 9:02 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 AMmbonnin
10/18/2023, 9:27 AMmbonnin
10/18/2023, 9:28 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
wasyl
10/18/2023, 9:32 AMSharedFlow-like cache would be out of scope for Apollo itself?mbonnin
10/18/2023, 9:41 AMmbonnin
10/18/2023, 9:41 AMmbonnin
10/18/2023, 9:42 AMmbonnin
10/18/2023, 9:42 AMApolloStore.refetchAllWatchers() or sowasyl
10/18/2023, 9:43 AMApolloStore.publish(rootKey)?mbonnin
10/18/2023, 9:43 AMmbonnin
10/18/2023, 9:44 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 AMmbonnin
10/18/2023, 2:06 PMApolloStore.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 querieswasyl
10/18/2023, 2:09 PMmbonnin
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")