UNPKG

2.15 kBTypeScriptView Raw
1import './fixPolyfills';
2import { DocumentNode } from 'graphql';
3import { Cache, ApolloCache, Transaction } from 'apollo-cache';
4import { ApolloReducerConfig, NormalizedCache, NormalizedCacheObject } from './types';
5import { ObjectCache } from './objectCache';
6export interface InMemoryCacheConfig extends ApolloReducerConfig {
7 resultCaching?: boolean;
8 freezeResults?: boolean;
9}
10export declare function defaultDataIdFromObject(result: any): string | null;
11export declare class OptimisticCacheLayer extends ObjectCache {
12 readonly optimisticId: string;
13 readonly parent: NormalizedCache;
14 readonly transaction: Transaction<NormalizedCacheObject>;
15 constructor(optimisticId: string, parent: NormalizedCache, transaction: Transaction<NormalizedCacheObject>);
16 toObject(): NormalizedCacheObject;
17 get(dataId: string): import("./types").StoreObject;
18}
19export declare class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
20 private data;
21 private optimisticData;
22 protected config: InMemoryCacheConfig;
23 private watches;
24 private addTypename;
25 private typenameDocumentCache;
26 private storeReader;
27 private storeWriter;
28 private cacheKeyRoot;
29 private silenceBroadcast;
30 constructor(config?: InMemoryCacheConfig);
31 restore(data: NormalizedCacheObject): this;
32 extract(optimistic?: boolean): NormalizedCacheObject;
33 read<T>(options: Cache.ReadOptions): T | null;
34 write(write: Cache.WriteOptions): void;
35 diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;
36 watch(watch: Cache.WatchOptions): () => void;
37 evict(query: Cache.EvictOptions): Cache.EvictionResult;
38 reset(): Promise<void>;
39 removeOptimistic(idToRemove: string): void;
40 performTransaction(transaction: Transaction<NormalizedCacheObject>, optimisticId?: string): void;
41 recordOptimisticTransaction(transaction: Transaction<NormalizedCacheObject>, id: string): void;
42 transformDocument(document: DocumentNode): DocumentNode;
43 protected broadcastWatches(): void;
44 private maybeBroadcastWatch;
45}
46//# sourceMappingURL=inMemoryCache.d.ts.map
\No newline at end of file