ApolloInterceptor

An ApolloInterceptor intercepts requests at the GraphQL layer.

ApolloInterceptors may modify the request and or the response:

// Add a header to each request and extensions to each response.
val newRequest = request.newBuilder()
.addHttpHeader("foo1", "bar1")
.build()

return chain.proceed(newRequest).map {
it.newBuilder()
.extensions(mapOf("foo2" to "bar2"))
.build()
}

See also

Inheritors

Functions

Link copied to clipboard
abstract fun <D : Operation.Data> intercept(request: ApolloRequest<D>, chain: ApolloInterceptorChain): Flow<ApolloResponse<D>>

Intercepts the given request. Call chain.proceed() to continue with the next interceptor or emit items directly to bypass the chain.