@apollo/client 4.1.0-alpha.7 → 4.1.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/__cjs/cache/core/cache.cjs +64 -24
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +47 -0
- package/__cjs/cache/core/types/Cache.d.cts +38 -0
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +47 -0
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +47 -0
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +14 -5
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +5 -0
- package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +1 -0
- package/__cjs/cache/inmemory/writeToStore.cjs +6 -5
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +2 -1
- package/__cjs/core/ApolloClient.cjs +14 -14
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +21 -1
- package/__cjs/core/ObservableQuery.cjs +22 -8
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +1 -0
- package/__cjs/core/QueryInfo.cjs +3 -0
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryManager.cjs +27 -17
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +18 -2
- package/__cjs/invariantErrorCodes.cjs +39 -33
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +13 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +1 -1
- package/__cjs/link/error/index.cjs +1 -1
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +1 -0
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.cjs +7 -4
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs +2 -0
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/utilities/internal/checkDocument.cjs +2 -4
- package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.cjs +21 -0
- package/__cjs/utilities/internal/constants.cjs.map +1 -0
- package/__cjs/utilities/internal/constants.d.cts +18 -0
- package/__cjs/utilities/internal/index.cjs +6 -1
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +2 -0
- package/__cjs/utilities/internal/mapObservableFragment.cjs +27 -0
- package/__cjs/utilities/internal/mapObservableFragment.cjs.map +1 -0
- package/__cjs/utilities/internal/mapObservableFragment.d.cts +3 -0
- package/__cjs/utilities/internal/memoize.cjs +31 -0
- package/__cjs/utilities/internal/memoize.cjs.map +1 -0
- package/__cjs/utilities/internal/memoize.d.cts +8 -0
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +47 -0
- package/cache/core/cache.js +65 -25
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +38 -0
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +47 -0
- package/cache/inmemory/inMemoryCache.js +47 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.d.ts +5 -0
- package/cache/inmemory/policies.js +14 -5
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +3 -3
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +1 -0
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +2 -1
- package/cache/inmemory/writeToStore.js +6 -5
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +21 -1
- package/core/ApolloClient.js +15 -15
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +1 -0
- package/core/ObservableQuery.js +23 -9
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js +3 -0
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +18 -2
- package/core/QueryManager.js +28 -18
- package/core/QueryManager.js.map +1 -1
- package/invariantErrorCodes.js +39 -33
- package/link/client-awareness/ClientAwarenessLink.d.ts +1 -1
- package/link/client-awareness/ClientAwarenessLink.js +13 -1
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
- package/link/error/index.d.ts +1 -1
- package/link/error/index.js +1 -1
- package/link/error/index.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/useLazyQuery.js +2 -1
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useQuery.js +8 -5
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +2 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.js +2 -1
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.js +9 -5
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.js +3 -1
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/utilities/internal/checkDocument.js +2 -4
- package/utilities/internal/checkDocument.js.map +1 -1
- package/utilities/internal/constants.d.ts +18 -0
- package/utilities/internal/constants.js +18 -0
- package/utilities/internal/constants.js.map +1 -0
- package/utilities/internal/index.d.ts +2 -0
- package/utilities/internal/index.js +2 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/mapObservableFragment.d.ts +3 -0
- package/utilities/internal/mapObservableFragment.js +24 -0
- package/utilities/internal/mapObservableFragment.js.map +1 -0
- package/utilities/internal/memoize.d.ts +8 -0
- package/utilities/internal/memoize.js +28 -0
- package/utilities/internal/memoize.js.map +1 -0
- package/version.js +1 -1
|
@@ -50,6 +50,11 @@ export declare namespace Cache {
|
|
|
50
50
|
* @defaultValue false
|
|
51
51
|
*/
|
|
52
52
|
overwrite?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* GraphQL extensions for the write operation. Any provided `extensions`
|
|
55
|
+
* are available in `merge` functions.
|
|
56
|
+
*/
|
|
57
|
+
extensions?: Record<string, unknown>;
|
|
53
58
|
}
|
|
54
59
|
interface DiffOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends Omit<ReadOptions<TData, TVariables>, "rootId"> {
|
|
55
60
|
}
|
|
@@ -75,9 +80,37 @@ export declare namespace Cache {
|
|
|
75
80
|
broadcast?: boolean;
|
|
76
81
|
}
|
|
77
82
|
interface BatchOptions<TCache extends ApolloCache, TUpdateResult = void> {
|
|
83
|
+
/**
|
|
84
|
+
* A function that performs cache operations. Receives the cache instance as its argument.
|
|
85
|
+
*
|
|
86
|
+
* The return value of this function becomes the return value of `batch`.
|
|
87
|
+
*/
|
|
78
88
|
update(cache: TCache): TUpdateResult;
|
|
89
|
+
/**
|
|
90
|
+
* Controls how optimistic data is handled:
|
|
91
|
+
*
|
|
92
|
+
* - `string`: Creates a new optimistic layer with this ID. Use `removeOptimistic` later to remove it.
|
|
93
|
+
* - `true`: Updates the current top layer of the cache (including any optimistic data).
|
|
94
|
+
* - `false`: Updates only the root (non-optimistic) cache data.
|
|
95
|
+
*
|
|
96
|
+
* @defaultValue false
|
|
97
|
+
*/
|
|
79
98
|
optimistic?: string | boolean;
|
|
99
|
+
/**
|
|
100
|
+
* If provided, removes the optimistic layer with this ID after the batch completes.
|
|
101
|
+
*
|
|
102
|
+
* This is useful for atomically applying server data while removing a pending optimistic update, triggering at most one broadcast for both operations.
|
|
103
|
+
*
|
|
104
|
+
* Note: this option is needed because calling `cache.removeOptimistic` during the transaction function may not be safe, since any modifications to cache layers may be discarded after the transaction finishes.
|
|
105
|
+
*/
|
|
80
106
|
removeOptimistic?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Optional callback invoked for each watcher affected by the batch operation.
|
|
109
|
+
*
|
|
110
|
+
* Receives the watch options, the new diff result, and optionally the previous diff result.
|
|
111
|
+
*
|
|
112
|
+
* Return `false` to prevent broadcasting to that specific watcher.
|
|
113
|
+
*/
|
|
81
114
|
onWatchUpdated?: (this: TCache, watch: Cache.WatchOptions, diff: Cache.DiffResult<any>, lastDiff?: Cache.DiffResult<any> | undefined) => any;
|
|
82
115
|
}
|
|
83
116
|
interface ReadQueryOptions<TData, TVariables extends OperationVariables> {
|
|
@@ -174,6 +207,11 @@ export declare namespace Cache {
|
|
|
174
207
|
* @defaultValue false
|
|
175
208
|
*/
|
|
176
209
|
overwrite?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* GraphQL extensions for the write operation. Any provided `extensions`
|
|
212
|
+
* are available in `merge` functions.
|
|
213
|
+
*/
|
|
214
|
+
extensions?: Record<string, unknown>;
|
|
177
215
|
}
|
|
178
216
|
type WriteFragmentOptions<TData, TVariables extends OperationVariables> = {
|
|
179
217
|
/**
|
|
@@ -82,7 +82,7 @@ class EntityStore {
|
|
|
82
82
|
// then there are no fields to be merged, so we're done.
|
|
83
83
|
if (!incoming)
|
|
84
84
|
return;
|
|
85
|
-
(0, invariant_1.invariant)(typeof dataId === "string",
|
|
85
|
+
(0, invariant_1.invariant)(typeof dataId === "string", 99);
|
|
86
86
|
const merged = new internal_1.DeepMerger({
|
|
87
87
|
reconciler: storeObjectReconciler,
|
|
88
88
|
}).merge(existing, incoming);
|
|
@@ -184,7 +184,7 @@ class EntityStore {
|
|
|
184
184
|
if (environment_1.__DEV__) {
|
|
185
185
|
const checkReference = (ref) => {
|
|
186
186
|
if (this.lookup(ref.__ref) === undefined) {
|
|
187
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
187
|
+
__DEV__ && invariant_1.invariant.warn(100, ref);
|
|
188
188
|
return true;
|
|
189
189
|
}
|
|
190
190
|
};
|
|
@@ -213,7 +213,7 @@ class EntityStore {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
if (seenReference && someNonReference !== undefined) {
|
|
216
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
216
|
+
__DEV__ && invariant_1.invariant.warn(101, someNonReference);
|
|
217
217
|
break;
|
|
218
218
|
}
|
|
219
219
|
}
|