Package-level declarations

Types

Link copied to clipboard
interface ApolloStore

ApolloStore exposes a thread-safe api to access a com.apollographql.cache.normalized.api.NormalizedCache.

Link copied to clipboard
class CacheInfo : ExecutionContext.Element
Link copied to clipboard
class CacheMissLoggingInterceptor(log: (String) -> Unit) : ApolloInterceptor
Link copied to clipboard

Properties

Link copied to clipboard
val ApolloClient.apolloStore: ApolloStore
Link copied to clipboard
val CacheAndNetworkInterceptor: ApolloInterceptor

An interceptor that emits the response from the cache first, and then emits the response(s) from the network.

Link copied to clipboard
val CacheFirstInterceptor: ApolloInterceptor

An interceptor that emits the response from the cache first, and if there was a cache miss, emits the response(s) from the network.

Link copied to clipboard
val <D : Operation.Data> ApolloResponse<D>.cacheHeaders: CacheHeaders
Link copied to clipboard
val <D : Operation.Data> ApolloResponse<D>.cacheInfo: CacheInfo?
Link copied to clipboard
val CacheOnlyInterceptor: ApolloInterceptor

An interceptor that emits the response from the cache only.

Link copied to clipboard
val <D : Operation.Data> ApolloResponse<D>.isFromCache: Boolean

True if this response comes from the cache, false if it comes from the network.

Link copied to clipboard
val NetworkFirstInterceptor: ApolloInterceptor

An interceptor that emits the response(s) from the network first, and if there was a network error, emits the response from the cache.

Link copied to clipboard
val NetworkOnlyInterceptor: ApolloInterceptor

An interceptor that emits the response(s) from the network only.

Link copied to clipboard
const val VERSION: String

Functions

Link copied to clipboard
fun <T> MutableExecutionOptions<T>.addCacheHeader(key: String, value: String): T

Add a cache header to be passed to your com.apollographql.cache.normalized.api.NormalizedCache

Link copied to clipboard
fun ApolloStore(normalizedCacheFactory: NormalizedCacheFactory, cacheKeyGenerator: CacheKeyGenerator = TypePolicyCacheKeyGenerator, metadataGenerator: MetadataGenerator = EmptyMetadataGenerator, cacheResolver: CacheResolver = FieldPolicyCacheResolver, recordMerger: RecordMerger = DefaultRecordMerger, fieldKeyGenerator: FieldKeyGenerator = DefaultFieldKeyGenerator, embeddedFieldsProvider: EmbeddedFieldsProvider = DefaultEmbeddedFieldsProvider): ApolloStore
Link copied to clipboard
fun <D : Operation.Data> ApolloResponse.Builder<D>.cacheHeaders(cacheHeaders: CacheHeaders): ApolloResponse.Builder<D>
fun <T> MutableExecutionOptions<T>.cacheHeaders(cacheHeaders: CacheHeaders): T
Link copied to clipboard
fun <T> MutableExecutionOptions<T>.doNotStore(doNotStore: Boolean): T
Link copied to clipboard
fun <T> MutableExecutionOptions<T>.fetchPolicy(fetchPolicy: FetchPolicy): T

Sets the initial FetchPolicy This only has effects for queries. Mutations and subscriptions always use FetchPolicy.NetworkOnly

Link copied to clipboard
fun <T> MutableExecutionOptions<T>.fetchPolicyInterceptor(interceptor: ApolloInterceptor): T

Sets the initial FetchPolicy This only has effects for queries. Mutations and subscriptions always use FetchPolicy.NetworkOnly

Link copied to clipboard
@JvmName(name = "-logCacheMisses")
fun ApolloClient.Builder.logCacheMisses(log: (String) -> Unit = { println(it) }): ApolloClient.Builder
Link copied to clipboard
fun <T> MutableExecutionOptions<T>.maxStale(maxStale: Duration): T
Link copied to clipboard
fun <T> MutableExecutionOptions<T>.memoryCacheOnly(memoryCacheOnly: Boolean): T
Link copied to clipboard
@JvmName(name = "configureApolloClientBuilder2")
fun ApolloClient.Builder.normalizedCache(normalizedCacheFactory: NormalizedCacheFactory, cacheKeyGenerator: CacheKeyGenerator = TypePolicyCacheKeyGenerator, metadataGenerator: MetadataGenerator = EmptyMetadataGenerator, cacheResolver: CacheResolver = FieldPolicyCacheResolver, recordMerger: RecordMerger = DefaultRecordMerger, fieldKeyGenerator: FieldKeyGenerator = DefaultFieldKeyGenerator, embeddedFieldsProvider: EmbeddedFieldsProvider = DefaultEmbeddedFieldsProvider, writeToCacheAsynchronously: Boolean = false): ApolloClient.Builder

Configures an ApolloClient with a normalized cache.

Link copied to clipboard
fun <D : Mutation.Data> ApolloCall<D>.optimisticUpdates(data: D): ApolloCall<D>

fun <D : Mutation.Data> ApolloRequest.Builder<D>.optimisticUpdates(data: D): ApolloRequest.Builder<D>

Sets the optimistic updates to write to the cache while a query is pending.

Link copied to clipboard
fun <T> MutableExecutionOptions<T>.refetchPolicy(fetchPolicy: FetchPolicy): T

Sets the FetchPolicy used when watching queries and a cache change has been published

Link copied to clipboard
fun <T> MutableExecutionOptions<T>.refetchPolicyInterceptor(interceptor: ApolloInterceptor): T

Sets the FetchPolicy used when watching queries and a cache change has been published

Link copied to clipboard
fun ApolloClient.Builder.store(store: ApolloStore, writeToCacheAsynchronously: Boolean = false): ApolloClient.Builder
Link copied to clipboard
fun <T> MutableExecutionOptions<T>.storeExpirationDate(storeExpirationDate: Boolean): T
Link copied to clipboard
fun <T> MutableExecutionOptions<T>.storePartialResponses(storePartialResponses: Boolean): T
Link copied to clipboard
fun <T> MutableExecutionOptions<T>.storeReceiveDate(storeReceiveDate: Boolean): T
Link copied to clipboard
fun <D : Query.Data> ApolloCall<D>.watch(): Flow<ApolloResponse<D>>

Gets initial response(s) then observes the cache for any changes.

fun <D : Query.Data> ApolloCall<D>.watch(data: D?): Flow<ApolloResponse<D>>

Observes the cache for the given data. Unlike watch, no initial request is executed on the network. The fetch policy set by fetchPolicy will be used.

Link copied to clipboard
fun <T> MutableExecutionOptions<T>.writeToCacheAsynchronously(writeToCacheAsynchronously: Boolean): T