Marco Pierucci
11/17/2023, 9:51 AMMarco Pierucci
11/17/2023, 9:57 AMfun workOrder(id: String): Flow<Pair<WorkOrderInfo, List<FetchWorkOrderQuery.ValidFieldsetOption>>> {
return apolloClient.query(FetchWorkOrderQuery(id = id))
.fetchPolicy(FetchPolicy.CacheFirst)
.watch()
.map {
...
}
}
And the Have A mutation with an optmistic cache:
apolloClient.mutation(UpdateTaskComponentsMutation(input = newComponents))
.doNotStore(false)
.optimisticUpdates(
UpdateTaskComponentsMutation.Data(
UpdateTaskComponentsMutation.UpdateTaskComponents(
listOf(
UpdateTaskComponentsMutation.Component(
__typename = newComponent.componentInfo.__typename,
componentInfo = newComponent.componentInfo,
id = newComponent.componentInfo.id
)
)
)
)
)
.execute()
This seems to be writing in the cache alright, ( If I re enter the screen I can see the new value)
But for some reason the watch is not emitting?Marco Pierucci
11/17/2023, 9:58 AMmbonnin
11/17/2023, 10:42 AMMarco Pierucci
11/17/2023, 10:43 AMmbonnin
11/17/2023, 10:44 AMonCompletion { println("complete) }
)mbonnin
11/17/2023, 10:44 AMapolloClient.apolloStore.publish(setOf("Component:42"))
)Marco Pierucci
11/17/2023, 10:45 AMmbonnin
11/17/2023, 10:46 AMmbonnin
11/17/2023, 10:48 AMwatch()
also takes 2 parameters (I'm assuming you're using v3, right?). You can try setting them to true to make the flow throw on cache missesMarco Pierucci
11/17/2023, 10:50 AMMarco Pierucci
11/17/2023, 10:50 AMMarco Pierucci
11/17/2023, 11:28 AMmbonnin
11/17/2023, 11:30 AMMarco Pierucci
11/17/2023, 11:30 AMmbonnin
11/17/2023, 11:30 AMmbonnin
11/17/2023, 11:31 AMMarco Pierucci
11/17/2023, 11:31 AMMarco Pierucci
11/17/2023, 11:31 AMWhat's interesting is that the other flow you were watching is not related to the 1st one?But they all add watch keys to the pool right?
mbonnin
11/17/2023, 11:32 AMwatchedKeys == null || changedKeys.intersect(watchedKeys!!).isNotEmpty()
mbonnin
11/17/2023, 11:32 AMwatchedKeys
here is local to one queryMarco Pierucci
11/17/2023, 11:32 AMmbonnin
11/17/2023, 11:32 AMchangedKeys
is whatever changed in the storeMarco Pierucci
11/17/2023, 11:33 AMMarco Pierucci
11/17/2023, 11:33 AM