1 | import type { DocumentNode } from "graphql";
|
2 | import type { StoreObject, Reference, DeepPartial } from "../../utilities/index.js";
|
3 | import { Observable } from "../../utilities/index.js";
|
4 | import type { DataProxy } from "./types/DataProxy.js";
|
5 | import type { Cache } from "./types/Cache.js";
|
6 | import { getApolloCacheMemoryInternals } from "../../utilities/caching/getMemoryInternals.js";
|
7 | import type { OperationVariables, TypedDocumentNode } from "../../core/types.js";
|
8 | import type { MissingTree } from "./types/common.js";
|
9 | export type Transaction<T> = (c: ApolloCache<T>) => void;
|
10 |
|
11 |
|
12 |
|
13 | export interface WatchFragmentOptions<TData, TVars> {
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | fragment: DocumentNode | TypedDocumentNode<TData, TVars>;
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | from: StoreObject | Reference | string;
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 | variables?: TVars;
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | fragmentName?: string;
|
45 | |
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | optimistic?: boolean;
|
53 | }
|
54 |
|
55 |
|
56 |
|
57 | export type WatchFragmentResult<TData> = {
|
58 | data: TData;
|
59 | complete: true;
|
60 | missing?: never;
|
61 | } | {
|
62 | data: DeepPartial<TData>;
|
63 | complete: false;
|
64 | missing: MissingTree;
|
65 | };
|
66 | export declare abstract class ApolloCache<TSerialized> implements DataProxy {
|
67 | readonly assumeImmutableResults: boolean;
|
68 | abstract read<TData = any, TVariables = any>(query: Cache.ReadOptions<TVariables, TData>): TData | null;
|
69 | abstract write<TData = any, TVariables = any>(write: Cache.WriteOptions<TData, TVariables>): Reference | undefined;
|
70 | abstract diff<T>(query: Cache.DiffOptions): Cache.DiffResult<T>;
|
71 | abstract watch<TData = any, TVariables = any>(watch: Cache.WatchOptions<TData, TVariables>): () => void;
|
72 | abstract reset(options?: Cache.ResetOptions): Promise<void>;
|
73 | abstract evict(options: Cache.EvictOptions): boolean;
|
74 | |
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | abstract restore(serializedState: TSerialized): ApolloCache<TSerialized>;
|
82 | |
83 |
|
84 |
|
85 | abstract extract(optimistic?: boolean): TSerialized;
|
86 | abstract removeOptimistic(id: string): void;
|
87 | batch<U>(options: Cache.BatchOptions<this, U>): U;
|
88 | abstract performTransaction(transaction: Transaction<TSerialized>, optimisticId?: string | null): void;
|
89 | recordOptimisticTransaction(transaction: Transaction<TSerialized>, optimisticId: string): void;
|
90 | transformDocument(document: DocumentNode): DocumentNode;
|
91 | transformForLink(document: DocumentNode): DocumentNode;
|
92 | identify(object: StoreObject | Reference): string | undefined;
|
93 | gc(): string[];
|
94 | modify<Entity extends Record<string, any> = Record<string, any>>(options: Cache.ModifyOptions<Entity>): boolean;
|
95 | readQuery<QueryType, TVariables = any>(options: Cache.ReadQueryOptions<QueryType, TVariables>, optimistic?: boolean): QueryType | null;
|
96 | |
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | watchFragment<TData = any, TVars = OperationVariables>(options: WatchFragmentOptions<TData, TVars>): Observable<WatchFragmentResult<TData>>;
|
108 | private getFragmentDoc;
|
109 | readFragment<FragmentType, TVariables = any>(options: Cache.ReadFragmentOptions<FragmentType, TVariables>, optimistic?: boolean): FragmentType | null;
|
110 | writeQuery<TData = any, TVariables = any>({ id, data, ...options }: Cache.WriteQueryOptions<TData, TVariables>): Reference | undefined;
|
111 | writeFragment<TData = any, TVariables = any>({ id, data, fragment, fragmentName, ...options }: Cache.WriteFragmentOptions<TData, TVariables>): Reference | undefined;
|
112 | updateQuery<TData = any, TVariables = any>(options: Cache.UpdateQueryOptions<TData, TVariables>, update: (data: TData | null) => TData | null | void): TData | null;
|
113 | updateFragment<TData = any, TVariables = any>(options: Cache.UpdateFragmentOptions<TData, TVariables>, update: (data: TData | null) => TData | null | void): TData | null;
|
114 | /**
|
115 | * @experimental
|
116 | * @internal
|
117 | * This is not a stable API - it is used in development builds to expose
|
118 | * information to the DevTools.
|
119 | * Use at your own risk!
|
120 | */
|
121 | getMemoryInternals?: typeof getApolloCacheMemoryInternals;
|
122 | }
|
123 | //# sourceMappingURL=cache.d.ts.map |
\ | No newline at end of file |