Package com.apollographql.apollo3.cache.normalized

Types

Link copied to clipboard
interface ApolloStore

ApolloStore exposes a thread-safe api to access a com.apollographql.apollo3.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
enum FetchPolicy : Enum<FetchPolicy>

Functions

Link copied to clipboard
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>.emitCacheMisses(emitCacheMisses: Boolean): T
Link copied to clipboard

Gets the result from the cache first and always fetch from the network. Use this to get an early cached result while also updating the network values.

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
@JvmName(name = "configureApolloClientBuilder")
fun ApolloClient.Builder.normalizedCache(    normalizedCacheFactory: NormalizedCacheFactory,     cacheKeyGenerator: CacheKeyGenerator = TypePolicyCacheKeyGenerator,     cacheResolver: CacheResolver = FieldPolicyCacheResolver,     writeToCacheAsynchronously: Boolean = false): ApolloClient.Builder

Configures an ApolloClient with a normalized cache.

@JvmName(name = "configureApolloClientBuilder2")
fun ApolloClient.Builder.normalizedCache(    normalizedCacheFactory: NormalizedCacheFactory,     cacheKeyGenerator: CacheKeyGenerator,     metadataGenerator: MetadataGenerator,     apolloResolver: ApolloResolver,     recordMerger: RecordMerger,     writeToCacheAsynchronously: Boolean = false): ApolloClient.Builder
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(data: D?, retryWhen: suspend (cause: Throwable, attempt: Long) -> Boolean = { _, _ -> true }): Flow<ApolloResponse<D>>

Observes the cache for the given data. Unlike watch, no initial request is executed on the network. Network and cache exceptions are ignored by default, this can be controlled with the retryWhen lambda. The fetch policy set by fetchPolicy will be used.

fun <D : Query.Data> ApolloCall<D>.watch(fetchThrows: Boolean = false, refetchThrows: Boolean = false): Flow<ApolloResponse<D>>

Gets the result from the network, then observes the cache for any changes. fetchPolicy will control how the result is first queried, while refetchPolicy will control the subsequent fetches. Network and cache exceptions are ignored by default, this can be changed by setting fetchThrows for the first fetch and refetchThrows for subsequent fetches (non Apollo exceptions like OutOfMemoryError are always propagated).

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

Properties

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

An interceptor that goes to cache first and then to the network. An exception is not thrown if the cache fails, whereas an exception will be thrown upon network failure.

Link copied to clipboard
val CacheFirstInterceptor: ApolloInterceptor

An interceptor that goes to cache first and then to the network if it fails

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 goes to the cache only

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