public static class ApolloClient.Builder
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
ApolloClient.Builder |
addApplicationInterceptor(ApolloInterceptor interceptor)
Adds an interceptor that observes the full span of each call: from before the connection is established until
after the response source is selected (either the server, cache or both).
|
<T> ApolloClient.Builder |
addCustomTypeAdapter(com.apollographql.apollo.api.ScalarType scalarType,
CustomTypeAdapter<T> customTypeAdapter)
Set the type adapter to use for serializing and de-serializing custom GraphQL scalar types.
|
ApolloClient |
build()
Builds the
ApolloClient instance using the configured values. |
ApolloClient.Builder |
defaultCacheControl(CacheControl cacheControl)
Set the default
CacheControl strategy that will be used for each new
ApolloCall. |
ApolloClient.Builder |
defaultCacheHeaders(CacheHeaders cacheHeaders)
Set the default
CacheHeaders strategy that will be passed
to each new ApolloCall. |
ApolloClient.Builder |
defaultHttpCachePolicy(HttpCachePolicy.Policy cachePolicy)
Sets the http cache policy to be used as default for all GraphQL
Query operations. |
ApolloClient.Builder |
dispatcher(java.util.concurrent.ExecutorService dispatcher)
The #
ExecutorService to use for dispatching the requests. |
ApolloClient.Builder |
httpCacheStore(HttpCacheStore cacheStore)
Set the configuration to be used for request/response http cache.
|
ApolloClient.Builder |
logger(Logger logger)
The
Logger to use for logging purposes. |
ApolloClient.Builder |
normalizedCache(NormalizedCacheFactory normalizedCacheFactory)
Set the configuration to be used for normalized cache.
|
ApolloClient.Builder |
normalizedCache(NormalizedCacheFactory normalizedCacheFactory,
CacheKeyResolver keyResolver)
Set the configuration to be used for normalized cache.
|
ApolloClient.Builder |
okHttpClient(okhttp3.OkHttpClient okHttpClient)
Set the
OkHttpClient to use for making network requests. |
ApolloClient.Builder |
serverUrl(okhttp3.HttpUrl serverUrl)
Set the API server's base url.
|
ApolloClient.Builder |
serverUrl(java.lang.String serverUrl)
Set the API server's base url.
|
public ApolloClient.Builder okHttpClient(@Nonnull okhttp3.OkHttpClient okHttpClient)
OkHttpClient to use for making network requests.okHttpClient - the client to use.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder serverUrl(@Nonnull okhttp3.HttpUrl serverUrl)
Set the API server's base url.
serverUrl - the url to set.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder serverUrl(@Nonnull java.lang.String serverUrl)
Set the API server's base url.
serverUrl - the url to set.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder httpCacheStore(@Nonnull HttpCacheStore cacheStore)
cacheStore - The store to use for reading and writing cached response.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder normalizedCache(@Nonnull NormalizedCacheFactory normalizedCacheFactory)
normalizedCacheFactory - the NormalizedCacheFactory used to construct a NormalizedCache.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder normalizedCache(@Nonnull NormalizedCacheFactory normalizedCacheFactory, @Nonnull CacheKeyResolver keyResolver)
normalizedCacheFactory - the NormalizedCacheFactory used to construct a NormalizedCache.keyResolver - the CacheKeyResolver to use to normalize recordsApolloClient.Builder object to be used for chaining method callspublic <T> ApolloClient.Builder addCustomTypeAdapter(@Nonnull com.apollographql.apollo.api.ScalarType scalarType, @Nonnull CustomTypeAdapter<T> customTypeAdapter)
T - the value typescalarType - the scalar type to serialize/deserializecustomTypeAdapter - the type adapter to useApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder dispatcher(@Nonnull java.util.concurrent.ExecutorService dispatcher)
ExecutorService to use for dispatching the requests.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder defaultHttpCachePolicy(@Nonnull HttpCachePolicy.Policy cachePolicy)
Query operations. Will be ignored for
any Mutation operations. By default http cache policy is set to HttpCachePolicy.NETWORK_ONLY.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder defaultCacheControl(@Nonnull CacheControl cacheControl)
CacheControl strategy that will be used for each new
ApolloCall.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder defaultCacheHeaders(@Nonnull CacheHeaders cacheHeaders)
CacheHeaders strategy that will be passed
to each new ApolloCall.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder logger(@Nullable Logger logger)
Logger to use for logging purposes.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder addApplicationInterceptor(@Nonnull ApolloInterceptor interceptor)
Adds an interceptor that observes the full span of each call: from before the connection is established until after the response source is selected (either the server, cache or both). This method can be called multiple times for adding multiple application interceptors.
Note: Interceptors will be called in the order in which they are added to the list of interceptors and if any of the interceptors tries to short circuit the responses, then subsequent interceptors won't be called.
interceptor - Application level interceptor to addApolloClient.Builder object to be used for chaining method callspublic ApolloClient build()
ApolloClient instance using the configured values.
Note that if the dispatcher is not called, then a default ExecutorService is used.ApolloClient