addInterceptor

fun addInterceptor(interceptor: ApolloInterceptor, insertionPoint: ApolloInterceptor.InsertionPoint = ApolloInterceptor.InsertionPoint.BeforeCache): ApolloClient.Builder

Adds an ApolloInterceptor to this ApolloClient.

An ApolloInterceptor may monitor, rewrite, or retry an ApolloRequest. Internally, ApolloInterceptor is used for features such as normalized cache and auto persisted queries. ApolloClient also inserts a terminating ApolloInterceptor that executes the request.

The order is important. The built-in interceptors are always called in the following order:

  • cacheInterceptor

  • autoPersistedQueriesInterceptor

  • retryOnErrorInterceptor

  • networkInterceptor

Use ApolloInterceptor.InsertionPoint to control where to insert a specific interceptor.

See also