@apollo/client
Version:
A fully-featured caching GraphQL client.
81 lines • 2.85 kB
TypeScript
import { DocumentNode, FieldNode } from 'graphql';
import { Transaction } from '../core/cache';
import { StoreObject, StoreValue, Reference } from '../../utilities';
import { FieldValueGetter } from './entityStore';
import { TypePolicies, PossibleTypesMap, KeyFieldsFunction, StorageType, FieldMergeFunction } from './policies';
import { Modifier, Modifiers, ToReferenceFunction, CanReadFunction } from '../core/types/common';
import { FragmentRegistryAPI } from './fragmentRegistry';
export { StoreObject, StoreValue, Reference };
export interface IdGetterObj extends Object {
__typename?: string;
id?: string;
_id?: string;
}
export declare type IdGetter = (value: IdGetterObj) => string | undefined;
export interface NormalizedCache {
has(dataId: string): boolean;
get(dataId: string, fieldName: string): StoreValue;
merge(olderId: string, newerObject: StoreObject): void;
merge(olderObject: StoreObject, newerId: string): void;
modify(dataId: string, fields: Modifiers | Modifier<any>): boolean;
delete(dataId: string, fieldName?: string): boolean;
clear(): void;
toObject(): NormalizedCacheObject;
replace(newData: NormalizedCacheObject): void;
retain(rootId: string): number;
release(rootId: string): number;
getFieldValue: FieldValueGetter;
toReference: ToReferenceFunction;
canRead: CanReadFunction;
getStorage(idOrObj: string | StoreObject, ...storeFieldNames: (string | number)[]): StorageType;
}
export interface NormalizedCacheObject {
__META?: {
extraRootIds: string[];
};
[dataId: string]: StoreObject | undefined;
}
export type OptimisticStoreItem = {
id: string;
data: NormalizedCacheObject;
transaction: Transaction<NormalizedCacheObject>;
};
export type ReadQueryOptions = {
store: NormalizedCache;
query: DocumentNode;
variables?: Object;
previousResult?: any;
canonizeResults?: boolean;
rootId?: string;
config?: ApolloReducerConfig;
};
export type DiffQueryAgainstStoreOptions = ReadQueryOptions & {
returnPartialData?: boolean;
};
export type ApolloReducerConfig = {
dataIdFromObject?: KeyFieldsFunction;
addTypename?: boolean;
};
export interface InMemoryCacheConfig extends ApolloReducerConfig {
resultCaching?: boolean;
possibleTypes?: PossibleTypesMap;
typePolicies?: TypePolicies;
resultCacheMaxSize?: number;
canonizeResults?: boolean;
fragments?: FragmentRegistryAPI;
}
export interface MergeInfo {
field: FieldNode;
typename: string | undefined;
merge: FieldMergeFunction;
}
export interface MergeTree {
info?: MergeInfo;
map: Map<string | number, MergeTree>;
}
export interface ReadMergeModifyContext {
store: NormalizedCache;
variables?: Record<string, any>;
varString?: string;
}
//# sourceMappingURL=types.d.ts.map