UNPKG

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