Builder

A Builder used to create instances of ApolloClient.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override var canBeBatched: Boolean?
Link copied to clipboard
var dispatcher: CoroutineDispatcher?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var httpHeaders: List<HttpHeader>?
Link copied to clipboard
Link copied to clipboard
open override var httpMethod: HttpMethod?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var sendApqExtensions: Boolean?
Link copied to clipboard
open override var sendDocument: Boolean?
Link copied to clipboard
Link copied to clipboard
var webSocketReopenServerUrl: suspend () -> String?
Link copied to clipboard
var webSocketReopenWhen: suspend (Throwable, attempt: Long) -> Boolean?
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun <T> addCustomScalarAdapter(customScalarType: CustomScalarType, customScalarAdapter: Adapter<T>): ApolloClient.Builder

Adds the given customScalarAdapter to this ApolloClient.

Link copied to clipboard
open override fun addExecutionContext(executionContext: ExecutionContext): ApolloClient.Builder
Link copied to clipboard
open override fun addHttpHeader(name: String, value: String): ApolloClient.Builder

Adds a HttpHeader to the ApolloClient headers. The ApolloClient headers are added to the ApolloCall headers.

Link copied to clipboard

Adds httpInterceptor to the list of HTTP interceptors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun autoPersistedQueries(httpMethodForHashedQueries: HttpMethod = HttpMethod.Get, httpMethodForDocumentQueries: HttpMethod = HttpMethod.Post, enableByDefault: Boolean = true): ApolloClient.Builder

Configures auto persisted queries.

Link copied to clipboard

Creates an ApolloClient from this Builder

Link copied to clipboard
open override fun canBeBatched(canBeBatched: Boolean?): ApolloClient.Builder

Whether this operation can be batched.

Link copied to clipboard

When conflateResponses is true, the fetch policy interceptors emit a single response and ignores the first cache or network error if a successful response is ultimately fetched. If no successful response can be emitted, a com.apollographql.apollo.exception.ApolloCompositeException error response is emitted.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun dispatcher(dispatcher: CoroutineDispatcher?): ApolloClient.Builder

Sets the CoroutineDispatcher that the return value of ApolloCall.toFlow will flow on.

Link copied to clipboard
open override fun enableAutoPersistedQueries(enableAutoPersistedQueries: Boolean?): ApolloClient.Builder

Whether to enable Auto Persisted Queries (APQs for this operation.

Link copied to clipboard
Link copied to clipboard

Whether to fail fast if the device is offline. Requires setting an interceptor that is aware of the network state with retryOnErrorInterceptor.

Link copied to clipboard
fun httpBatching(batchIntervalMillis: Long = 10, maxBatchSize: Int = 10, enableByDefault: Boolean = true): ApolloClient.Builder

Batch HTTP queries to execute multiple at once. This reduces the number of HTTP round trips at the price of increased latency as every request in the batch is now as slow as the slowest one. Some servers might have a per-HTTP-call cache making it faster to resolve 1 big array of n queries compared to resolving the n queries separately.

Link copied to clipboard

The HttpEngine to use for HTTP requests.

Link copied to clipboard

Configures whether to expose the error body in ApolloHttpException.

Link copied to clipboard
open override fun httpHeaders(httpHeaders: List<HttpHeader>?): ApolloClient.Builder

Configures the HttpHeaders to use. These headers are added with the ApolloCall headers.

Link copied to clipboard

Adds httpInterceptor to the list of HTTP interceptors.

Link copied to clipboard
open override fun httpMethod(httpMethod: HttpMethod?): ApolloClient.Builder

Configures the HttpMethod to use.

Link copied to clipboard

The http:// or https:// url of the GraphQL server.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Configures the NetworkTransport to use for queries and mutations.

Link copied to clipboard
fun ApolloClient.Builder.okHttpCallFactory(callFactory: <Error class: unknown class>): ApolloClient.Builder

Configures the ApolloClient to use the callFactory for network requests.

fun ApolloClient.Builder.okHttpCallFactory(callFactory: () -> <Error class: unknown class>): ApolloClient.Builder

Configures the ApolloClient to use the lazily initialized callFactory for network requests.

Link copied to clipboard
fun ApolloClient.Builder.okHttpClient(okHttpClient: <Error class: unknown class>): ApolloClient.Builder

Configures the ApolloClient to use the OkHttpClient for network requests. The OkHttpClient will be used for both HTTP and WebSocket requests.

Link copied to clipboard

Removes httpInterceptor from the list of HTTP interceptors.

Link copied to clipboard
Link copied to clipboard

Configures the retryOnError default if ApolloRequest.retryOnError is not set.

Link copied to clipboard

Sets the ApolloInterceptor used to retry or fail fast a request. The interceptor may use ApolloRequest.retryOnError and ApolloRequest.failFastIfOffline. The interceptor is also responsible for allocating a new ApolloRequest.requestUuid on retries if needed.

Link copied to clipboard
open override fun sendApqExtensions(sendApqExtensions: Boolean?): ApolloClient.Builder

Whether to send the Auto Persisted Queries (APQs extensions.

Link copied to clipboard
open override fun sendDocument(sendDocument: Boolean?): ApolloClient.Builder

Whether to send the GraphQL Document.

Link copied to clipboard

The http:// or https:// url of the GraphQL server.

Link copied to clipboard

Configures the NetworkTransport to use for queries and mutations.

Link copied to clipboard

The WebSocketEngine to use for WebSocket requests

Link copied to clipboard
fun webSocketIdleTimeoutMillis(webSocketIdleTimeoutMillis: Long?): ApolloClient.Builder

The timeout after which an inactive WebSocket will be closed

Link copied to clipboard
fun webSocketReopenWhen(webSocketReopenWhen: suspend (Throwable, attempt: Long) -> Boolean?): ApolloClient.Builder

Configure the WebSocketNetworkTransport to reopen the websocket automatically when a network error happens

Link copied to clipboard

The url of the GraphQL server used for WebSockets Use this function or webSocketServerUrl((suspend () -> String)) but not both.

fun webSocketServerUrl(webSocketServerUrl: suspend () -> String?): ApolloClient.Builder

Configure dynamically the url of the GraphQL server used for WebSockets. Use this function or webSocketServerUrl(String) but not both.

Link copied to clipboard

The WsProtocol.Factory to use for websockets