CacheKeyResolver

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.

Override cacheKeyForField to compute a cache key for a field of composite type. Override listOfCacheKeysForField to compute a list of cache keys for a field of 'list-of-composite' type.

For simplicity, this only handles one level of lists. Implement CacheResolver if you need arbitrary nested lists of objects.

Inheritors

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
abstract fun cacheKeyForField(context: ResolverContext): CacheKey?

Returns the computed cache key for a composite field.

Link copied to clipboard

For a field that contains a list of objects, listOfCacheKeysForField returns a list of CacheKeys where each CacheKey identifies an object.

Link copied to clipboard
override fun resolveField(context: ResolverContext): Any?

Resolves a field from the cache. Called when reading from the cache, usually before a network request.