Package-level declarations

Types

Link copied to clipboard

A collection of cache headers that Apollo's implementations of NormalizedCache respect.

Link copied to clipboard
interface CacheData

Data read from the cache that can be represented as a JSON map.

Link copied to clipboard

A key/value collection which is sent with Record from a Operation to the NormalizedCache.

Link copied to clipboard
class CacheKey(val key: String)

A CacheKey identifies an object in the cache.

Link copied to clipboard

An CacheKeyGenerator is responsible for finding an id for a given object

Link copied to clipboard
class CacheKeyGeneratorContext(val field: CompiledField, val variables: Executable.Variables)

The context in which an object is normalized.

Link copied to clipboard

A CacheResolver that resolves objects and list of objects and falls back to the default resolver for scalar fields. It is intended to simplify the usage of CacheResolver when no special handling is needed for scalar fields.

Link copied to clipboard
interface CacheResolver

Controls how fields are resolved from the cache.

Link copied to clipboard

A FieldKeyGenerator that generates field keys by excluding Relay connection types pagination arguments.

Link copied to clipboard

A MetadataGenerator that generates metadata for Relay connection types. Collaborates with ConnectionRecordMerger to merge pages of a connection.

Link copied to clipboard

A cache resolver that uses the parent to resolve fields.

Link copied to clipboard

An EmbeddedFieldsProvider that returns the fields specified by the @typePolicy(embeddedFields: "...") directive.

Link copied to clipboard

A FieldKeyGenerator that returns the field name with its arguments, excluding pagination arguments defined with the @fieldPolicy(forField: "...", paginationArgs: "...") directive.

Link copied to clipboard

A RecordMerger that merges fields by replacing them with the incoming fields.

Link copied to clipboard
class EmbeddedFieldsContext(val parentType: CompiledNamedType)
Link copied to clipboard

A provider for fields whose value should be embedded in their Record, rather than being dereferenced during normalization.

Link copied to clipboard

Default MetadataGenerator that returns empty metadata.

Link copied to clipboard

A cache resolver that raises a cache miss if the field's received date is older than its max age (configurable via maxAgeProvider) or its expiration date has passed.

Link copied to clipboard
class FieldKeyContext(val parentType: String, val field: CompiledField, val variables: Executable.Variables)

Context passed to the FieldKeyGenerator.getFieldKey method.

Link copied to clipboard

A generator for field keys.

Link copied to clipboard

A cache resolver that uses @fieldPolicy annotations to resolve fields and delegates to DefaultCacheResolver otherwise

Link copied to clipboard

A convenience implementation of RecordMerger that simplifies the merging of Records by delegating to a FieldMerger.

Link copied to clipboard

A provider that returns a single max age for all types.

Link copied to clipboard
sealed interface MaxAge
Link copied to clipboard
class MaxAgeContext(val fieldPath: List<CompiledField>)
Link copied to clipboard
interface MaxAgeProvider
Link copied to clipboard
class MemoryCache(nextCache: NormalizedCache? = null, maxSizeBytes: Int = Int.MAX_VALUE, expireAfterMillis: Long = -1) : NormalizedCache

Memory (multiplatform) cache implementation based on recently used property (LRU).

Link copied to clipboard
class MemoryCacheFactory @JvmOverloads constructor(maxSizeBytes: Int = Int.MAX_VALUE, expireAfterMillis: Long = -1) : NormalizedCacheFactory
Link copied to clipboard

A generator for arbitrary metadata associated with objects. For example, information about pagination can later be used to merge pages (see RecordMerger).

Link copied to clipboard
class MetadataGeneratorContext(val field: CompiledField, val variables: Executable.Variables)

Additional context passed to the MetadataGenerator.metadataForObject method.

Link copied to clipboard

A provider of Record for reading requests from cache.

Link copied to clipboard
abstract class NormalizedCacheFactory

A Factory used to construct an instance of a NormalizedCache configured with the custom scalar adapters set in ApolloClient.Builder#addCustomScalarAdapter(ScalarType, CustomScalarAdapter).

Link copied to clipboard
Link copied to clipboard
class Record(val key: String, val fields: Map<String, RecordValue>, val mutationId: Uuid? = null) : Map<String, Any?>

A normalized entry that corresponds to a response object. Object fields are stored if they are a GraphQL Scalars. If a field is a GraphQL Object a CacheKey will be stored instead.

Link copied to clipboard
interface RecordMerger

A merger that merges incoming Records from the network with existing ones in the cache.

Link copied to clipboard
typealias RecordValue = Any?

A typealias for a type-unsafe Kotlin representation of a Record value. This typealias is mainly for internal documentation purposes and low-level manipulations and should generally be avoided in application code.

Link copied to clipboard
class ResolverContext(val field: CompiledField, val variables: Executable.Variables, val parent: Map<String, @JvmSuppressWildcards Any?>, val parentKey: String, val parentType: String, val cacheHeaders: CacheHeaders, val fieldKeyGenerator: FieldKeyGenerator, val path: List<CompiledField>)
Link copied to clipboard

A provider that returns a max age based on schema coordinates. The given coordinates must be object/interface/union (e.g. MyType) or field (e.g. MyType.myField) coordinates.

Link copied to clipboard

A CacheKeyGenerator that uses annotations to compute the id

Properties

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <D : Operation.Data> Operation<D>.normalize(data: D, customScalarAdapters: CustomScalarAdapters, cacheKeyGenerator: CacheKeyGenerator, metadataGenerator: MetadataGenerator = EmptyMetadataGenerator, fieldKeyGenerator: FieldKeyGenerator = DefaultFieldKeyGenerator, embeddedFieldsProvider: EmbeddedFieldsProvider = DefaultEmbeddedFieldsProvider): Map<String, Record>
fun <D : Executable.Data> Executable<D>.normalize(data: D, customScalarAdapters: CustomScalarAdapters, cacheKeyGenerator: CacheKeyGenerator, metadataGenerator: MetadataGenerator = EmptyMetadataGenerator, fieldKeyGenerator: FieldKeyGenerator = DefaultFieldKeyGenerator, embeddedFieldsProvider: EmbeddedFieldsProvider = DefaultEmbeddedFieldsProvider, rootKey: String): Map<String, Record>
Link copied to clipboard
fun <D : Executable.Data> Executable<D>.readDataFromCache(customScalarAdapters: CustomScalarAdapters, cache: ReadOnlyNormalizedCache, cacheResolver: CacheResolver, cacheHeaders: CacheHeaders, fieldKeyGenerator: FieldKeyGenerator = DefaultFieldKeyGenerator): D
fun <D : Executable.Data> Executable<D>.readDataFromCache(cacheKey: CacheKey, customScalarAdapters: CustomScalarAdapters, cache: ReadOnlyNormalizedCache, cacheResolver: CacheResolver, cacheHeaders: CacheHeaders, fieldKeyGenerator: FieldKeyGenerator = DefaultFieldKeyGenerator): D
Link copied to clipboard
fun <D : Executable.Data> Executable<D>.readDataFromCacheInternal(cacheKey: CacheKey, cache: ReadOnlyNormalizedCache, cacheResolver: CacheResolver, cacheHeaders: CacheHeaders, variables: Executable.Variables, fieldKeyGenerator: FieldKeyGenerator): CacheData
Link copied to clipboard
Link copied to clipboard
fun <D : Executable.Data> CacheData.toData(adapter: Adapter<D>, customScalarAdapters: CustomScalarAdapters, variables: Executable.Variables): D
Link copied to clipboard
fun Record.withDates(receivedDate: String?, expirationDate: String?): Record