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 |
callFactory(okhttp3.Call.Factory factory)
Set the custom call factory for creating
Call instances. |
ApolloClient.Builder |
defaultCacheHeaders(CacheHeaders cacheHeaders)
Set the default
CacheHeaders strategy that will be passed to the com.apollographql.apollo.interceptor.FetchOptions used in each new ApolloCall. |
ApolloClient.Builder |
defaultHttpCachePolicy(com.apollographql.apollo.api.cache.http.HttpCachePolicy.Policy cachePolicy)
Sets the http cache policy to be used as default for all GraphQL
Query operations. |
ApolloClient.Builder |
defaultResponseFetcher(ResponseFetcher defaultResponseFetcher)
Set the default
ResponseFetcher to be used with each new ApolloCall. |
ApolloClient.Builder |
dispatcher(java.util.concurrent.Executor dispatcher)
The #
Executor to use for dispatching the requests. |
ApolloClient.Builder |
httpCache(com.apollographql.apollo.api.cache.http.HttpCache httpCache)
Set the configuration to be used for request/response http cache.
|
ApolloClient.Builder |
logger(com.apollographql.apollo.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 |
sendOperationIdentifiers(boolean sendOperationIdentifiers) |
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.
|
ApolloClient.Builder |
subscriptionConnectionParams(java.util.Map<java.lang.String,java.lang.Object> subscriptionConnectionParams)
Sets up subscription connection parameters to be sent to the server when connection is established with
subscription server
|
ApolloClient.Builder |
subscriptionTransportFactory(SubscriptionTransport.Factory subscriptionTransportFactory)
Sets up subscription transport factory to be used for subscription server communication. See also:
WebSocketSubscriptionTransport |
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 callFactory(@Nonnull okhttp3.Call.Factory factory)
Call instances. Note: Calling okHttpClient(OkHttpClient) automatically sets this value.
public 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 httpCache(@Nonnull com.apollographql.apollo.api.cache.http.HttpCache httpCache)
httpCache - The 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.Executor dispatcher)
Executor to use for dispatching the requests.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder defaultHttpCachePolicy(@Nonnull com.apollographql.apollo.api.cache.http.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 defaultCacheHeaders(@Nonnull CacheHeaders cacheHeaders)
CacheHeaders strategy that will be passed to the com.apollographql.apollo.interceptor.FetchOptions used in each new ApolloCall.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder defaultResponseFetcher(@Nonnull ResponseFetcher defaultResponseFetcher)
ResponseFetcher to be used with each new ApolloCall.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder logger(@Nullable com.apollographql.apollo.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.Builder sendOperationIdentifiers(boolean sendOperationIdentifiers)
sendOperationIdentifiers - True if ApolloClient should send a operation identifier instead of the operation
definition. Default: false.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder subscriptionTransportFactory(@Nonnull SubscriptionTransport.Factory subscriptionTransportFactory)
Sets up subscription transport factory to be used for subscription server communication.
See also:WebSocketSubscriptionTransportsubscriptionTransportFactory - transport layer to be used for subscriptions.ApolloClient.Builder object to be used for chaining method callspublic ApolloClient.Builder subscriptionConnectionParams(@Nonnull java.util.Map<java.lang.String,java.lang.Object> subscriptionConnectionParams)
Sets up subscription connection parameters to be sent to the server when connection is established with subscription server
subscriptionConnectionParams - map of connection parameters to be sentApolloClient.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 Executor is used.ApolloClient