KeyArgumentsCacheResolver

A cache resolver that uses a KeyArgumentsProvider to resolve fields and delegates to DefaultCacheResolver otherwise.

Note: using a CacheKey.Scope.TYPE keyScope namespaces the ids with the schema type, which will lead to cache misses for:

  • unions

  • interfaces that have a @typePolicy on subtypes.

If the ids are unique across the whole service, use CacheKey.Scope.SERVICE. Otherwise there is no way to resolve the cache keys automatically for those cases.

Parameters

keyArgumentsProvider

provides the key arguments for a given field

keyScope

the scope of the computed cache keys. Use CacheKey.Scope.TYPE to namespace the keys by the schema type name, or CacheKey.Scope.SERVICE if the ids are unique across the whole service.

Constructors

Link copied to clipboard
constructor(keyArgumentsProvider: KeyArgumentsProvider, keyScope: CacheKey.Scope)

Functions

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

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