@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
package/core/QueryManager.js
CHANGED
|
@@ -11,6 +11,7 @@ import { cacheSizes, DocumentTransform, isNetworkRequestInFlight, print, } from
|
|
|
11
11
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
12
12
|
import { AutoCleanedWeakCache, checkDocument, extensionsSymbol, filterMap, getDefaultValues, getOperationDefinition, getOperationName, graphQLResultHasError, hasDirectives, hasForcedResolvers, isDocumentNode, isNonNullObject, makeUniqueId, mergeOptions, removeDirectivesFromDocument, streamInfoSymbol, toQueryResult, } from "@apollo/client/utilities/internal";
|
|
13
13
|
import { invariant, newInvariantError, } from "@apollo/client/utilities/invariant";
|
|
14
|
+
import { dataStateErrorCache } from "./dataStateErrorCache.js";
|
|
14
15
|
import { NetworkStatus } from "./networkStatus.js";
|
|
15
16
|
import { logMissingFieldErrors, ObservableQuery } from "./ObservableQuery.js";
|
|
16
17
|
import { QueryInfo } from "./QueryInfo.js";
|
|
@@ -75,6 +76,12 @@ export class QueryManager {
|
|
|
75
76
|
// selections and fragments from the fragment registry.
|
|
76
77
|
.concat(defaultDocumentTransform)
|
|
77
78
|
: defaultDocumentTransform;
|
|
79
|
+
// Put the incremental transform last so custom document transforms don't
|
|
80
|
+
// revert changes made to the document accidentally. Adding last also
|
|
81
|
+
// ensures `@defer` fragments added by the fragment registry are labeled.
|
|
82
|
+
if (this.incrementalHandler.documentTransform) {
|
|
83
|
+
this.documentTransform = this.documentTransform.concat(this.incrementalHandler.documentTransform);
|
|
84
|
+
}
|
|
78
85
|
this.defaultContext = options.defaultContext || {};
|
|
79
86
|
if ((this.onBroadcast = options.onBroadcast)) {
|
|
80
87
|
this.mutationStore = {};
|
|
@@ -92,7 +99,7 @@ export class QueryManager {
|
|
|
92
99
|
*/
|
|
93
100
|
stop() {
|
|
94
101
|
this.obsQueries.forEach((oq) => oq.stop());
|
|
95
|
-
this.cancelPendingFetches(newInvariantError(
|
|
102
|
+
this.cancelPendingFetches(newInvariantError(90));
|
|
96
103
|
}
|
|
97
104
|
cancelPendingFetches(error) {
|
|
98
105
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
@@ -105,7 +112,7 @@ export class QueryManager {
|
|
|
105
112
|
variables = this.getVariables(mutation, variables);
|
|
106
113
|
if (hasClientExports) {
|
|
107
114
|
if (__DEV__) {
|
|
108
|
-
invariant(this.localState,
|
|
115
|
+
invariant(this.localState, 91, getOperationName(mutation, "(anonymous)"));
|
|
109
116
|
}
|
|
110
117
|
variables = await this.localState.getExportedVariables({
|
|
111
118
|
client: this.client,
|
|
@@ -338,7 +345,7 @@ export class QueryManager {
|
|
|
338
345
|
// depend on values that previously existed in the data portion of the
|
|
339
346
|
// store. So, we cancel the promises and observers that we have issued
|
|
340
347
|
// so far and not yet resolved (in the case of queries).
|
|
341
|
-
this.cancelPendingFetches(newInvariantError(
|
|
348
|
+
this.cancelPendingFetches(newInvariantError(92));
|
|
342
349
|
this.obsQueries.forEach((observableQuery) => {
|
|
343
350
|
// Set loading to true so listeners don't trigger unless they want
|
|
344
351
|
// results with partial data.
|
|
@@ -408,10 +415,10 @@ export class QueryManager {
|
|
|
408
415
|
if (!included) {
|
|
409
416
|
const queryName = queryNames.get(nameOrQueryString);
|
|
410
417
|
if (queryName) {
|
|
411
|
-
__DEV__ && invariant.warn(
|
|
418
|
+
__DEV__ && invariant.warn(93, queryName);
|
|
412
419
|
}
|
|
413
420
|
else {
|
|
414
|
-
__DEV__ && invariant.warn(
|
|
421
|
+
__DEV__ && invariant.warn(94);
|
|
415
422
|
}
|
|
416
423
|
}
|
|
417
424
|
});
|
|
@@ -440,7 +447,7 @@ export class QueryManager {
|
|
|
440
447
|
if (__DEV__) {
|
|
441
448
|
invariant(
|
|
442
449
|
!this.getDocumentInfo(query).hasClientExports || this.localState,
|
|
443
|
-
|
|
450
|
+
95,
|
|
444
451
|
getOperationName(query, "(anonymous)")
|
|
445
452
|
);
|
|
446
453
|
}
|
|
@@ -585,14 +592,14 @@ export class QueryManager {
|
|
|
585
592
|
if (__DEV__) {
|
|
586
593
|
invariant(
|
|
587
594
|
this.localState,
|
|
588
|
-
|
|
595
|
+
96,
|
|
589
596
|
operation[0].toUpperCase() + operation.slice(1),
|
|
590
597
|
operationName ?? "(anonymous)"
|
|
591
598
|
);
|
|
592
599
|
}
|
|
593
600
|
invariant(
|
|
594
601
|
!hasIncrementalDirective,
|
|
595
|
-
|
|
602
|
+
97,
|
|
596
603
|
operation[0].toUpperCase() + operation.slice(1),
|
|
597
604
|
operationName ?? "(anonymous)"
|
|
598
605
|
);
|
|
@@ -616,7 +623,7 @@ export class QueryManager {
|
|
|
616
623
|
})),
|
|
617
624
|
};
|
|
618
625
|
}
|
|
619
|
-
getResultsFromLink(options, { queryInfo, cacheWriteBehavior, observableQuery, exposeExtensions, }) {
|
|
626
|
+
getResultsFromLink(options, { queryInfo, cacheWriteBehavior, observableQuery, exposeExtensions, prunePendingDeferFragments, }) {
|
|
620
627
|
const { errorPolicy } = options;
|
|
621
628
|
// Performing transformForLink here gives this.cache a chance to fill in
|
|
622
629
|
// missing fragment definitions (for example) before sending this document
|
|
@@ -631,12 +638,15 @@ export class QueryManager {
|
|
|
631
638
|
document: linkDocument,
|
|
632
639
|
cacheWriteBehavior,
|
|
633
640
|
returnPartialData: options.returnPartialData,
|
|
641
|
+
prunePendingDeferFragments,
|
|
634
642
|
});
|
|
635
643
|
const hasErrors = graphQLResultHasError(result);
|
|
636
644
|
if (hasErrors && errorPolicy === "none") {
|
|
637
645
|
queryInfo.resetLastWrite();
|
|
638
646
|
observableQuery?.["resetNotifications"]();
|
|
639
|
-
|
|
647
|
+
const error = new CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
|
|
648
|
+
dataStateErrorCache.set(error, dataState);
|
|
649
|
+
throw error;
|
|
640
650
|
}
|
|
641
651
|
const partial = dataState !== "complete";
|
|
642
652
|
const aqr = {
|
|
@@ -658,16 +668,10 @@ export class QueryManager {
|
|
|
658
668
|
if (exposeExtensions && "extensions" in result) {
|
|
659
669
|
aqr[extensionsSymbol] = result.extensions;
|
|
660
670
|
}
|
|
661
|
-
if (hasErrors) {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
aqr.
|
|
665
|
-
}
|
|
666
|
-
if (errorPolicy !== "ignore") {
|
|
667
|
-
aqr.error = new CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
|
|
668
|
-
if (aqr.networkStatus !== NetworkStatus.streaming) {
|
|
669
|
-
aqr.networkStatus = NetworkStatus.error;
|
|
670
|
-
}
|
|
671
|
+
if (hasErrors && errorPolicy !== "ignore") {
|
|
672
|
+
aqr.error = new CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
|
|
673
|
+
if (aqr.networkStatus !== NetworkStatus.streaming) {
|
|
674
|
+
aqr.networkStatus = NetworkStatus.error;
|
|
671
675
|
}
|
|
672
676
|
}
|
|
673
677
|
return aqr;
|
|
@@ -708,6 +712,7 @@ export class QueryManager {
|
|
|
708
712
|
fetchPolicy,
|
|
709
713
|
errorPolicy,
|
|
710
714
|
returnPartialData,
|
|
715
|
+
networkStatus,
|
|
711
716
|
notifyOnNetworkStatusChange,
|
|
712
717
|
context,
|
|
713
718
|
});
|
|
@@ -764,7 +769,7 @@ export class QueryManager {
|
|
|
764
769
|
// we deprecated and removed LocalState.
|
|
765
770
|
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
766
771
|
if (__DEV__) {
|
|
767
|
-
invariant(this.localState,
|
|
772
|
+
invariant(this.localState, 98, getOperationName(normalized.query, "(anonymous)"));
|
|
768
773
|
}
|
|
769
774
|
observable = from(this.localState.getExportedVariables({
|
|
770
775
|
client: this.client,
|
|
@@ -937,7 +942,7 @@ export class QueryManager {
|
|
|
937
942
|
!isFullyUnmaskedOperation(document) &&
|
|
938
943
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
939
944
|
this.noCacheWarningsByCause.add(cause);
|
|
940
|
-
__DEV__ && invariant.warn(
|
|
945
|
+
__DEV__ && invariant.warn(99, getOperationName(document, `Unnamed ${operationType ?? "operation"}`));
|
|
941
946
|
}
|
|
942
947
|
}
|
|
943
948
|
return (this.dataMasking ?
|
|
@@ -950,7 +955,7 @@ export class QueryManager {
|
|
|
950
955
|
maskFragment(data, fragment, this.cache, fragmentName)
|
|
951
956
|
: data;
|
|
952
957
|
}
|
|
953
|
-
fetchQueryByPolicy({ query, variables, fetchPolicy, errorPolicy, returnPartialData, context, }, { cacheWriteBehavior, onCacheHit, queryInfo, observableQuery, exposeExtensions, }) {
|
|
958
|
+
fetchQueryByPolicy({ query, variables, fetchPolicy, errorPolicy, returnPartialData, context, networkStatus, }, { cacheWriteBehavior, onCacheHit, queryInfo, observableQuery, exposeExtensions, }) {
|
|
954
959
|
const readCache = () => this.cache.diff({
|
|
955
960
|
query,
|
|
956
961
|
variables,
|
|
@@ -985,6 +990,10 @@ export class QueryManager {
|
|
|
985
990
|
return of({
|
|
986
991
|
kind: "N",
|
|
987
992
|
value: toResult(data),
|
|
993
|
+
// Always attach the variables used for this fetch so @export
|
|
994
|
+
// resolution can update ObservableQuery.options.variables and
|
|
995
|
+
// resubscribe the cache watch under the correct variable set.
|
|
996
|
+
resolvedVariables: variables,
|
|
988
997
|
source: "cache",
|
|
989
998
|
});
|
|
990
999
|
};
|
|
@@ -995,7 +1004,7 @@ export class QueryManager {
|
|
|
995
1004
|
(diff.complete || returnPartialData) &&
|
|
996
1005
|
this.getDocumentInfo(query).hasForcedResolvers) {
|
|
997
1006
|
if (__DEV__) {
|
|
998
|
-
invariant(this.localState,
|
|
1007
|
+
invariant(this.localState, 100, getOperationName(query, "(anonymous)"));
|
|
999
1008
|
}
|
|
1000
1009
|
onCacheHit();
|
|
1001
1010
|
return from(this.localState.execute({
|
|
@@ -1010,6 +1019,10 @@ export class QueryManager {
|
|
|
1010
1019
|
}).then((resolved) => ({
|
|
1011
1020
|
kind: "N",
|
|
1012
1021
|
value: toResult(resolved.data || void 0),
|
|
1022
|
+
// Always attach the variables used for this fetch so @export
|
|
1023
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1024
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1025
|
+
resolvedVariables: variables,
|
|
1013
1026
|
source: "cache",
|
|
1014
1027
|
})));
|
|
1015
1028
|
}
|
|
@@ -1024,20 +1037,26 @@ export class QueryManager {
|
|
|
1024
1037
|
}
|
|
1025
1038
|
return fromData(data || undefined);
|
|
1026
1039
|
};
|
|
1027
|
-
const resultsFromLink = () => this.getResultsFromLink({
|
|
1040
|
+
const resultsFromLink = ({ prunePendingDeferFragments = true, } = {}) => this.getResultsFromLink({
|
|
1028
1041
|
query,
|
|
1029
1042
|
variables,
|
|
1030
1043
|
context,
|
|
1031
1044
|
fetchPolicy,
|
|
1032
1045
|
errorPolicy,
|
|
1033
1046
|
returnPartialData,
|
|
1047
|
+
networkStatus,
|
|
1034
1048
|
}, {
|
|
1035
1049
|
cacheWriteBehavior,
|
|
1036
1050
|
queryInfo,
|
|
1037
1051
|
observableQuery,
|
|
1038
1052
|
exposeExtensions,
|
|
1053
|
+
prunePendingDeferFragments,
|
|
1039
1054
|
}).pipe(validateDidEmitValue(), materialize(), map((result) => ({
|
|
1040
1055
|
...result,
|
|
1056
|
+
// Always attach the variables used for this fetch so @export
|
|
1057
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1058
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1059
|
+
resolvedVariables: variables,
|
|
1041
1060
|
source: "network",
|
|
1042
1061
|
})));
|
|
1043
1062
|
switch (fetchPolicy) {
|
|
@@ -1063,7 +1082,7 @@ export class QueryManager {
|
|
|
1063
1082
|
if (diff.complete || returnPartialData) {
|
|
1064
1083
|
return {
|
|
1065
1084
|
fromLink: true,
|
|
1066
|
-
observable: concat(resultsFromCache(diff, NetworkStatus.loading), resultsFromLink()),
|
|
1085
|
+
observable: concat(resultsFromCache(diff, NetworkStatus.loading), resultsFromLink({ prunePendingDeferFragments: false })),
|
|
1067
1086
|
};
|
|
1068
1087
|
}
|
|
1069
1088
|
return { fromLink: true, observable: resultsFromLink() };
|
|
@@ -1074,7 +1093,12 @@ export class QueryManager {
|
|
|
1074
1093
|
observable: concat(resultsFromCache(readCache(), NetworkStatus.ready)),
|
|
1075
1094
|
};
|
|
1076
1095
|
case "network-only":
|
|
1077
|
-
return {
|
|
1096
|
+
return {
|
|
1097
|
+
fromLink: true,
|
|
1098
|
+
observable: resultsFromLink({
|
|
1099
|
+
prunePendingDeferFragments: networkStatus !== NetworkStatus.refetch,
|
|
1100
|
+
}),
|
|
1101
|
+
};
|
|
1078
1102
|
case "no-cache":
|
|
1079
1103
|
return { fromLink: true, observable: resultsFromLink() };
|
|
1080
1104
|
case "standby":
|
|
@@ -1089,7 +1113,7 @@ function validateDidEmitValue() {
|
|
|
1089
1113
|
didEmitValue = true;
|
|
1090
1114
|
},
|
|
1091
1115
|
complete() {
|
|
1092
|
-
invariant(didEmitValue,
|
|
1116
|
+
invariant(didEmitValue, 101);
|
|
1093
1117
|
},
|
|
1094
1118
|
});
|
|
1095
1119
|
}
|