public final class ApolloServerInterceptor extends java.lang.Object implements ApolloInterceptor
ApolloInterceptor responsible for making the network calls to the
server. It is the last interceptor in the chain of interceptors and hence doesn't call
ApolloInterceptorChain.proceed() on the interceptor chain.ApolloInterceptor.CallBack, ApolloInterceptor.InterceptorResponse| Constructor and Description |
|---|
ApolloServerInterceptor(okhttp3.HttpUrl serverUrl,
okhttp3.Call.Factory httpCallFactory,
HttpCachePolicy.Policy cachePolicy,
boolean prefetch,
com.squareup.moshi.Moshi moshi,
ApolloLogger logger) |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
cacheKey(okhttp3.RequestBody requestBody) |
void |
dispose()
Disposes of the resources which are no longer required.
|
ApolloInterceptor.InterceptorResponse |
intercept(com.apollographql.apollo.api.Operation operation,
ApolloInterceptorChain chain)
Intercepts the outgoing request, performs blocking operations on the request or the response returned by the next
set of interceptors in the chain, and returns an
ApolloInterceptor.InterceptorResponse if the operations succeeded or throws
an exception if the operations failed. |
void |
interceptAsync(com.apollographql.apollo.api.Operation operation,
ApolloInterceptorChain chain,
java.util.concurrent.ExecutorService dispatcher,
ApolloInterceptor.CallBack callBack)
Intercepts the outgoing request and performs non blocking operations on the request or the response returned by
the next set of interceptors in the chain.
|
public ApolloServerInterceptor(@Nonnull
okhttp3.HttpUrl serverUrl,
@Nonnull
okhttp3.Call.Factory httpCallFactory,
@Nullable
HttpCachePolicy.Policy cachePolicy,
boolean prefetch,
@Nonnull
com.squareup.moshi.Moshi moshi,
@Nonnull
ApolloLogger logger)
@Nonnull public ApolloInterceptor.InterceptorResponse intercept(com.apollographql.apollo.api.Operation operation, ApolloInterceptorChain chain) throws ApolloException
ApolloInterceptorApolloInterceptor.InterceptorResponse if the operations succeeded or throws
an exception if the operations failed.intercept in interface ApolloInterceptoroperation - the GraphQL Operation object contained within the outgoing request.chain - the ApolloInterceptorChain object containing the next set of interceptors.ApolloException - if an error occurred while performing operations on the request/response.public void interceptAsync(@Nonnull
com.apollographql.apollo.api.Operation operation,
@Nonnull
ApolloInterceptorChain chain,
@Nonnull
java.util.concurrent.ExecutorService dispatcher,
@Nonnull
ApolloInterceptor.CallBack callBack)
ApolloInterceptorinterceptAsync in interface ApolloInterceptoroperation - the GraphQL Operation object contained within the outgoing request.chain - the ApolloInterceptorChain object containing the next set of interceptors.dispatcher - the ExecutorService which dispatches the non blocking operations on the request/response.callBack - the Callback which will handle the interceptor's response or failure exception.public void dispose()
ApolloInterceptorA use case for this method call would be when an ApolloCall needs to be
cancelled and resources need to be disposed of.
dispose in interface ApolloInterceptorpublic static java.lang.String cacheKey(okhttp3.RequestBody requestBody)
throws java.io.IOException
java.io.IOException