@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
|
@@ -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;
|
|
@@ -778,7 +782,7 @@ class QueryManager {
|
|
|
778
782
|
if (environment_1.__DEV__) {
|
|
779
783
|
(0, invariant_1.invariant)(
|
|
780
784
|
this.localState,
|
|
781
|
-
|
|
785
|
+
98,
|
|
782
786
|
(0, internal_1.getOperationName)(normalized.query, "(anonymous)")
|
|
783
787
|
);
|
|
784
788
|
}
|
|
@@ -954,7 +958,7 @@ class QueryManager {
|
|
|
954
958
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
955
959
|
this.noCacheWarningsByCause.add(cause);
|
|
956
960
|
__DEV__ && invariant_1.invariant.warn(
|
|
957
|
-
|
|
961
|
+
99,
|
|
958
962
|
(0, internal_1.getOperationName)(document, `Unnamed ${operationType ?? "operation"}`)
|
|
959
963
|
);
|
|
960
964
|
}
|
|
@@ -970,31 +974,32 @@ class QueryManager {
|
|
|
970
974
|
: data;
|
|
971
975
|
}
|
|
972
976
|
fetchQueryByPolicy({ query, variables, fetchPolicy, errorPolicy, returnPartialData, context, networkStatus, }, { cacheWriteBehavior, onCacheHit, queryInfo, observableQuery, exposeExtensions, }) {
|
|
973
|
-
const readCache = () =>
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
977
|
+
const readCache = () => {
|
|
978
|
+
return queryInfo.getDiff({
|
|
979
|
+
query,
|
|
980
|
+
variables,
|
|
981
|
+
returnPartialData: true,
|
|
982
|
+
optimistic: true,
|
|
983
|
+
});
|
|
984
|
+
};
|
|
979
985
|
const resultsFromCache = (diff, networkStatus) => {
|
|
980
986
|
const data = diff.result;
|
|
981
987
|
if (environment_1.__DEV__ && !returnPartialData && data !== null) {
|
|
982
988
|
(0, ObservableQuery_js_1.logMissingFieldErrors)(diff.missing);
|
|
983
989
|
}
|
|
984
|
-
const toResult = (data) => {
|
|
990
|
+
const toResult = (data, dataState = diff.dataState) => {
|
|
985
991
|
// TODO: Eventually we should move this handling into
|
|
986
992
|
// queryInfo.getDiff() directly. Since getDiff is updated to return null
|
|
987
993
|
// on returnPartialData: false, we should take advantage of that instead
|
|
988
994
|
// of having to patch it elsewhere.
|
|
989
995
|
if (!diff.complete && !returnPartialData) {
|
|
990
996
|
data = undefined;
|
|
997
|
+
dataState = "empty";
|
|
991
998
|
}
|
|
992
999
|
return {
|
|
993
1000
|
// TODO: Handle partial data
|
|
994
1001
|
data: data,
|
|
995
|
-
dataState
|
|
996
|
-
: data ? "partial"
|
|
997
|
-
: "empty",
|
|
1002
|
+
dataState,
|
|
998
1003
|
loading: (0, utilities_1.isNetworkRequestInFlight)(networkStatus),
|
|
999
1004
|
networkStatus,
|
|
1000
1005
|
partial: !diff.complete,
|
|
@@ -1004,6 +1009,10 @@ class QueryManager {
|
|
|
1004
1009
|
return (0, rxjs_2.of)({
|
|
1005
1010
|
kind: "N",
|
|
1006
1011
|
value: toResult(data),
|
|
1012
|
+
// Always attach the variables used for this fetch so @export
|
|
1013
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1014
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1015
|
+
resolvedVariables: variables,
|
|
1007
1016
|
source: "cache",
|
|
1008
1017
|
});
|
|
1009
1018
|
};
|
|
@@ -1016,7 +1025,7 @@ class QueryManager {
|
|
|
1016
1025
|
if (environment_1.__DEV__) {
|
|
1017
1026
|
(0, invariant_1.invariant)(
|
|
1018
1027
|
this.localState,
|
|
1019
|
-
|
|
1028
|
+
100,
|
|
1020
1029
|
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
1021
1030
|
);
|
|
1022
1031
|
}
|
|
@@ -1032,7 +1041,13 @@ class QueryManager {
|
|
|
1032
1041
|
fetchPolicy,
|
|
1033
1042
|
}).then((resolved) => ({
|
|
1034
1043
|
kind: "N",
|
|
1035
|
-
value: toResult(resolved.data || void 0
|
|
1044
|
+
value: toResult(resolved.data || void 0, diff.complete ? "complete"
|
|
1045
|
+
: resolved.data ? "partial"
|
|
1046
|
+
: "empty"),
|
|
1047
|
+
// Always attach the variables used for this fetch so @export
|
|
1048
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1049
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1050
|
+
resolvedVariables: variables,
|
|
1036
1051
|
source: "cache",
|
|
1037
1052
|
})));
|
|
1038
1053
|
}
|
|
@@ -1047,7 +1062,7 @@ class QueryManager {
|
|
|
1047
1062
|
}
|
|
1048
1063
|
return fromData(data || undefined);
|
|
1049
1064
|
};
|
|
1050
|
-
const resultsFromLink = () => this.getResultsFromLink({
|
|
1065
|
+
const resultsFromLink = ({ prunePendingDeferFragments = true, } = {}) => this.getResultsFromLink({
|
|
1051
1066
|
query,
|
|
1052
1067
|
variables,
|
|
1053
1068
|
context,
|
|
@@ -1060,8 +1075,13 @@ class QueryManager {
|
|
|
1060
1075
|
queryInfo,
|
|
1061
1076
|
observableQuery,
|
|
1062
1077
|
exposeExtensions,
|
|
1078
|
+
prunePendingDeferFragments,
|
|
1063
1079
|
}).pipe(validateDidEmitValue(), (0, rxjs_2.materialize)(), (0, rxjs_2.map)((result) => ({
|
|
1064
1080
|
...result,
|
|
1081
|
+
// Always attach the variables used for this fetch so @export
|
|
1082
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1083
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1084
|
+
resolvedVariables: variables,
|
|
1065
1085
|
source: "network",
|
|
1066
1086
|
})));
|
|
1067
1087
|
switch (fetchPolicy) {
|
|
@@ -1087,7 +1107,7 @@ class QueryManager {
|
|
|
1087
1107
|
if (diff.complete || returnPartialData) {
|
|
1088
1108
|
return {
|
|
1089
1109
|
fromLink: true,
|
|
1090
|
-
observable: (0, rxjs_2.concat)(resultsFromCache(diff, networkStatus_js_1.NetworkStatus.loading), resultsFromLink()),
|
|
1110
|
+
observable: (0, rxjs_2.concat)(resultsFromCache(diff, networkStatus_js_1.NetworkStatus.loading), resultsFromLink({ prunePendingDeferFragments: false })),
|
|
1091
1111
|
};
|
|
1092
1112
|
}
|
|
1093
1113
|
return { fromLink: true, observable: resultsFromLink() };
|
|
@@ -1098,7 +1118,12 @@ class QueryManager {
|
|
|
1098
1118
|
observable: (0, rxjs_2.concat)(resultsFromCache(readCache(), networkStatus_js_1.NetworkStatus.ready)),
|
|
1099
1119
|
};
|
|
1100
1120
|
case "network-only":
|
|
1101
|
-
return {
|
|
1121
|
+
return {
|
|
1122
|
+
fromLink: true,
|
|
1123
|
+
observable: resultsFromLink({
|
|
1124
|
+
prunePendingDeferFragments: networkStatus !== networkStatus_js_1.NetworkStatus.refetch,
|
|
1125
|
+
}),
|
|
1126
|
+
};
|
|
1102
1127
|
case "no-cache":
|
|
1103
1128
|
return { fromLink: true, observable: resultsFromLink() };
|
|
1104
1129
|
case "standby":
|
|
@@ -1114,7 +1139,7 @@ function validateDidEmitValue() {
|
|
|
1114
1139
|
didEmitValue = true;
|
|
1115
1140
|
},
|
|
1116
1141
|
complete() {
|
|
1117
|
-
(0, invariant_1.invariant)(didEmitValue,
|
|
1142
|
+
(0, invariant_1.invariant)(didEmitValue, 101);
|
|
1118
1143
|
},
|
|
1119
1144
|
});
|
|
1120
1145
|
}
|