UNPKG

graphql-norm-stale

Version:

Staleness tracking for normalized GraphQL responses

24 lines (23 loc) 960 B
import { NormMap, FieldsMap, NormKey, NormObj } from "graphql-norm"; export declare type Patch = InvalidateEntity | InvalidateField; export interface InvalidateEntity { readonly type: "InvalidateEntity"; readonly id: string; readonly recursive: boolean; } export interface InvalidateField { readonly type: "InvalidateField"; readonly id: string; readonly fieldName: string; readonly recursive: boolean; readonly fieldArguments: {} | undefined; } /** * Makes an entity stale in the cache */ export declare function invalidateEntity(id: NormKey, recursive: boolean): InvalidateEntity; /** * Makes a field stale in the cache */ export declare function invalidateField<T = NormObj, A extends {} = {}>(id: NormKey, fieldName: Extract<keyof T, string>, recursive: boolean, fieldArguments?: A): InvalidateField; export declare function applyPatches(patches: ReadonlyArray<Patch>, cache: NormMap, staleMap: FieldsMap): FieldsMap;