@apollo/client 4.0.0-alpha.17 → 4.0.0-alpha.19
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 +68 -0
- package/__cjs/core/ApolloClient.cjs +3 -1
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +2 -2
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryManager.cjs +126 -99
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +5 -2
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +1 -1
- package/__cjs/core/types.d.cts +21 -1
- package/__cjs/invariantErrorCodes.cjs +1 -1
- package/__cjs/masking/GraphQLCodegenDataMasking.cjs +3 -0
- package/__cjs/masking/GraphQLCodegenDataMasking.cjs.map +1 -0
- package/__cjs/masking/GraphQLCodegenDataMasking.d.cts +79 -0
- package/__cjs/masking/index.cjs.map +1 -1
- package/__cjs/masking/index.d.cts +1 -0
- package/__cjs/masking/types.d.cts +11 -26
- package/__cjs/react/hooks/useSubscription.cjs +11 -16
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/utilities/HKT.cjs +3 -0
- package/__cjs/utilities/HKT.cjs.map +1 -0
- package/__cjs/utilities/HKT.d.cts +35 -0
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +1 -0
- package/__cjs/utilities/internal/index.cjs +2 -4
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +2 -1
- package/__cjs/utilities/internal/types/ApplyHKT.cjs +3 -0
- package/__cjs/utilities/internal/types/ApplyHKT.cjs.map +1 -0
- package/__cjs/utilities/internal/types/ApplyHKT.d.cts +13 -0
- package/__cjs/utilities/internal/types/ApplyHKTImplementationWithDefault.cjs +3 -0
- package/__cjs/utilities/internal/types/ApplyHKTImplementationWithDefault.cjs.map +1 -0
- package/__cjs/utilities/internal/types/ApplyHKTImplementationWithDefault.d.cts +11 -0
- package/__cjs/version.cjs +1 -1
- package/core/ApolloClient.d.ts +2 -2
- package/core/ApolloClient.js +3 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +5 -2
- package/core/QueryManager.js +111 -80
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js.map +1 -1
- package/core/types.d.ts +21 -1
- package/invariantErrorCodes.js +1 -1
- package/masking/GraphQLCodegenDataMasking.d.ts +79 -0
- package/masking/GraphQLCodegenDataMasking.js +2 -0
- package/masking/GraphQLCodegenDataMasking.js.map +1 -0
- package/masking/index.d.ts +1 -0
- package/masking/index.js.map +1 -1
- package/masking/types.d.ts +11 -26
- package/package.json +1 -1
- package/react/hooks/useSubscription.js +11 -16
- package/react/hooks/useSubscription.js.map +1 -1
- package/utilities/HKT.d.ts +35 -0
- package/utilities/HKT.js +2 -0
- package/utilities/HKT.js.map +1 -0
- package/utilities/index.d.ts +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/internal/index.d.ts +2 -1
- package/utilities/internal/index.js +0 -1
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/types/ApplyHKT.d.ts +13 -0
- package/utilities/internal/types/ApplyHKT.js +2 -0
- package/utilities/internal/types/ApplyHKT.js.map +1 -0
- package/utilities/internal/types/ApplyHKTImplementationWithDefault.d.ts +11 -0
- package/utilities/internal/types/ApplyHKTImplementationWithDefault.js +2 -0
- package/utilities/internal/types/ApplyHKTImplementationWithDefault.js.map +1 -0
- package/version.js +1 -1
- package/__cjs/utilities/internal/onAnyEvent.cjs +0 -33
- package/__cjs/utilities/internal/onAnyEvent.cjs.map +0 -1
- package/__cjs/utilities/internal/onAnyEvent.d.cts +0 -18
- package/utilities/internal/onAnyEvent.d.ts +0 -18
- package/utilities/internal/onAnyEvent.js +0 -30
- package/utilities/internal/onAnyEvent.js.map +0 -1
|
@@ -8,6 +8,7 @@ exports.QueryManager = void 0;
|
|
|
8
8
|
const trie_1 = require("@wry/trie");
|
|
9
9
|
const graphql_1 = require("graphql");
|
|
10
10
|
const rxjs_1 = require("rxjs");
|
|
11
|
+
const rxjs_2 = require("rxjs");
|
|
11
12
|
const cache_1 = require("@apollo/client/cache");
|
|
12
13
|
const errors_1 = require("@apollo/client/errors");
|
|
13
14
|
const errors_2 = require("@apollo/client/errors");
|
|
@@ -150,7 +151,7 @@ class QueryManager {
|
|
|
150
151
|
...context,
|
|
151
152
|
optimisticResponse: isOptimistic ? optimisticResponse : void 0,
|
|
152
153
|
}, variables, {}, false)
|
|
153
|
-
.pipe(validateDidEmitValue(), (0,
|
|
154
|
+
.observable.pipe(validateDidEmitValue(), (0, rxjs_2.mergeMap)((result) => {
|
|
154
155
|
const hasErrors = (0, internal_1.graphQLResultHasError)(result);
|
|
155
156
|
if (hasErrors && errorPolicy === "none") {
|
|
156
157
|
throw new errors_1.CombinedGraphQLErrors(result);
|
|
@@ -166,7 +167,7 @@ class QueryManager {
|
|
|
166
167
|
if (errorPolicy === "ignore" && hasErrors) {
|
|
167
168
|
delete storeResult.errors;
|
|
168
169
|
}
|
|
169
|
-
return (0,
|
|
170
|
+
return (0, rxjs_2.from)(this.markMutationResult({
|
|
170
171
|
mutationId,
|
|
171
172
|
result: storeResult,
|
|
172
173
|
document: mutation,
|
|
@@ -414,7 +415,7 @@ class QueryManager {
|
|
|
414
415
|
return true;
|
|
415
416
|
}
|
|
416
417
|
fetchQuery(queryId, options, networkStatus) {
|
|
417
|
-
return (0,
|
|
418
|
+
return (0, rxjs_2.lastValueFrom)(this.fetchObservableWithInfo(this.getOrCreateQuery(queryId), options, {
|
|
418
419
|
networkStatus,
|
|
419
420
|
}).observable.pipe((0, internal_1.filterMap)((value) => {
|
|
420
421
|
switch (value.kind) {
|
|
@@ -439,6 +440,7 @@ class QueryManager {
|
|
|
439
440
|
getDocumentInfo(document) {
|
|
440
441
|
const { transformCache } = this;
|
|
441
442
|
if (!transformCache.has(document)) {
|
|
443
|
+
const operationDefinition = (0, internal_1.getOperationDefinition)(document);
|
|
442
444
|
const cacheEntry = {
|
|
443
445
|
// TODO These three calls (hasClientExports, shouldForceResolvers, and
|
|
444
446
|
// usesNonreactiveDirective) are performing independent full traversals
|
|
@@ -456,7 +458,8 @@ class QueryManager {
|
|
|
456
458
|
{ name: "nonreactive" },
|
|
457
459
|
{ name: "unmask" },
|
|
458
460
|
], document),
|
|
459
|
-
|
|
461
|
+
operationType: operationDefinition?.operation,
|
|
462
|
+
defaultVars: (0, internal_1.getDefaultValues)(operationDefinition),
|
|
460
463
|
// Transform any mutation or subscription operations to query operations
|
|
461
464
|
// so we can read/write them from/to the cache.
|
|
462
465
|
asQuery: {
|
|
@@ -660,69 +663,68 @@ class QueryManager {
|
|
|
660
663
|
(0, internal_1.checkDocument)(query, graphql_1.OperationTypeNode.SUBSCRIPTION);
|
|
661
664
|
query = this.transform(query);
|
|
662
665
|
variables = this.getVariables(query, variables);
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
this.broadcastQueries();
|
|
676
|
-
}
|
|
677
|
-
const result = {
|
|
678
|
-
data: rawResult.data ?? undefined,
|
|
679
|
-
};
|
|
680
|
-
if ((0, internal_1.graphQLResultHasError)(rawResult)) {
|
|
681
|
-
result.error = new errors_1.CombinedGraphQLErrors(rawResult);
|
|
682
|
-
}
|
|
683
|
-
else if ((0, errors_1.graphQLResultHasProtocolErrors)(rawResult)) {
|
|
684
|
-
result.error = rawResult.extensions[errors_2.PROTOCOL_ERRORS_SYMBOL];
|
|
685
|
-
// Don't emit protocol errors added by HttpLink
|
|
686
|
-
delete rawResult.extensions[errors_2.PROTOCOL_ERRORS_SYMBOL];
|
|
687
|
-
}
|
|
688
|
-
if (rawResult.extensions &&
|
|
689
|
-
Object.keys(rawResult.extensions).length) {
|
|
690
|
-
result.extensions = rawResult.extensions;
|
|
691
|
-
}
|
|
692
|
-
if (result.error && errorPolicy === "none") {
|
|
693
|
-
result.data = undefined;
|
|
694
|
-
}
|
|
695
|
-
if (errorPolicy === "ignore") {
|
|
696
|
-
delete result.error;
|
|
697
|
-
}
|
|
698
|
-
return result;
|
|
699
|
-
}), (0, rxjs_1.catchError)((error) => {
|
|
700
|
-
if (errorPolicy === "ignore") {
|
|
701
|
-
return (0, rxjs_1.of)({ data: undefined });
|
|
702
|
-
}
|
|
703
|
-
return (0, rxjs_1.of)({ data: undefined, error });
|
|
704
|
-
}), (0, rxjs_1.filter)((result) => !!(result.data || result.error)));
|
|
705
|
-
if (this.getDocumentInfo(query).hasClientExports) {
|
|
706
|
-
if (environment_1.__DEV__) {
|
|
707
|
-
(0, invariant_1.invariant)(
|
|
708
|
-
this.localState,
|
|
709
|
-
89,
|
|
710
|
-
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
711
|
-
);
|
|
712
|
-
}
|
|
713
|
-
const observablePromise = this.localState.getExportedVariables({
|
|
666
|
+
let restart;
|
|
667
|
+
if (environment_1.__DEV__) {
|
|
668
|
+
(0, invariant_1.invariant)(
|
|
669
|
+
!this.getDocumentInfo(query).hasClientExports || this.localState,
|
|
670
|
+
89,
|
|
671
|
+
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
const observable = (this.getDocumentInfo(query).hasClientExports ?
|
|
675
|
+
(0, rxjs_2.from)(this.localState.getExportedVariables({
|
|
714
676
|
client: this.client,
|
|
715
677
|
document: query,
|
|
716
678
|
variables,
|
|
717
679
|
context,
|
|
718
|
-
})
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
680
|
+
}))
|
|
681
|
+
: (0, rxjs_2.of)(variables)).pipe((0, rxjs_2.mergeMap)((variables) => {
|
|
682
|
+
const { observable, restart: res } = this.getObservableFromLink(query, context, variables, extensions);
|
|
683
|
+
restart = res;
|
|
684
|
+
return observable.pipe((0, rxjs_2.map)((rawResult) => {
|
|
685
|
+
if (fetchPolicy !== "no-cache") {
|
|
686
|
+
// the subscription interface should handle not sending us results we no longer subscribe to.
|
|
687
|
+
// XXX I don't think we ever send in an object with errors, but we might in the future...
|
|
688
|
+
if ((0, QueryInfo_js_1.shouldWriteResult)(rawResult, errorPolicy)) {
|
|
689
|
+
this.cache.write({
|
|
690
|
+
query,
|
|
691
|
+
result: rawResult.data,
|
|
692
|
+
dataId: "ROOT_SUBSCRIPTION",
|
|
693
|
+
variables: variables,
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
this.broadcastQueries();
|
|
697
|
+
}
|
|
698
|
+
const result = {
|
|
699
|
+
data: rawResult.data ?? undefined,
|
|
700
|
+
};
|
|
701
|
+
if ((0, internal_1.graphQLResultHasError)(rawResult)) {
|
|
702
|
+
result.error = new errors_1.CombinedGraphQLErrors(rawResult);
|
|
703
|
+
}
|
|
704
|
+
else if ((0, errors_1.graphQLResultHasProtocolErrors)(rawResult)) {
|
|
705
|
+
result.error = rawResult.extensions[errors_2.PROTOCOL_ERRORS_SYMBOL];
|
|
706
|
+
// Don't emit protocol errors added by HttpLink
|
|
707
|
+
delete rawResult.extensions[errors_2.PROTOCOL_ERRORS_SYMBOL];
|
|
708
|
+
}
|
|
709
|
+
if (rawResult.extensions &&
|
|
710
|
+
Object.keys(rawResult.extensions).length) {
|
|
711
|
+
result.extensions = rawResult.extensions;
|
|
712
|
+
}
|
|
713
|
+
if (result.error && errorPolicy === "none") {
|
|
714
|
+
result.data = undefined;
|
|
715
|
+
}
|
|
716
|
+
if (errorPolicy === "ignore") {
|
|
717
|
+
delete result.error;
|
|
718
|
+
}
|
|
719
|
+
return result;
|
|
720
|
+
}), (0, rxjs_2.catchError)((error) => {
|
|
721
|
+
if (errorPolicy === "ignore") {
|
|
722
|
+
return (0, rxjs_2.of)({ data: undefined });
|
|
723
|
+
}
|
|
724
|
+
return (0, rxjs_2.of)({ data: undefined, error });
|
|
725
|
+
}), (0, rxjs_2.filter)((result) => !!(result.data || result.error)));
|
|
726
|
+
}));
|
|
727
|
+
return Object.assign(observable, { restart: () => restart?.() });
|
|
726
728
|
}
|
|
727
729
|
removeQuery(queryId) {
|
|
728
730
|
// teardown all links
|
|
@@ -753,8 +755,8 @@ class QueryManager {
|
|
|
753
755
|
// Prefer context.queryDeduplication if specified.
|
|
754
756
|
deduplication = context?.queryDeduplication ??
|
|
755
757
|
this.queryDeduplication) {
|
|
756
|
-
let
|
|
757
|
-
const { serverQuery, clientQuery } = this.getDocumentInfo(query);
|
|
758
|
+
let entry = {};
|
|
759
|
+
const { serverQuery, clientQuery, operationType } = this.getDocumentInfo(query);
|
|
758
760
|
const operationName = (0, internal_1.getOperationName)(query);
|
|
759
761
|
const executeContext = {
|
|
760
762
|
client: this.client,
|
|
@@ -774,29 +776,51 @@ class QueryManager {
|
|
|
774
776
|
extensions,
|
|
775
777
|
};
|
|
776
778
|
context = operation.context;
|
|
779
|
+
function withRestart(source) {
|
|
780
|
+
return new rxjs_1.Observable((observer) => {
|
|
781
|
+
function subscribe() {
|
|
782
|
+
return source.subscribe({
|
|
783
|
+
next: observer.next.bind(observer),
|
|
784
|
+
complete: observer.complete.bind(observer),
|
|
785
|
+
error: observer.error.bind(observer),
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
let subscription = subscribe();
|
|
789
|
+
entry.restart ||= () => {
|
|
790
|
+
subscription.unsubscribe();
|
|
791
|
+
subscription = subscribe();
|
|
792
|
+
};
|
|
793
|
+
return () => {
|
|
794
|
+
subscription.unsubscribe();
|
|
795
|
+
entry.restart = undefined;
|
|
796
|
+
};
|
|
797
|
+
});
|
|
798
|
+
}
|
|
777
799
|
if (deduplication) {
|
|
778
800
|
const printedServerQuery = (0, utilities_1.print)(serverQuery);
|
|
779
801
|
const varJson = (0, cache_1.canonicalStringify)(variables);
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
!("hasNext" in event.value) ||
|
|
786
|
-
!event.value.hasNext) &&
|
|
787
|
-
inFlightLinkObservables.peek(printedServerQuery, varJson) ===
|
|
788
|
-
entry) {
|
|
802
|
+
entry = inFlightLinkObservables.lookup(printedServerQuery, varJson);
|
|
803
|
+
if (!entry.observable) {
|
|
804
|
+
entry.observable = (0, link_1.execute)(link, operation, executeContext).pipe(withRestart, (0, rxjs_2.finalize)(() => {
|
|
805
|
+
if (inFlightLinkObservables.peek(printedServerQuery, varJson) ===
|
|
806
|
+
entry) {
|
|
789
807
|
inFlightLinkObservables.remove(printedServerQuery, varJson);
|
|
790
808
|
}
|
|
791
|
-
}),
|
|
809
|
+
}),
|
|
810
|
+
// We don't want to replay the last emitted value for
|
|
811
|
+
// subscriptions and instead opt to wait to receive updates until
|
|
812
|
+
// the subscription emits new values.
|
|
813
|
+
operationType === graphql_1.OperationTypeNode.SUBSCRIPTION ?
|
|
814
|
+
(0, rxjs_2.share)()
|
|
815
|
+
: (0, rxjs_2.shareReplay)({ refCount: true }));
|
|
792
816
|
}
|
|
793
817
|
}
|
|
794
818
|
else {
|
|
795
|
-
observable = (0, link_1.execute)(link, operation, executeContext);
|
|
819
|
+
entry.observable = (0, link_1.execute)(link, operation, executeContext).pipe(withRestart);
|
|
796
820
|
}
|
|
797
821
|
}
|
|
798
822
|
else {
|
|
799
|
-
observable = (0,
|
|
823
|
+
entry.observable = (0, rxjs_2.of)({ data: {} });
|
|
800
824
|
}
|
|
801
825
|
if (clientQuery) {
|
|
802
826
|
if (environment_1.__DEV__) {
|
|
@@ -808,8 +832,8 @@ class QueryManager {
|
|
|
808
832
|
operationName ?? "(anonymous)"
|
|
809
833
|
);
|
|
810
834
|
}
|
|
811
|
-
observable = observable.pipe((0,
|
|
812
|
-
return (0,
|
|
835
|
+
entry.observable = entry.observable.pipe((0, rxjs_2.mergeMap)((result) => {
|
|
836
|
+
return (0, rxjs_2.from)(this.localState.execute({
|
|
813
837
|
client: this.client,
|
|
814
838
|
document: clientQuery,
|
|
815
839
|
remoteResult: result,
|
|
@@ -818,11 +842,14 @@ class QueryManager {
|
|
|
818
842
|
}));
|
|
819
843
|
}));
|
|
820
844
|
}
|
|
821
|
-
return
|
|
822
|
-
|
|
823
|
-
(0,
|
|
824
|
-
|
|
825
|
-
|
|
845
|
+
return {
|
|
846
|
+
restart: () => entry.restart?.(),
|
|
847
|
+
observable: entry.observable.pipe((0, rxjs_2.catchError)((error) => {
|
|
848
|
+
error = (0, errors_1.toErrorLike)(error);
|
|
849
|
+
(0, errors_1.registerLinkError)(error);
|
|
850
|
+
throw error;
|
|
851
|
+
})),
|
|
852
|
+
};
|
|
826
853
|
}
|
|
827
854
|
getResultsFromLink(queryInfo, cacheWriteBehavior, options) {
|
|
828
855
|
const requestId = (queryInfo.lastRequestId = this.generateRequestId());
|
|
@@ -831,7 +858,7 @@ class QueryManager {
|
|
|
831
858
|
// missing fragment definitions (for example) before sending this document
|
|
832
859
|
// through the link chain.
|
|
833
860
|
const linkDocument = this.cache.transformForLink(options.query);
|
|
834
|
-
return this.getObservableFromLink(linkDocument, options.context, options.variables).pipe((0,
|
|
861
|
+
return this.getObservableFromLink(linkDocument, options.context, options.variables).observable.pipe((0, rxjs_2.map)((result) => {
|
|
835
862
|
const graphQLErrors = (0, internal_1.getGraphQLErrorsFromResult)(result);
|
|
836
863
|
const hasErrors = graphQLErrors.length > 0;
|
|
837
864
|
// If we interrupted this request by calling getResultsFromLink again
|
|
@@ -875,7 +902,7 @@ class QueryManager {
|
|
|
875
902
|
}
|
|
876
903
|
}
|
|
877
904
|
return aqr;
|
|
878
|
-
}), (0,
|
|
905
|
+
}), (0, rxjs_2.catchError)((error) => {
|
|
879
906
|
// Avoid storing errors from older interrupted queries.
|
|
880
907
|
if (requestId >= queryInfo.lastRequestId && errorPolicy === "none") {
|
|
881
908
|
queryInfo.resetLastWrite();
|
|
@@ -893,7 +920,7 @@ class QueryManager {
|
|
|
893
920
|
aqr.error = error;
|
|
894
921
|
aqr.networkStatus = networkStatus_js_1.NetworkStatus.error;
|
|
895
922
|
}
|
|
896
|
-
return (0,
|
|
923
|
+
return (0, rxjs_2.of)(aqr);
|
|
897
924
|
}));
|
|
898
925
|
}
|
|
899
926
|
fetchObservableWithInfo(queryInfo, options, {
|
|
@@ -959,7 +986,7 @@ class QueryManager {
|
|
|
959
986
|
fetchCancelSubject.complete();
|
|
960
987
|
cleanupCancelFn();
|
|
961
988
|
});
|
|
962
|
-
const fetchCancelSubject = new
|
|
989
|
+
const fetchCancelSubject = new rxjs_2.Subject();
|
|
963
990
|
let observable, containsDataFromLink;
|
|
964
991
|
// If the query has @export(as: ...) directives, then we need to
|
|
965
992
|
// process those directives asynchronously. When there are no
|
|
@@ -976,12 +1003,12 @@ class QueryManager {
|
|
|
976
1003
|
(0, internal_1.getOperationName)(normalized.query, "(anonymous)")
|
|
977
1004
|
);
|
|
978
1005
|
}
|
|
979
|
-
observable = (0,
|
|
1006
|
+
observable = (0, rxjs_2.from)(this.localState.getExportedVariables({
|
|
980
1007
|
client: this.client,
|
|
981
1008
|
document: normalized.query,
|
|
982
1009
|
variables: normalized.variables,
|
|
983
1010
|
context: normalized.context,
|
|
984
|
-
})).pipe((0,
|
|
1011
|
+
})).pipe((0, rxjs_2.mergeMap)((variables) => fromVariables(variables).observable));
|
|
985
1012
|
// there is just no way we can synchronously get the *right* value here,
|
|
986
1013
|
// so we will assume `true`, which is the behaviour before the bug fix in
|
|
987
1014
|
// #10597. This means that bug is not fixed in that case, and is probably
|
|
@@ -995,7 +1022,7 @@ class QueryManager {
|
|
|
995
1022
|
observable = sourcesWithInfo.observable;
|
|
996
1023
|
}
|
|
997
1024
|
return {
|
|
998
|
-
observable: observable.pipe((0,
|
|
1025
|
+
observable: observable.pipe((0, rxjs_2.tap)({ error: cleanupCancelFn, complete: cleanupCancelFn }), (0, rxjs_2.mergeWith)(fetchCancelSubject), (0, rxjs_2.share)()),
|
|
999
1026
|
fromLink: containsDataFromLink,
|
|
1000
1027
|
};
|
|
1001
1028
|
}
|
|
@@ -1188,7 +1215,7 @@ class QueryManager {
|
|
|
1188
1215
|
};
|
|
1189
1216
|
};
|
|
1190
1217
|
const fromData = (data) => {
|
|
1191
|
-
return (0,
|
|
1218
|
+
return (0, rxjs_2.of)({
|
|
1192
1219
|
kind: "N",
|
|
1193
1220
|
value: toResult(data),
|
|
1194
1221
|
source: "cache",
|
|
@@ -1208,7 +1235,7 @@ class QueryManager {
|
|
|
1208
1235
|
);
|
|
1209
1236
|
}
|
|
1210
1237
|
onCacheHit();
|
|
1211
|
-
return (0,
|
|
1238
|
+
return (0, rxjs_2.from)(this.localState.execute({
|
|
1212
1239
|
client: this.client,
|
|
1213
1240
|
document: query,
|
|
1214
1241
|
remoteResult: data ? { data } : undefined,
|
|
@@ -1239,7 +1266,7 @@ class QueryManager {
|
|
|
1239
1266
|
context,
|
|
1240
1267
|
fetchPolicy,
|
|
1241
1268
|
errorPolicy,
|
|
1242
|
-
}).pipe(validateDidEmitValue(), (0,
|
|
1269
|
+
}).pipe(validateDidEmitValue(), (0, rxjs_2.materialize)(), (0, rxjs_2.map)((result) => ({
|
|
1243
1270
|
...result,
|
|
1244
1271
|
source: "network",
|
|
1245
1272
|
})));
|
|
@@ -1256,7 +1283,7 @@ class QueryManager {
|
|
|
1256
1283
|
if (returnPartialData) {
|
|
1257
1284
|
return {
|
|
1258
1285
|
fromLink: true,
|
|
1259
|
-
observable: (0,
|
|
1286
|
+
observable: (0, rxjs_2.concat)(resultsFromCache(diff, networkStatus_js_1.NetworkStatus.loading), resultsFromLink()),
|
|
1260
1287
|
};
|
|
1261
1288
|
}
|
|
1262
1289
|
return { fromLink: true, observable: resultsFromLink() };
|
|
@@ -1266,7 +1293,7 @@ class QueryManager {
|
|
|
1266
1293
|
if (diff.complete || returnPartialData) {
|
|
1267
1294
|
return {
|
|
1268
1295
|
fromLink: true,
|
|
1269
|
-
observable: (0,
|
|
1296
|
+
observable: (0, rxjs_2.concat)(resultsFromCache(diff, networkStatus_js_1.NetworkStatus.loading), resultsFromLink()),
|
|
1270
1297
|
};
|
|
1271
1298
|
}
|
|
1272
1299
|
return { fromLink: true, observable: resultsFromLink() };
|
|
@@ -1274,14 +1301,14 @@ class QueryManager {
|
|
|
1274
1301
|
case "cache-only":
|
|
1275
1302
|
return {
|
|
1276
1303
|
fromLink: false,
|
|
1277
|
-
observable: (0,
|
|
1304
|
+
observable: (0, rxjs_2.concat)(resultsFromCache(readCache(), networkStatus_js_1.NetworkStatus.ready)),
|
|
1278
1305
|
};
|
|
1279
1306
|
case "network-only":
|
|
1280
1307
|
return { fromLink: true, observable: resultsFromLink() };
|
|
1281
1308
|
case "no-cache":
|
|
1282
1309
|
return { fromLink: true, observable: resultsFromLink() };
|
|
1283
1310
|
case "standby":
|
|
1284
|
-
return { fromLink: false, observable:
|
|
1311
|
+
return { fromLink: false, observable: rxjs_2.EMPTY };
|
|
1285
1312
|
}
|
|
1286
1313
|
}
|
|
1287
1314
|
getOrCreateQuery(queryId) {
|
|
@@ -1294,7 +1321,7 @@ class QueryManager {
|
|
|
1294
1321
|
exports.QueryManager = QueryManager;
|
|
1295
1322
|
function validateDidEmitValue() {
|
|
1296
1323
|
let didEmitValue = false;
|
|
1297
|
-
return (0,
|
|
1324
|
+
return (0, rxjs_2.tap)({
|
|
1298
1325
|
next() {
|
|
1299
1326
|
didEmitValue = true;
|
|
1300
1327
|
},
|