@apollo/client 4.3.0-alpha.3 → 4.3.0-alpha.5
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 +120 -0
- package/README.md +3 -7
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +5 -1
- package/__cjs/cache/core/types/Cache.d.cts +25 -0
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +6 -3
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/readFromStore.cjs +477 -49
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.d.cts +11 -2
- package/__cjs/cache/inmemory/types.d.cts +10 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +5 -9
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/core/ApolloClient.cjs +21 -22
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +44 -10
- package/__cjs/core/ObservableQuery.cjs +46 -5
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +12 -1
- package/__cjs/core/QueryInfo.cjs +206 -269
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +20 -4
- package/__cjs/core/QueryManager.cjs +52 -28
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/RefetchEventManager.cjs +3 -3
- package/__cjs/core/dataStateErrorCache.cjs +12 -0
- package/__cjs/core/dataStateErrorCache.cjs.map +1 -0
- package/__cjs/core/dataStateErrorCache.d.cts +3 -0
- package/__cjs/core/types.d.cts +2 -0
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +2 -4
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +46 -15
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +29 -6
- package/__cjs/incremental/types.d.cts +55 -4
- package/__cjs/invariantErrorCodes.cjs +50 -31
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +100 -47
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +26 -20
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +23 -15
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +10 -7
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +74 -32
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +83 -34
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/types.d.cts +14 -3
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +20 -5
- package/__cjs/testing/core/mocking/mockLink.cjs +21 -1
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +1 -2
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +39 -1
- package/__cjs/utilities/internal/StreamArrayState.cjs +27 -0
- package/__cjs/utilities/internal/StreamArrayState.cjs.map +1 -0
- package/__cjs/utilities/internal/StreamArrayState.d.cts +12 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.cjs +33 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.cjs.map +1 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.d.cts +3 -0
- package/__cjs/utilities/internal/constants.cjs +20 -1
- package/__cjs/utilities/internal/constants.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.d.cts +19 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.cjs +19 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.cjs.map +1 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.d.cts +9 -0
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs +1 -1
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.cjs +6 -0
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.d.cts +4 -0
- package/__cjs/utilities/internal/index.cjs +13 -4
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +7 -3
- package/__cjs/utilities/internal/isDeferredFragment.cjs +19 -4
- package/__cjs/utilities/internal/isDeferredFragment.cjs.map +1 -1
- package/__cjs/utilities/internal/isDeferredFragment.d.cts +6 -1
- package/__cjs/utilities/internal/isStreamField.cjs +37 -0
- package/__cjs/utilities/internal/isStreamField.cjs.map +1 -0
- package/__cjs/utilities/internal/isStreamField.d.cts +9 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.cjs +17 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.cjs.map +1 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.d.cts +8 -0
- package/__cjs/utilities/internal/types/DeferInfo.cjs +3 -0
- package/__cjs/utilities/internal/types/DeferInfo.cjs.map +1 -0
- package/__cjs/utilities/internal/types/DeferInfo.d.cts +10 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.d.cts +2 -0
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +5 -1
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +25 -0
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/index.d.ts +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/inMemoryCache.d.ts +6 -3
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/readFromStore.d.ts +11 -2
- package/cache/inmemory/readFromStore.js +478 -50
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +11 -2
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.js +6 -10
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +44 -10
- package/core/ApolloClient.js +21 -22
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +12 -1
- package/core/ObservableQuery.js +46 -5
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +20 -4
- package/core/QueryInfo.js +202 -269
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +52 -28
- package/core/QueryManager.js.map +1 -1
- package/core/RefetchEventManager.js +3 -3
- package/core/dataStateErrorCache.d.ts +3 -0
- package/core/dataStateErrorCache.js +9 -0
- package/core/dataStateErrorCache.js.map +1 -0
- package/core/types.d.ts +2 -0
- package/core/types.js.map +1 -1
- package/incremental/handlers/defer20220824.d.ts +2 -4
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.d.ts +29 -6
- package/incremental/handlers/graphql17Alpha9.js +47 -16
- package/incremental/handlers/graphql17Alpha9.js.map +1 -1
- package/incremental/types.d.ts +55 -4
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +50 -31
- package/package.json +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +100 -47
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +26 -20
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +23 -15
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +10 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +74 -32
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +83 -34
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +100 -47
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +26 -20
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +23 -15
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +10 -7
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +74 -32
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +83 -34
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/types.d.ts +15 -4
- package/react/internal/types.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +20 -5
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +1 -2
- package/testing/core/mocking/mockLink.js +21 -1
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/utilities/caching/sizes.d.ts +39 -1
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/internal/StreamArrayState.d.ts +12 -0
- package/utilities/internal/StreamArrayState.js +23 -0
- package/utilities/internal/StreamArrayState.js.map +1 -0
- package/utilities/internal/addDeferFragmentLabels.d.ts +3 -0
- package/utilities/internal/addDeferFragmentLabels.js +30 -0
- package/utilities/internal/addDeferFragmentLabels.js.map +1 -0
- package/utilities/internal/constants.d.ts +19 -0
- package/utilities/internal/constants.js +19 -0
- package/utilities/internal/constants.js.map +1 -1
- package/utilities/internal/getDirectiveArgValue.d.ts +9 -0
- package/utilities/internal/getDirectiveArgValue.js +16 -0
- package/utilities/internal/getDirectiveArgValue.js.map +1 -0
- package/utilities/internal/getFragmentFromSelection.js +1 -1
- package/utilities/internal/getFragmentFromSelection.js.map +1 -1
- package/utilities/internal/getMemoryInternals.d.ts +4 -0
- package/utilities/internal/getMemoryInternals.js +6 -0
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/index.d.ts +7 -3
- package/utilities/internal/index.js +6 -2
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/isDeferredFragment.d.ts +7 -2
- package/utilities/internal/isDeferredFragment.js +19 -4
- package/utilities/internal/isDeferredFragment.js.map +1 -1
- package/utilities/internal/isStreamField.d.ts +9 -0
- package/utilities/internal/isStreamField.js +34 -0
- package/utilities/internal/isStreamField.js.map +1 -0
- package/utilities/internal/makeStreamInfoTrie.d.ts +8 -0
- package/utilities/internal/makeStreamInfoTrie.js +14 -0
- package/utilities/internal/makeStreamInfoTrie.js.map +1 -0
- package/utilities/internal/types/DeferInfo.d.ts +10 -0
- package/utilities/internal/types/DeferInfo.js +2 -0
- package/utilities/internal/types/DeferInfo.js.map +1 -0
- package/utilities/internal/types/StreamInfoTrie.d.ts +2 -0
- package/utilities/internal/types/StreamInfoTrie.js.map +1 -1
- package/version.js +1 -1
- package/__cjs/utilities/internal/collectSiblingFields.cjs +0 -61
- package/__cjs/utilities/internal/collectSiblingFields.cjs.map +0 -1
- package/__cjs/utilities/internal/collectSiblingFields.d.cts +0 -21
- package/utilities/internal/collectSiblingFields.d.ts +0 -21
- package/utilities/internal/collectSiblingFields.js +0 -58
- package/utilities/internal/collectSiblingFields.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { DocumentNode, FormattedExecutionResult } from "graphql";
|
|
2
2
|
import type { Cache } from "@apollo/client/cache";
|
|
3
|
+
import type { Incremental } from "@apollo/client/incremental";
|
|
3
4
|
import type { ApolloLink } from "@apollo/client/link";
|
|
4
5
|
import type { Unmasked } from "@apollo/client/masking";
|
|
5
6
|
import type { ExtensionsWithStreamInfo } from "@apollo/client/utilities/internal";
|
|
6
7
|
import type { ApolloClient } from "./ApolloClient.cjs";
|
|
8
|
+
import { NetworkStatus } from "./networkStatus.cjs";
|
|
7
9
|
import type { ObservableQuery } from "./ObservableQuery.cjs";
|
|
8
10
|
import type { QueryManager } from "./QueryManager.cjs";
|
|
9
11
|
import type { DataValue, DefaultContext, InternalRefetchQueriesInclude, MutationUpdaterFunction, NormalizedExecutionResult, OnQueryUpdated, OperationVariables, TypedDocumentNode } from "./types.cjs";
|
|
10
|
-
import type { ErrorPolicy } from "./watchQueryOptions.cjs";
|
|
12
|
+
import type { ErrorPolicy, WatchQueryFetchPolicy } from "./watchQueryOptions.cjs";
|
|
11
13
|
type UpdateQueries<TData> = ApolloClient.MutateOptions<TData, any, any>["updateQueries"];
|
|
12
14
|
export declare const enum CacheWriteBehavior {
|
|
13
15
|
FORBID = 0,
|
|
@@ -18,6 +20,7 @@ interface LastWrite {
|
|
|
18
20
|
result: FormattedExecutionResult<any, ExtensionsWithStreamInfo>;
|
|
19
21
|
variables: ApolloClient.WatchQueryOptions["variables"];
|
|
20
22
|
dmCount: number | undefined;
|
|
23
|
+
hasNext: boolean;
|
|
21
24
|
}
|
|
22
25
|
interface OperationInfo<TData, TVariables extends OperationVariables, AllowedCacheWriteBehavior = CacheWriteBehavior> {
|
|
23
26
|
document: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
|
@@ -38,8 +41,14 @@ export declare class QueryInfo<TData, TVariables extends OperationVariables = Op
|
|
|
38
41
|
constructor(queryManager: QueryManager, observableQuery?: ObservableQuery<any, any>);
|
|
39
42
|
/**
|
|
40
43
|
* @internal
|
|
41
|
-
*
|
|
42
|
-
*
|
|
44
|
+
* Tracks the last result written to the cache so that `shouldWrite` can skip
|
|
45
|
+
* an identical write. Since a `QueryInfo` only ever represents a single
|
|
46
|
+
* network request, this is shared by all `QueryInfo` instances of an
|
|
47
|
+
* `ObservableQuery`. A standalone `QueryInfo` keeps a local version.
|
|
48
|
+
*
|
|
49
|
+
* A network result that was explicitly asked for always takes precedence over
|
|
50
|
+
* what is already cached, so `ObservableQuery.refetch` and polling clear this
|
|
51
|
+
* value before starting their request.
|
|
43
52
|
*
|
|
44
53
|
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
45
54
|
*/
|
|
@@ -49,8 +58,15 @@ export declare class QueryInfo<TData, TVariables extends OperationVariables = Op
|
|
|
49
58
|
resetLastWrite(): void;
|
|
50
59
|
private shouldWrite;
|
|
51
60
|
get hasNext(): boolean;
|
|
61
|
+
get incrementalHandler(): Incremental.Handler<Record<string, unknown>>;
|
|
52
62
|
private maybeHandleIncrementalResult;
|
|
53
|
-
markQueryResult(incoming: ApolloLink.Result<TData>, { document: query, variables, errorPolicy, cacheWriteBehavior, returnPartialData, }: OperationInfo<TData, TVariables>
|
|
63
|
+
markQueryResult(incoming: ApolloLink.Result<TData>, { document: query, variables, errorPolicy, cacheWriteBehavior, returnPartialData, fetchPolicy, networkStatus, prunePendingDeferFragments: prune, }: OperationInfo<TData, TVariables> & {
|
|
64
|
+
fetchPolicy: WatchQueryFetchPolicy;
|
|
65
|
+
networkStatus: NetworkStatus;
|
|
66
|
+
prunePendingDeferFragments: boolean;
|
|
67
|
+
}): MarkQueryResult<DataValue.Complete<TData> | DataValue.Streaming<TData>, ExtensionsWithStreamInfo>;
|
|
68
|
+
private getIncrementalInfo;
|
|
69
|
+
private getDiff;
|
|
54
70
|
markMutationResult(incoming: ApolloLink.Result<TData>, mutation: OperationInfo<TData, TVariables, CacheWriteBehavior.FORBID | CacheWriteBehavior.MERGE> & {
|
|
55
71
|
context?: DefaultContext;
|
|
56
72
|
updateQueries: UpdateQueries<TData>;
|
|
@@ -18,6 +18,7 @@ const utilities_1 = require("@apollo/client/utilities");
|
|
|
18
18
|
const environment_1 = require("@apollo/client/utilities/environment");
|
|
19
19
|
const internal_1 = require("@apollo/client/utilities/internal");
|
|
20
20
|
const invariant_1 = require("@apollo/client/utilities/invariant");
|
|
21
|
+
const dataStateErrorCache_js_1 = require("./dataStateErrorCache.cjs");
|
|
21
22
|
const networkStatus_js_1 = require("./networkStatus.cjs");
|
|
22
23
|
const ObservableQuery_js_1 = require("./ObservableQuery.cjs");
|
|
23
24
|
const QueryInfo_js_1 = require("./QueryInfo.cjs");
|
|
@@ -82,6 +83,12 @@ class QueryManager {
|
|
|
82
83
|
// selections and fragments from the fragment registry.
|
|
83
84
|
.concat(defaultDocumentTransform)
|
|
84
85
|
: defaultDocumentTransform;
|
|
86
|
+
// Put the incremental transform last so custom document transforms don't
|
|
87
|
+
// revert changes made to the document accidentally. Adding last also
|
|
88
|
+
// ensures `@defer` fragments added by the fragment registry are labeled.
|
|
89
|
+
if (this.incrementalHandler.documentTransform) {
|
|
90
|
+
this.documentTransform = this.documentTransform.concat(this.incrementalHandler.documentTransform);
|
|
91
|
+
}
|
|
85
92
|
this.defaultContext = options.defaultContext || {};
|
|
86
93
|
if ((this.onBroadcast = options.onBroadcast)) {
|
|
87
94
|
this.mutationStore = {};
|
|
@@ -99,7 +106,7 @@ class QueryManager {
|
|
|
99
106
|
*/
|
|
100
107
|
stop() {
|
|
101
108
|
this.obsQueries.forEach((oq) => oq.stop());
|
|
102
|
-
this.cancelPendingFetches((0, invariant_1.newInvariantError)(
|
|
109
|
+
this.cancelPendingFetches((0, invariant_1.newInvariantError)(90));
|
|
103
110
|
}
|
|
104
111
|
cancelPendingFetches(error) {
|
|
105
112
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
@@ -114,7 +121,7 @@ class QueryManager {
|
|
|
114
121
|
if (environment_1.__DEV__) {
|
|
115
122
|
(0, invariant_1.invariant)(
|
|
116
123
|
this.localState,
|
|
117
|
-
|
|
124
|
+
91,
|
|
118
125
|
(0, internal_1.getOperationName)(mutation, "(anonymous)")
|
|
119
126
|
);
|
|
120
127
|
}
|
|
@@ -349,7 +356,7 @@ class QueryManager {
|
|
|
349
356
|
// depend on values that previously existed in the data portion of the
|
|
350
357
|
// store. So, we cancel the promises and observers that we have issued
|
|
351
358
|
// so far and not yet resolved (in the case of queries).
|
|
352
|
-
this.cancelPendingFetches((0, invariant_1.newInvariantError)(
|
|
359
|
+
this.cancelPendingFetches((0, invariant_1.newInvariantError)(92));
|
|
353
360
|
this.obsQueries.forEach((observableQuery) => {
|
|
354
361
|
// Set loading to true so listeners don't trigger unless they want
|
|
355
362
|
// results with partial data.
|
|
@@ -419,10 +426,10 @@ class QueryManager {
|
|
|
419
426
|
if (!included) {
|
|
420
427
|
const queryName = queryNames.get(nameOrQueryString);
|
|
421
428
|
if (queryName) {
|
|
422
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
429
|
+
__DEV__ && invariant_1.invariant.warn(93, queryName);
|
|
423
430
|
}
|
|
424
431
|
else {
|
|
425
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
432
|
+
__DEV__ && invariant_1.invariant.warn(94);
|
|
426
433
|
}
|
|
427
434
|
}
|
|
428
435
|
});
|
|
@@ -451,7 +458,7 @@ class QueryManager {
|
|
|
451
458
|
if (environment_1.__DEV__) {
|
|
452
459
|
(0, invariant_1.invariant)(
|
|
453
460
|
!this.getDocumentInfo(query).hasClientExports || this.localState,
|
|
454
|
-
|
|
461
|
+
95,
|
|
455
462
|
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
456
463
|
);
|
|
457
464
|
}
|
|
@@ -596,14 +603,14 @@ class QueryManager {
|
|
|
596
603
|
if (environment_1.__DEV__) {
|
|
597
604
|
(0, invariant_1.invariant)(
|
|
598
605
|
this.localState,
|
|
599
|
-
|
|
606
|
+
96,
|
|
600
607
|
operation[0].toUpperCase() + operation.slice(1),
|
|
601
608
|
operationName ?? "(anonymous)"
|
|
602
609
|
);
|
|
603
610
|
}
|
|
604
611
|
(0, invariant_1.invariant)(
|
|
605
612
|
!hasIncrementalDirective,
|
|
606
|
-
|
|
613
|
+
97,
|
|
607
614
|
operation[0].toUpperCase() + operation.slice(1),
|
|
608
615
|
operationName ?? "(anonymous)"
|
|
609
616
|
);
|
|
@@ -627,7 +634,7 @@ class QueryManager {
|
|
|
627
634
|
})),
|
|
628
635
|
};
|
|
629
636
|
}
|
|
630
|
-
getResultsFromLink(options, { queryInfo, cacheWriteBehavior, observableQuery, exposeExtensions, }) {
|
|
637
|
+
getResultsFromLink(options, { queryInfo, cacheWriteBehavior, observableQuery, exposeExtensions, prunePendingDeferFragments, }) {
|
|
631
638
|
const { errorPolicy } = options;
|
|
632
639
|
// Performing transformForLink here gives this.cache a chance to fill in
|
|
633
640
|
// missing fragment definitions (for example) before sending this document
|
|
@@ -642,12 +649,15 @@ class QueryManager {
|
|
|
642
649
|
document: linkDocument,
|
|
643
650
|
cacheWriteBehavior,
|
|
644
651
|
returnPartialData: options.returnPartialData,
|
|
652
|
+
prunePendingDeferFragments,
|
|
645
653
|
});
|
|
646
654
|
const hasErrors = (0, internal_1.graphQLResultHasError)(result);
|
|
647
655
|
if (hasErrors && errorPolicy === "none") {
|
|
648
656
|
queryInfo.resetLastWrite();
|
|
649
657
|
observableQuery?.["resetNotifications"]();
|
|
650
|
-
|
|
658
|
+
const error = new errors_1.CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
|
|
659
|
+
dataStateErrorCache_js_1.dataStateErrorCache.set(error, dataState);
|
|
660
|
+
throw error;
|
|
651
661
|
}
|
|
652
662
|
const partial = dataState !== "complete";
|
|
653
663
|
const aqr = {
|
|
@@ -669,16 +679,10 @@ class QueryManager {
|
|
|
669
679
|
if (exposeExtensions && "extensions" in result) {
|
|
670
680
|
aqr[internal_1.extensionsSymbol] = result.extensions;
|
|
671
681
|
}
|
|
672
|
-
if (hasErrors) {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
aqr.
|
|
676
|
-
}
|
|
677
|
-
if (errorPolicy !== "ignore") {
|
|
678
|
-
aqr.error = new errors_1.CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
|
|
679
|
-
if (aqr.networkStatus !== networkStatus_js_1.NetworkStatus.streaming) {
|
|
680
|
-
aqr.networkStatus = networkStatus_js_1.NetworkStatus.error;
|
|
681
|
-
}
|
|
682
|
+
if (hasErrors && errorPolicy !== "ignore") {
|
|
683
|
+
aqr.error = new errors_1.CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
|
|
684
|
+
if (aqr.networkStatus !== networkStatus_js_1.NetworkStatus.streaming) {
|
|
685
|
+
aqr.networkStatus = networkStatus_js_1.NetworkStatus.error;
|
|
682
686
|
}
|
|
683
687
|
}
|
|
684
688
|
return aqr;
|
|
@@ -719,6 +723,7 @@ class QueryManager {
|
|
|
719
723
|
fetchPolicy,
|
|
720
724
|
errorPolicy,
|
|
721
725
|
returnPartialData,
|
|
726
|
+
networkStatus,
|
|
722
727
|
notifyOnNetworkStatusChange,
|
|
723
728
|
context,
|
|
724
729
|
});
|
|
@@ -777,7 +782,7 @@ class QueryManager {
|
|
|
777
782
|
if (environment_1.__DEV__) {
|
|
778
783
|
(0, invariant_1.invariant)(
|
|
779
784
|
this.localState,
|
|
780
|
-
|
|
785
|
+
98,
|
|
781
786
|
(0, internal_1.getOperationName)(normalized.query, "(anonymous)")
|
|
782
787
|
);
|
|
783
788
|
}
|
|
@@ -953,7 +958,7 @@ class QueryManager {
|
|
|
953
958
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
954
959
|
this.noCacheWarningsByCause.add(cause);
|
|
955
960
|
__DEV__ && invariant_1.invariant.warn(
|
|
956
|
-
|
|
961
|
+
99,
|
|
957
962
|
(0, internal_1.getOperationName)(document, `Unnamed ${operationType ?? "operation"}`)
|
|
958
963
|
);
|
|
959
964
|
}
|
|
@@ -968,7 +973,7 @@ class QueryManager {
|
|
|
968
973
|
(0, masking_1.maskFragment)(data, fragment, this.cache, fragmentName)
|
|
969
974
|
: data;
|
|
970
975
|
}
|
|
971
|
-
fetchQueryByPolicy({ query, variables, fetchPolicy, errorPolicy, returnPartialData, context, }, { cacheWriteBehavior, onCacheHit, queryInfo, observableQuery, exposeExtensions, }) {
|
|
976
|
+
fetchQueryByPolicy({ query, variables, fetchPolicy, errorPolicy, returnPartialData, context, networkStatus, }, { cacheWriteBehavior, onCacheHit, queryInfo, observableQuery, exposeExtensions, }) {
|
|
972
977
|
const readCache = () => this.cache.diff({
|
|
973
978
|
query,
|
|
974
979
|
variables,
|
|
@@ -1003,6 +1008,10 @@ class QueryManager {
|
|
|
1003
1008
|
return (0, rxjs_2.of)({
|
|
1004
1009
|
kind: "N",
|
|
1005
1010
|
value: toResult(data),
|
|
1011
|
+
// Always attach the variables used for this fetch so @export
|
|
1012
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1013
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1014
|
+
resolvedVariables: variables,
|
|
1006
1015
|
source: "cache",
|
|
1007
1016
|
});
|
|
1008
1017
|
};
|
|
@@ -1015,7 +1024,7 @@ class QueryManager {
|
|
|
1015
1024
|
if (environment_1.__DEV__) {
|
|
1016
1025
|
(0, invariant_1.invariant)(
|
|
1017
1026
|
this.localState,
|
|
1018
|
-
|
|
1027
|
+
100,
|
|
1019
1028
|
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
1020
1029
|
);
|
|
1021
1030
|
}
|
|
@@ -1032,6 +1041,10 @@ class QueryManager {
|
|
|
1032
1041
|
}).then((resolved) => ({
|
|
1033
1042
|
kind: "N",
|
|
1034
1043
|
value: toResult(resolved.data || void 0),
|
|
1044
|
+
// Always attach the variables used for this fetch so @export
|
|
1045
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1046
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1047
|
+
resolvedVariables: variables,
|
|
1035
1048
|
source: "cache",
|
|
1036
1049
|
})));
|
|
1037
1050
|
}
|
|
@@ -1046,20 +1059,26 @@ class QueryManager {
|
|
|
1046
1059
|
}
|
|
1047
1060
|
return fromData(data || undefined);
|
|
1048
1061
|
};
|
|
1049
|
-
const resultsFromLink = () => this.getResultsFromLink({
|
|
1062
|
+
const resultsFromLink = ({ prunePendingDeferFragments = true, } = {}) => this.getResultsFromLink({
|
|
1050
1063
|
query,
|
|
1051
1064
|
variables,
|
|
1052
1065
|
context,
|
|
1053
1066
|
fetchPolicy,
|
|
1054
1067
|
errorPolicy,
|
|
1055
1068
|
returnPartialData,
|
|
1069
|
+
networkStatus,
|
|
1056
1070
|
}, {
|
|
1057
1071
|
cacheWriteBehavior,
|
|
1058
1072
|
queryInfo,
|
|
1059
1073
|
observableQuery,
|
|
1060
1074
|
exposeExtensions,
|
|
1075
|
+
prunePendingDeferFragments,
|
|
1061
1076
|
}).pipe(validateDidEmitValue(), (0, rxjs_2.materialize)(), (0, rxjs_2.map)((result) => ({
|
|
1062
1077
|
...result,
|
|
1078
|
+
// Always attach the variables used for this fetch so @export
|
|
1079
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1080
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1081
|
+
resolvedVariables: variables,
|
|
1063
1082
|
source: "network",
|
|
1064
1083
|
})));
|
|
1065
1084
|
switch (fetchPolicy) {
|
|
@@ -1085,7 +1104,7 @@ class QueryManager {
|
|
|
1085
1104
|
if (diff.complete || returnPartialData) {
|
|
1086
1105
|
return {
|
|
1087
1106
|
fromLink: true,
|
|
1088
|
-
observable: (0, rxjs_2.concat)(resultsFromCache(diff, networkStatus_js_1.NetworkStatus.loading), resultsFromLink()),
|
|
1107
|
+
observable: (0, rxjs_2.concat)(resultsFromCache(diff, networkStatus_js_1.NetworkStatus.loading), resultsFromLink({ prunePendingDeferFragments: false })),
|
|
1089
1108
|
};
|
|
1090
1109
|
}
|
|
1091
1110
|
return { fromLink: true, observable: resultsFromLink() };
|
|
@@ -1096,7 +1115,12 @@ class QueryManager {
|
|
|
1096
1115
|
observable: (0, rxjs_2.concat)(resultsFromCache(readCache(), networkStatus_js_1.NetworkStatus.ready)),
|
|
1097
1116
|
};
|
|
1098
1117
|
case "network-only":
|
|
1099
|
-
return {
|
|
1118
|
+
return {
|
|
1119
|
+
fromLink: true,
|
|
1120
|
+
observable: resultsFromLink({
|
|
1121
|
+
prunePendingDeferFragments: networkStatus !== networkStatus_js_1.NetworkStatus.refetch,
|
|
1122
|
+
}),
|
|
1123
|
+
};
|
|
1100
1124
|
case "no-cache":
|
|
1101
1125
|
return { fromLink: true, observable: resultsFromLink() };
|
|
1102
1126
|
case "standby":
|
|
@@ -1112,7 +1136,7 @@ function validateDidEmitValue() {
|
|
|
1112
1136
|
didEmitValue = true;
|
|
1113
1137
|
},
|
|
1114
1138
|
complete() {
|
|
1115
|
-
(0, invariant_1.invariant)(didEmitValue,
|
|
1139
|
+
(0, invariant_1.invariant)(didEmitValue, 101);
|
|
1116
1140
|
},
|
|
1117
1141
|
});
|
|
1118
1142
|
}
|