Docs
API
Interfaces
ResponseCacheConfig

Interface: ResponseCacheConfig

types/src.YamlConfig.ResponseCacheConfig

Table of contents

Properties

Properties

cacheKey

Optional cacheKey: string

Customize the behavior how the response cache key is computed from the documentString, variableValues, contextValue and sessionId. If the given string is interpolated as empty, default behavior is used. Example;

# Cache by specific value
cacheKey: "{variableValues.userId}"

# Cache by documentString
cacheKey: "{documentString}"

# Cache by operationName
cacheKey: "{operationName}"

# Cache by some header value
cacheKey: "{contextValue.headers.authorization}"

# Or combine two of each
cacheKey: "{contextValue.headers.authorization}-{operationName}"

Defined in

packages/types/src/config.ts:1977


idFields

Optional idFields: string[]

List of fields that are used to identify the entity.

Defined in

packages/types/src/config.ts:1929


if

Optional if: string

Specify whether the cache should be used based on the context.

if: "context.headers.userId != null"

Defined in

packages/types/src/config.ts:1955


ignoredTypes

Optional ignoredTypes: string[]

Skip caching of following the types.

Defined in

packages/types/src/config.ts:1925


includeExtensionMetadata

Optional includeExtensionMetadata: boolean

Include extension values that provide useful information, such as whether the cache was hit or which resources a mutation invalidated.

Defined in

packages/types/src/config.ts:1938


invalidateViaMutation

Optional invalidateViaMutation: boolean

Whether the mutation execution result should be used for invalidating resources. Defaults to true

Defined in

packages/types/src/config.ts:1934


sessionId

Optional sessionId: string

Allows to cache responses based on the resolved session id. Return a unique value for each session. Creates a global session by default. Example;

sessionId: "{context.headers.userId}"

Defined in

packages/types/src/config.ts:1948


shouldCacheResult

Optional shouldCacheResult: string

Checks if the result should be cached.

shouldCacheResult: "result.errors.length > 0"

Defined in

packages/types/src/config.ts:1984


ttl

Optional ttl: number

Maximum age in ms. Defaults to Infinity. Set it to 0 for disabling the global TTL.

Defined in

packages/types/src/config.ts:1916


ttlPerCoordinate

Optional ttlPerCoordinate: ResponseCacheTTLConfig[]

Overwrite the ttl for query operations whose selection contains a specific schema coordinate (e.g. Query.users). Useful if the selection of a specific field should reduce the TTL of the query operation.

Defined in

packages/types/src/config.ts:1921