watch

fun <D : Query.Data> ApolloCall<D>.watch(fetchThrows: Boolean = false, refetchThrows: Boolean = false): Flow<ApolloResponse<D>>

Gets the result from the network, then observes the cache for any changes. fetchPolicy will control how the result is first queried, while refetchPolicy will control the subsequent fetches. Network and cache exceptions are ignored by default, this can be changed by setting fetchThrows for the first fetch and refetchThrows for subsequent fetches (non Apollo exceptions like OutOfMemoryError are always propagated).

Parameters

fetchThrows

whether to throw if an ApolloException happens during the initial fetch. Default: false

refetchThrows

whether to throw if an ApolloException happens during a refetch. Default: false


fun <D : Query.Data> ApolloCall<D>.watch(data: D?, retryWhen: suspend (cause: Throwable, attempt: Long) -> Boolean = { _, _ -> true }): Flow<ApolloResponse<D>>

Observes the cache for the given data. Unlike watch, no initial request is executed on the network. Network and cache exceptions are ignored by default, this can be controlled with the retryWhen lambda. The fetch policy set by fetchPolicy will be used.