UNPKG

2.58 kBTypeScriptView Raw
1import { DocumentNode } from 'graphql';
2import { StoreObject, Reference } from '../../utilities';
3import { DataProxy } from './types/DataProxy';
4import { Cache } from './types/Cache';
5export declare type Transaction<T> = (c: ApolloCache<T>) => void;
6export declare abstract class ApolloCache<TSerialized> implements DataProxy {
7 abstract read<TData = any, TVariables = any>(query: Cache.ReadOptions<TVariables, TData>): TData | null;
8 abstract write<TData = any, TVariables = any>(write: Cache.WriteOptions<TData, TVariables>): Reference | undefined;
9 abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;
10 abstract watch<TData = any, TVariables = any>(watch: Cache.WatchOptions<TData, TVariables>): () => void;
11 abstract reset(options?: Cache.ResetOptions): Promise<void>;
12 abstract evict(options: Cache.EvictOptions): boolean;
13 abstract restore(serializedState: TSerialized): ApolloCache<TSerialized>;
14 abstract extract(optimistic?: boolean): TSerialized;
15 abstract removeOptimistic(id: string): void;
16 batch<U>(options: Cache.BatchOptions<this, U>): U;
17 abstract performTransaction(transaction: Transaction<TSerialized>, optimisticId?: string | null): void;
18 recordOptimisticTransaction(transaction: Transaction<TSerialized>, optimisticId: string): void;
19 transformDocument(document: DocumentNode): DocumentNode;
20 transformForLink(document: DocumentNode): DocumentNode;
21 identify(object: StoreObject | Reference): string | undefined;
22 gc(): string[];
23 modify(options: Cache.ModifyOptions): boolean;
24 readQuery<QueryType, TVariables = any>(options: Cache.ReadQueryOptions<QueryType, TVariables>, optimistic?: boolean): QueryType | null;
25 private getFragmentDoc;
26 readFragment<FragmentType, TVariables = any>(options: Cache.ReadFragmentOptions<FragmentType, TVariables>, optimistic?: boolean): FragmentType | null;
27 writeQuery<TData = any, TVariables = any>({ id, data, ...options }: Cache.WriteQueryOptions<TData, TVariables>): Reference | undefined;
28 writeFragment<TData = any, TVariables = any>({ id, data, fragment, fragmentName, ...options }: Cache.WriteFragmentOptions<TData, TVariables>): Reference | undefined;
29 updateQuery<TData = any, TVariables = any>(options: Cache.UpdateQueryOptions<TData, TVariables>, update: (data: TData | null) => TData | null | void): TData | null;
30 updateFragment<TData = any, TVariables = any>(options: Cache.UpdateFragmentOptions<TData, TVariables>, update: (data: TData | null) => TData | null | void): TData | null;
31}
32//# sourceMappingURL=cache.d.ts.map
\No newline at end of file