ApolloStore

interface ApolloStore

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

Functions

Link copied to clipboard
abstract suspend fun <R> accessCache(block: (NormalizedCache) -> R): R

Direct access to the cache.

Link copied to clipboard
abstract fun clearAll(): Boolean

Clear all records from this ApolloStore. This is a synchronous operation that might block if the underlying cache is doing IO

Link copied to clipboard
abstract fun dispose()

releases resources associated with this store.

Link copied to clipboard
abstract suspend fun dump(): Map<KClass<*>, Map<String, Record>>
Link copied to clipboard
abstract fun <D : Operation.Data> normalize(    operation: Operation<D>,     data: D,     customScalarAdapters: CustomScalarAdapters): Map<String, Record>
Link copied to clipboard
abstract suspend fun publish(keys: Set<String>)
Link copied to clipboard
abstract suspend fun <D : Fragment.Data> readFragment(    fragment: Fragment<D>,     cacheKey: CacheKey,     customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty,     cacheHeaders: CacheHeaders = CacheHeaders.NONE): D

Read a GraphQL fragment from the store. This is a synchronous operation that might block if the underlying cache is doing IO

Link copied to clipboard
abstract suspend fun <D : Operation.Data> readOperation(    operation: Operation<D>,     customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty,     cacheHeaders: CacheHeaders = CacheHeaders.NONE): D

Read GraphQL operation from store. This is a synchronous operation that might block if the underlying cache is doing IO

Link copied to clipboard
abstract suspend fun remove(cacheKey: CacheKey, cascade: Boolean = true): Boolean

Remove cache record by the key This is a synchronous operation that might block if the underlying cache is doing IO

abstract suspend fun remove(cacheKeys: List<CacheKey>, cascade: Boolean = true): Int

Remove a list of cache records This is an optimized version of remove for caches that can batch operations This is a synchronous operation that might block if the underlying cache is doing IO

Link copied to clipboard
abstract suspend fun rollbackOptimisticUpdates(mutationId: Uuid, publish: Boolean = true): Set<String>

Rollback operation data optimistic updates.

Link copied to clipboard
abstract suspend fun <D : Fragment.Data> writeFragment(    fragment: Fragment<D>,     cacheKey: CacheKey,     fragmentData: D,     customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty,     cacheHeaders: CacheHeaders = CacheHeaders.NONE,     publish: Boolean = true): Set<String>

Write a fragment data to the store and optionally publish changes of Record which have changed, that will notify any watcher that depends on these Record to re-fetch. This is a synchronous operation that might block if the underlying cache is doing IO

Link copied to clipboard
abstract suspend fun <D : Operation.Data> writeOperation(    operation: Operation<D>,     operationData: D,     customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty,     cacheHeaders: CacheHeaders = CacheHeaders.NONE,     publish: Boolean = true): Set<String>

Write an operation data to the store and optionally publish changes of Record which have changed, that will notify any watcher that depends on these Record to re-fetch. This is a synchronous operation that might block if the underlying cache is doing IO

Link copied to clipboard
abstract suspend fun <D : Operation.Data> writeOptimisticUpdates(    operation: Operation<D>,     operationData: D,     mutationId: Uuid,     customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty,     publish: Boolean = true): Set<String>

Write operation data to the optimistic store.

Properties

Link copied to clipboard
abstract val changedKeys: SharedFlow<Set<String>>

changedKeys will emit changes as they are written