UNPKG

2.6 kBTypeScriptView Raw
1import { DocumentNode } from 'graphql';
2import { FragmentMatcher } from './readFromStore';
3import { Transaction } from 'apollo-cache';
4import { IdValue, StoreValue } from 'apollo-utilities';
5export interface IdGetterObj extends Object {
6 __typename?: string;
7 id?: string;
8}
9export declare type IdGetter = (value: IdGetterObj) => string | null | undefined;
10export interface NormalizedCache {
11 get(dataId: string): StoreObject;
12 set(dataId: string, value: StoreObject): void;
13 delete(dataId: string): void;
14 clear(): void;
15 toObject(): NormalizedCacheObject;
16 replace(newData: NormalizedCacheObject): void;
17}
18export interface NormalizedCacheObject {
19 [dataId: string]: StoreObject | undefined;
20}
21export interface StoreObject {
22 __typename?: string;
23 [storeFieldKey: string]: StoreValue;
24}
25export declare type OptimisticStoreItem = {
26 id: string;
27 data: NormalizedCacheObject;
28 transaction: Transaction<NormalizedCacheObject>;
29};
30export declare type ReadQueryOptions = {
31 store: NormalizedCache;
32 query: DocumentNode;
33 fragmentMatcherFunction?: FragmentMatcher;
34 variables?: Object;
35 previousResult?: any;
36 rootId?: string;
37 config?: ApolloReducerConfig;
38};
39export declare type DiffQueryAgainstStoreOptions = ReadQueryOptions & {
40 returnPartialData?: boolean;
41};
42export declare type ApolloReducerConfig = {
43 dataIdFromObject?: IdGetter;
44 fragmentMatcher?: FragmentMatcherInterface;
45 addTypename?: boolean;
46 cacheRedirects?: CacheResolverMap;
47};
48export declare type ReadStoreContext = {
49 readonly store: NormalizedCache;
50 readonly cacheRedirects: CacheResolverMap;
51 readonly dataIdFromObject?: IdGetter;
52};
53export interface FragmentMatcherInterface {
54 match(idValue: IdValue, typeCondition: string, context: ReadStoreContext): boolean | 'heuristic';
55}
56export declare type PossibleTypesMap = {
57 [key: string]: string[];
58};
59export declare type IntrospectionResultData = {
60 __schema: {
61 types: {
62 kind: string;
63 name: string;
64 possibleTypes: {
65 name: string;
66 }[];
67 }[];
68 };
69};
70export declare type CacheResolver = (rootValue: any, args: {
71 [argName: string]: any;
72}, context: any) => any;
73export declare type CacheResolverMap = {
74 [typeName: string]: {
75 [fieldName: string]: CacheResolver;
76 };
77};
78export declare type CustomResolver = CacheResolver;
79export declare type CustomResolverMap = CacheResolverMap;
80//# sourceMappingURL=types.d.ts.map
\No newline at end of file