@apollo/client 4.3.0-alpha.4 → 4.3.0-alpha.6
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 +116 -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/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/inMemoryCache.cjs +0 -4
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +3 -4
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +28 -6
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +71 -54
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.d.cts +1 -1
- package/__cjs/cache/inmemory/types.d.cts +1 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- 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 +56 -14
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +13 -2
- package/__cjs/core/QueryInfo.cjs +175 -161
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +15 -5
- package/__cjs/core/QueryManager.cjs +63 -38
- 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/graphql17Alpha9.cjs +34 -11
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +26 -3
- package/__cjs/incremental/types.d.cts +41 -3
- package/__cjs/invariantErrorCodes.cjs +56 -32
- 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/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/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/index.cjs +8 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +3 -0
- package/__cjs/utilities/internal/toDiffWithDataState.cjs +20 -0
- package/__cjs/utilities/internal/toDiffWithDataState.cjs.map +1 -0
- package/__cjs/utilities/internal/toDiffWithDataState.d.cts +8 -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/inmemory/entityStore.js +3 -3
- package/cache/inmemory/inMemoryCache.d.ts +3 -4
- package/cache/inmemory/inMemoryCache.js +1 -5
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +28 -6
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +1 -1
- package/cache/inmemory/readFromStore.js +72 -55
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +1 -2
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.js +4 -4
- 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 +13 -2
- package/core/ObservableQuery.js +57 -15
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +15 -5
- package/core/QueryInfo.js +171 -161
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +63 -38
- 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/graphql17Alpha9.d.ts +26 -3
- package/incremental/handlers/graphql17Alpha9.js +35 -12
- package/incremental/handlers/graphql17Alpha9.js.map +1 -1
- package/incremental/types.d.ts +41 -3
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +56 -32
- 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/internal/addDeferFragmentLabels.d.ts +3 -0
- package/utilities/internal/addDeferFragmentLabels.js +30 -0
- package/utilities/internal/addDeferFragmentLabels.js.map +1 -0
- 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/index.d.ts +3 -0
- package/utilities/internal/index.js +3 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/toDiffWithDataState.d.ts +8 -0
- package/utilities/internal/toDiffWithDataState.js +17 -0
- package/utilities/internal/toDiffWithDataState.js.map +1 -0
- package/version.js +1 -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;
|
|
@@ -765,7 +769,7 @@ export class QueryManager {
|
|
|
765
769
|
// we deprecated and removed LocalState.
|
|
766
770
|
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
767
771
|
if (__DEV__) {
|
|
768
|
-
invariant(this.localState,
|
|
772
|
+
invariant(this.localState, 98, getOperationName(normalized.query, "(anonymous)"));
|
|
769
773
|
}
|
|
770
774
|
observable = from(this.localState.getExportedVariables({
|
|
771
775
|
client: this.client,
|
|
@@ -938,7 +942,7 @@ export class QueryManager {
|
|
|
938
942
|
!isFullyUnmaskedOperation(document) &&
|
|
939
943
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
940
944
|
this.noCacheWarningsByCause.add(cause);
|
|
941
|
-
__DEV__ && invariant.warn(
|
|
945
|
+
__DEV__ && invariant.warn(99, getOperationName(document, `Unnamed ${operationType ?? "operation"}`));
|
|
942
946
|
}
|
|
943
947
|
}
|
|
944
948
|
return (this.dataMasking ?
|
|
@@ -952,31 +956,32 @@ export class QueryManager {
|
|
|
952
956
|
: data;
|
|
953
957
|
}
|
|
954
958
|
fetchQueryByPolicy({ query, variables, fetchPolicy, errorPolicy, returnPartialData, context, networkStatus, }, { cacheWriteBehavior, onCacheHit, queryInfo, observableQuery, exposeExtensions, }) {
|
|
955
|
-
const readCache = () =>
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
959
|
+
const readCache = () => {
|
|
960
|
+
return queryInfo.getDiff({
|
|
961
|
+
query,
|
|
962
|
+
variables,
|
|
963
|
+
returnPartialData: true,
|
|
964
|
+
optimistic: true,
|
|
965
|
+
});
|
|
966
|
+
};
|
|
961
967
|
const resultsFromCache = (diff, networkStatus) => {
|
|
962
968
|
const data = diff.result;
|
|
963
969
|
if (__DEV__ && !returnPartialData && data !== null) {
|
|
964
970
|
logMissingFieldErrors(diff.missing);
|
|
965
971
|
}
|
|
966
|
-
const toResult = (data) => {
|
|
972
|
+
const toResult = (data, dataState = diff.dataState) => {
|
|
967
973
|
// TODO: Eventually we should move this handling into
|
|
968
974
|
// queryInfo.getDiff() directly. Since getDiff is updated to return null
|
|
969
975
|
// on returnPartialData: false, we should take advantage of that instead
|
|
970
976
|
// of having to patch it elsewhere.
|
|
971
977
|
if (!diff.complete && !returnPartialData) {
|
|
972
978
|
data = undefined;
|
|
979
|
+
dataState = "empty";
|
|
973
980
|
}
|
|
974
981
|
return {
|
|
975
982
|
// TODO: Handle partial data
|
|
976
983
|
data: data,
|
|
977
|
-
dataState
|
|
978
|
-
: data ? "partial"
|
|
979
|
-
: "empty",
|
|
984
|
+
dataState,
|
|
980
985
|
loading: isNetworkRequestInFlight(networkStatus),
|
|
981
986
|
networkStatus,
|
|
982
987
|
partial: !diff.complete,
|
|
@@ -986,6 +991,10 @@ export class QueryManager {
|
|
|
986
991
|
return of({
|
|
987
992
|
kind: "N",
|
|
988
993
|
value: toResult(data),
|
|
994
|
+
// Always attach the variables used for this fetch so @export
|
|
995
|
+
// resolution can update ObservableQuery.options.variables and
|
|
996
|
+
// resubscribe the cache watch under the correct variable set.
|
|
997
|
+
resolvedVariables: variables,
|
|
989
998
|
source: "cache",
|
|
990
999
|
});
|
|
991
1000
|
};
|
|
@@ -996,7 +1005,7 @@ export class QueryManager {
|
|
|
996
1005
|
(diff.complete || returnPartialData) &&
|
|
997
1006
|
this.getDocumentInfo(query).hasForcedResolvers) {
|
|
998
1007
|
if (__DEV__) {
|
|
999
|
-
invariant(this.localState,
|
|
1008
|
+
invariant(this.localState, 100, getOperationName(query, "(anonymous)"));
|
|
1000
1009
|
}
|
|
1001
1010
|
onCacheHit();
|
|
1002
1011
|
return from(this.localState.execute({
|
|
@@ -1010,7 +1019,13 @@ export class QueryManager {
|
|
|
1010
1019
|
fetchPolicy,
|
|
1011
1020
|
}).then((resolved) => ({
|
|
1012
1021
|
kind: "N",
|
|
1013
|
-
value: toResult(resolved.data || void 0
|
|
1022
|
+
value: toResult(resolved.data || void 0, diff.complete ? "complete"
|
|
1023
|
+
: resolved.data ? "partial"
|
|
1024
|
+
: "empty"),
|
|
1025
|
+
// Always attach the variables used for this fetch so @export
|
|
1026
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1027
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1028
|
+
resolvedVariables: variables,
|
|
1014
1029
|
source: "cache",
|
|
1015
1030
|
})));
|
|
1016
1031
|
}
|
|
@@ -1025,7 +1040,7 @@ export class QueryManager {
|
|
|
1025
1040
|
}
|
|
1026
1041
|
return fromData(data || undefined);
|
|
1027
1042
|
};
|
|
1028
|
-
const resultsFromLink = () => this.getResultsFromLink({
|
|
1043
|
+
const resultsFromLink = ({ prunePendingDeferFragments = true, } = {}) => this.getResultsFromLink({
|
|
1029
1044
|
query,
|
|
1030
1045
|
variables,
|
|
1031
1046
|
context,
|
|
@@ -1038,8 +1053,13 @@ export class QueryManager {
|
|
|
1038
1053
|
queryInfo,
|
|
1039
1054
|
observableQuery,
|
|
1040
1055
|
exposeExtensions,
|
|
1056
|
+
prunePendingDeferFragments,
|
|
1041
1057
|
}).pipe(validateDidEmitValue(), materialize(), map((result) => ({
|
|
1042
1058
|
...result,
|
|
1059
|
+
// Always attach the variables used for this fetch so @export
|
|
1060
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1061
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1062
|
+
resolvedVariables: variables,
|
|
1043
1063
|
source: "network",
|
|
1044
1064
|
})));
|
|
1045
1065
|
switch (fetchPolicy) {
|
|
@@ -1065,7 +1085,7 @@ export class QueryManager {
|
|
|
1065
1085
|
if (diff.complete || returnPartialData) {
|
|
1066
1086
|
return {
|
|
1067
1087
|
fromLink: true,
|
|
1068
|
-
observable: concat(resultsFromCache(diff, NetworkStatus.loading), resultsFromLink()),
|
|
1088
|
+
observable: concat(resultsFromCache(diff, NetworkStatus.loading), resultsFromLink({ prunePendingDeferFragments: false })),
|
|
1069
1089
|
};
|
|
1070
1090
|
}
|
|
1071
1091
|
return { fromLink: true, observable: resultsFromLink() };
|
|
@@ -1076,7 +1096,12 @@ export class QueryManager {
|
|
|
1076
1096
|
observable: concat(resultsFromCache(readCache(), NetworkStatus.ready)),
|
|
1077
1097
|
};
|
|
1078
1098
|
case "network-only":
|
|
1079
|
-
return {
|
|
1099
|
+
return {
|
|
1100
|
+
fromLink: true,
|
|
1101
|
+
observable: resultsFromLink({
|
|
1102
|
+
prunePendingDeferFragments: networkStatus !== NetworkStatus.refetch,
|
|
1103
|
+
}),
|
|
1104
|
+
};
|
|
1080
1105
|
case "no-cache":
|
|
1081
1106
|
return { fromLink: true, observable: resultsFromLink() };
|
|
1082
1107
|
case "standby":
|
|
@@ -1091,7 +1116,7 @@ function validateDidEmitValue() {
|
|
|
1091
1116
|
didEmitValue = true;
|
|
1092
1117
|
},
|
|
1093
1118
|
complete() {
|
|
1094
|
-
invariant(didEmitValue,
|
|
1119
|
+
invariant(didEmitValue, 101);
|
|
1095
1120
|
},
|
|
1096
1121
|
});
|
|
1097
1122
|
}
|