Builder

class Builder : MutableExecutionOptions<ApolloClient.Builder>

A Builder used to create instances of ApolloClient

Constructors

Link copied to clipboard
fun Builder()

Functions

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

Registers the given customScalarAdapter

Link copied to clipboard
fun <T> addCustomTypeAdapter(customScalarType: CustomScalarType, customTypeAdapter: CustomTypeAdapter<T>): ApolloClient.Builder
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
Link copied to clipboard
fun addHttpInterceptor(httpInterceptor: HttpInterceptor): ApolloClient.Builder

Adds httpInterceptor to the list of HTTP interceptors

Link copied to clipboard
fun addInterceptor(interceptor: ApolloInterceptor): ApolloClient.Builder
Link copied to clipboard
fun addInterceptors(interceptors: List<ApolloInterceptor>): ApolloClient.Builder
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
fun build(): ApolloClient

Creates an ApolloClient from this Builder

Link copied to clipboard
open override fun canBeBatched(canBeBatched: Boolean?): ApolloClient.Builder
Link copied to clipboard
fun copy(): ApolloClient.Builder
Link copied to clipboard
fun customScalarAdapters(customScalarAdapters: CustomScalarAdapters): ApolloClient.Builder
Link copied to clipboard
fun dispatcher(dispatcher: CoroutineDispatcher?): ApolloClient.Builder

Changes the CoroutineDispatcher used for I/O intensive work like reading the network or the cache On the JVM the dispatcher is kotlinx.coroutines.Dispatchers.IO by default. On native this function has no effect. Network request use the default NSURLConnection threads and the cache uses a background dispatch queue.

Link copied to clipboard
open override fun enableAutoPersistedQueries(enableAutoPersistedQueries: Boolean?): ApolloClient.Builder
Link copied to clipboard
fun executionContext(executionContext: ExecutionContext): ApolloClient.Builder
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
fun httpEngine(httpEngine: HttpEngine): ApolloClient.Builder

The HttpEngine to use for HTTP requests

Link copied to clipboard
fun httpExposeErrorBody(httpExposeErrorBody: Boolean): ApolloClient.Builder

Configures whether to expose the error body in ApolloHttpException.

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

The url of the GraphQL server used for HTTP

Link copied to clipboard
fun interceptors(interceptors: List<ApolloInterceptor>): ApolloClient.Builder
Link copied to clipboard
fun networkTransport(networkTransport: NetworkTransport): ApolloClient.Builder
Link copied to clipboard
fun requestedDispatcher(requestedDispatcher: CoroutineDispatcher?): ApolloClient.Builder
Link copied to clipboard
open override fun sendApqExtensions(sendApqExtensions: Boolean?): ApolloClient.Builder
Link copied to clipboard
open override fun sendDocument(sendDocument: Boolean?): ApolloClient.Builder
Link copied to clipboard
fun serverUrl(serverUrl: String): ApolloClient.Builder

The url of the GraphQL server used for HTTP

Link copied to clipboard
fun subscriptionNetworkTransport(subscriptionNetworkTransport: NetworkTransport): ApolloClient.Builder
Link copied to clipboard
Link copied to clipboard
fun useHttpGetMethodForQueries(useHttpGetMethodForQueries: Boolean): ApolloClient.Builder
Link copied to clipboard
fun webSocketEngine(webSocketEngine: WebSocketEngine): ApolloClient.Builder

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
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
fun webSocketServerUrl(webSocketServerUrl: String): ApolloClient.Builder

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
fun wsProtocol(wsProtocolFactory: WsProtocol.Factory): ApolloClient.Builder

The WsProtocol.Factory to use for websockets

Properties

Link copied to clipboard
open override var canBeBatched: Boolean? = null
Link copied to clipboard
open override var enableAutoPersistedQueries: Boolean? = null
Link copied to clipboard
open override var executionContext: ExecutionContext
Link copied to clipboard
open override var httpHeaders: List<HttpHeader>? = null
Link copied to clipboard
open override var httpMethod: HttpMethod? = null
Link copied to clipboard
val interceptors: List<ApolloInterceptor>
Link copied to clipboard
open override var sendApqExtensions: Boolean? = null
Link copied to clipboard
open override var sendDocument: Boolean? = null

Extensions

Link copied to clipboard
fun ApolloClient.Builder.okHttpCallFactory(callFactory: Call.Factory): ApolloClient.Builder

Configures the ApolloClient to use the callFactory for network requests.

Link copied to clipboard
fun ApolloClient.Builder.okHttpClient(okHttpClient: OkHttpClient): ApolloClient.Builder

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