IdCacheKeyResolver

class IdCacheKeyResolver(idFields: List<String> = listOf("id"), idListFields: List<String> = listOf("ids")) : CacheKeyResolver

A simple CacheKeyResolver that uses the id/ids argument, if present, to compute the cache key. The name of the id arguments can be provided (by default "id" for objects and "ids" for lists). If several names are provided, the first present one is used. Only one level of list is supported - implement CacheResolver if you need arbitrary nested lists of objects.

Parameters

idFields

possible names of the argument containing the id for objects

idListFields

possible names of the argument containing the ids for lists

See also

Constructors

Link copied to clipboard
constructor(idFields: List<String> = listOf("id"), idListFields: List<String> = listOf("ids"))

Functions

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

Returns the computed cache key for a composite field.

Link copied to clipboard
open override fun listOfCacheKeysForField(context: ResolverContext): List<CacheKey?>?

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.