RetryOnErrorInterceptor
Returns an ApolloInterceptor that monitors network errors and possibly retries the Flow when an ApolloNetworkException happens.
The returned RetryOnErrorInterceptor:
allocates a new ApolloRequest.requestUuid for each retry.
if ApolloRequest.retryOnError is
true
, waits until network is available and retries the request.if ApolloRequest.failFastIfOffline is
true
and NetworkMonitor.isOnline isfalse
, returns early with ApolloNetworkException.
Use with com.apollographql.apollo.ApolloClient.Builder.retryOnErrorInterceptor:
apolloClient = ApolloClient.Builder()
.serverUrl("https://...")
.retryOnErrorInterceptor(RetryOnErrorInterceptor(NetworkMonitor(context)))
.build()
Content copied to clipboard
Some other types of error than ApolloNetworkException might be recoverable as well (rate limit, ...) but are out of scope for this interceptor.