Is there any benefit to using
prefetch
if we’re already observing the query we want to prefetch? Will we avoid some parsing, for example?
Context: we’re trying to have a separation between observing data from cache and refreshing it. Observers will do:
val observer = apolloClient.query(operation).toBuilder()
.responseFetcher(ApolloResponseFetchers.CACHE_ONLY)
.build()
.toFlow()
and I wonder if there’s preferred refreshing method. One is prefetch:
fun refresh() = apolloClient.prefetch(operation).await()
another is a
NETWORK_ONLY
request and awaiting first response:
fun refresh() = apolloClient.query(operation).toBuilder()
.responseFetcher(ApolloResponseFetchers.NETWORK_ONLY)
.build()
.toFlow()
.first()
I also see
ApolloQueryWatcher#refetch
, but I don’t think it’ll work for us because it doesn’t propagate errors.
Prefetch
has some optimisations mentioned in the docs, are they relevant if we have another query observing the cache?