UNPKG

2.85 kBTypeScriptView Raw
1import { DocumentNode, FieldNode } from 'graphql';
2import { Transaction } from '../core/cache';
3import { StoreObject, StoreValue, Reference } from '../../utilities';
4import { FieldValueGetter } from './entityStore';
5import { TypePolicies, PossibleTypesMap, KeyFieldsFunction, StorageType, FieldMergeFunction } from './policies';
6import { Modifier, Modifiers, ToReferenceFunction, CanReadFunction } from '../core/types/common';
7import { FragmentRegistryAPI } from './fragmentRegistry';
8export { StoreObject, StoreValue, Reference };
9export interface IdGetterObj extends Object {
10 __typename?: string;
11 id?: string;
12 _id?: string;
13}
14export declare type IdGetter = (value: IdGetterObj) => string | undefined;
15export interface NormalizedCache {
16 has(dataId: string): boolean;
17 get(dataId: string, fieldName: string): StoreValue;
18 merge(olderId: string, newerObject: StoreObject): void;
19 merge(olderObject: StoreObject, newerId: string): void;
20 modify(dataId: string, fields: Modifiers | Modifier<any>): boolean;
21 delete(dataId: string, fieldName?: string): boolean;
22 clear(): void;
23 toObject(): NormalizedCacheObject;
24 replace(newData: NormalizedCacheObject): void;
25 retain(rootId: string): number;
26 release(rootId: string): number;
27 getFieldValue: FieldValueGetter;
28 toReference: ToReferenceFunction;
29 canRead: CanReadFunction;
30 getStorage(idOrObj: string | StoreObject, ...storeFieldNames: (string | number)[]): StorageType;
31}
32export interface NormalizedCacheObject {
33 __META?: {
34 extraRootIds: string[];
35 };
36 [dataId: string]: StoreObject | undefined;
37}
38export type OptimisticStoreItem = {
39 id: string;
40 data: NormalizedCacheObject;
41 transaction: Transaction<NormalizedCacheObject>;
42};
43export type ReadQueryOptions = {
44 store: NormalizedCache;
45 query: DocumentNode;
46 variables?: Object;
47 previousResult?: any;
48 canonizeResults?: boolean;
49 rootId?: string;
50 config?: ApolloReducerConfig;
51};
52export type DiffQueryAgainstStoreOptions = ReadQueryOptions & {
53 returnPartialData?: boolean;
54};
55export type ApolloReducerConfig = {
56 dataIdFromObject?: KeyFieldsFunction;
57 addTypename?: boolean;
58};
59export interface InMemoryCacheConfig extends ApolloReducerConfig {
60 resultCaching?: boolean;
61 possibleTypes?: PossibleTypesMap;
62 typePolicies?: TypePolicies;
63 resultCacheMaxSize?: number;
64 canonizeResults?: boolean;
65 fragments?: FragmentRegistryAPI;
66}
67export interface MergeInfo {
68 field: FieldNode;
69 typename: string | undefined;
70 merge: FieldMergeFunction;
71}
72export interface MergeTree {
73 info?: MergeInfo;
74 map: Map<string | number, MergeTree>;
75}
76export interface ReadMergeModifyContext {
77 store: NormalizedCache;
78 variables?: Record<string, any>;
79 varString?: string;
80}
81//# sourceMappingURL=types.d.ts.map
\No newline at end of file