@apollo/client 3.11.0-rc.0 → 3.11.0-rc.2
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/.changeset/breezy-deers-dream.md +5 -0
- package/.changeset/curly-vans-draw.md +5 -0
- package/.changeset/early-tips-vanish.md +5 -0
- package/.changeset/good-suns-happen.md +5 -0
- package/.changeset/hungry-rings-help.md +5 -0
- package/.changeset/pink-flowers-switch.md +5 -0
- package/.changeset/pre.json +7 -0
- package/.changeset/proud-humans-begin.md +5 -0
- package/CHANGELOG.md +22 -0
- package/README.md +5 -5
- package/apollo-client.cjs +1393 -1405
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +2 -7
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +2 -7
- package/cache/core/cache.d.ts +0 -11
- package/cache/core/cache.js +2 -7
- package/cache/core/cache.js.map +1 -1
- package/config/jest/areApolloErrorsEqual.d.ts +3 -0
- package/config/jest/areApolloErrorsEqual.js +23 -0
- package/config/jest/areApolloErrorsEqual.js.map +1 -0
- package/config/jest/areGraphQlErrorsEqual.d.ts +3 -0
- package/config/jest/areGraphQlErrorsEqual.js +7 -0
- package/config/jest/areGraphQlErrorsEqual.js.map +1 -0
- package/config/jest/setup.js +4 -0
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.js +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/QueryManager.d.ts +15 -14
- package/core/QueryManager.js +12 -13
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +806 -806
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +806 -806
- package/core/watchQueryOptions.d.ts +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +1 -1
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +1 -1
- package/package.json +8 -5
- package/react/hooks/hooks.cjs +26 -33
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +26 -33
- package/react/hooks/useQuery.d.ts +2 -5
- package/react/hooks/useQuery.js +42 -53
- package/react/hooks/useQuery.js.map +1 -1
- package/react/internal/internal.cjs +1 -1
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +1 -1
- package/react/types/types.d.ts +6 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts +15 -0
- package/testing/core/mocking/mockQueryManager.js +5 -2
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/experimental/createSchemaFetch.js +5 -12
- package/testing/experimental/createSchemaFetch.js.map +1 -1
- package/testing/experimental/experimental.cjs +3 -5
- package/testing/experimental/experimental.cjs.map +1 -1
- package/testing/experimental/experimental.cjs.native.js +3 -5
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/version.js +1 -1
package/core/core.cjs
CHANGED
|
@@ -10,8 +10,8 @@ var equal = require('@wry/equality');
|
|
|
10
10
|
var utilities = require('../utilities');
|
|
11
11
|
var cache = require('../cache');
|
|
12
12
|
var errors = require('../errors');
|
|
13
|
-
var graphql = require('graphql');
|
|
14
13
|
var trie = require('@wry/trie');
|
|
14
|
+
var graphql = require('graphql');
|
|
15
15
|
var utils = require('../link/utils');
|
|
16
16
|
var tsInvariant = require('ts-invariant');
|
|
17
17
|
var graphqlTag = require('graphql-tag');
|
|
@@ -20,7 +20,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
20
20
|
|
|
21
21
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
22
22
|
|
|
23
|
-
var version = "3.11.0-rc.
|
|
23
|
+
var version = "3.11.0-rc.2";
|
|
24
24
|
|
|
25
25
|
function isNonNullObject(obj) {
|
|
26
26
|
return obj !== null && typeof obj === "object";
|
|
@@ -762,479 +762,165 @@ function skipCacheDataFor(fetchPolicy ) {
|
|
|
762
762
|
fetchPolicy === "standby");
|
|
763
763
|
}
|
|
764
764
|
|
|
765
|
-
var
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
765
|
+
var destructiveMethodCounts = new (utilities.canUseWeakMap ? WeakMap : Map)();
|
|
766
|
+
function wrapDestructiveCacheMethod(cache, methodName) {
|
|
767
|
+
var original = cache[methodName];
|
|
768
|
+
if (typeof original === "function") {
|
|
769
|
+
cache[methodName] = function () {
|
|
770
|
+
destructiveMethodCounts.set(cache,
|
|
771
|
+
(destructiveMethodCounts.get(cache) + 1) % 1e15);
|
|
772
|
+
return original.apply(this, arguments);
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
function cancelNotifyTimeout(info) {
|
|
777
|
+
if (info["notifyTimeout"]) {
|
|
778
|
+
clearTimeout(info["notifyTimeout"]);
|
|
779
|
+
info["notifyTimeout"] = void 0;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
var QueryInfo = (function () {
|
|
783
|
+
function QueryInfo(queryManager, queryId) {
|
|
784
|
+
if (queryId === void 0) { queryId = queryManager.generateQueryId(); }
|
|
785
|
+
this.queryId = queryId;
|
|
786
|
+
this.listeners = new Set();
|
|
787
|
+
this.document = null;
|
|
788
|
+
this.lastRequestId = 1;
|
|
789
|
+
this.stopped = false;
|
|
790
|
+
this.dirty = false;
|
|
791
|
+
this.observableQuery = null;
|
|
792
|
+
var cache = (this.cache = queryManager.cache);
|
|
793
|
+
if (!destructiveMethodCounts.has(cache)) {
|
|
794
|
+
destructiveMethodCounts.set(cache, 0);
|
|
795
|
+
wrapDestructiveCacheMethod(cache, "evict");
|
|
796
|
+
wrapDestructiveCacheMethod(cache, "modify");
|
|
797
|
+
wrapDestructiveCacheMethod(cache, "reset");
|
|
772
798
|
}
|
|
773
|
-
|
|
774
|
-
|
|
799
|
+
}
|
|
800
|
+
QueryInfo.prototype.init = function (query) {
|
|
801
|
+
var networkStatus = query.networkStatus || exports.NetworkStatus.loading;
|
|
802
|
+
if (this.variables &&
|
|
803
|
+
this.networkStatus !== exports.NetworkStatus.loading &&
|
|
804
|
+
!equal.equal(this.variables, query.variables)) {
|
|
805
|
+
networkStatus = exports.NetworkStatus.setVariables;
|
|
775
806
|
}
|
|
776
|
-
if (
|
|
777
|
-
this.
|
|
807
|
+
if (!equal.equal(query.variables, this.variables)) {
|
|
808
|
+
this.lastDiff = void 0;
|
|
778
809
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
810
|
+
Object.assign(this, {
|
|
811
|
+
document: query.document,
|
|
812
|
+
variables: query.variables,
|
|
813
|
+
networkError: null,
|
|
814
|
+
graphQLErrors: this.graphQLErrors || [],
|
|
815
|
+
networkStatus: networkStatus,
|
|
816
|
+
});
|
|
817
|
+
if (query.observableQuery) {
|
|
818
|
+
this.setObservableQuery(query.observableQuery);
|
|
787
819
|
}
|
|
788
|
-
|
|
789
|
-
this.
|
|
820
|
+
if (query.lastRequestId) {
|
|
821
|
+
this.lastRequestId = query.lastRequestId;
|
|
790
822
|
}
|
|
823
|
+
return this;
|
|
791
824
|
};
|
|
792
|
-
|
|
793
|
-
this
|
|
794
|
-
this.
|
|
825
|
+
QueryInfo.prototype.reset = function () {
|
|
826
|
+
cancelNotifyTimeout(this);
|
|
827
|
+
this.dirty = false;
|
|
795
828
|
};
|
|
796
|
-
|
|
797
|
-
|
|
829
|
+
QueryInfo.prototype.resetDiff = function () {
|
|
830
|
+
this.lastDiff = void 0;
|
|
798
831
|
};
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
return
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
}
|
|
808
|
-
}
|
|
832
|
+
QueryInfo.prototype.getDiff = function () {
|
|
833
|
+
var options = this.getDiffOptions();
|
|
834
|
+
if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
|
|
835
|
+
return this.lastDiff.diff;
|
|
836
|
+
}
|
|
837
|
+
this.updateWatch(this.variables);
|
|
838
|
+
var oq = this.observableQuery;
|
|
839
|
+
if (oq && oq.options.fetchPolicy === "no-cache") {
|
|
840
|
+
return { complete: false };
|
|
841
|
+
}
|
|
842
|
+
var diff = this.cache.diff(options);
|
|
843
|
+
this.updateLastDiff(diff, options);
|
|
844
|
+
return diff;
|
|
809
845
|
};
|
|
810
|
-
|
|
811
|
-
this.
|
|
846
|
+
QueryInfo.prototype.updateLastDiff = function (diff, options) {
|
|
847
|
+
this.lastDiff =
|
|
848
|
+
diff ?
|
|
849
|
+
{
|
|
850
|
+
diff: diff,
|
|
851
|
+
options: options || this.getDiffOptions(),
|
|
852
|
+
}
|
|
853
|
+
: void 0;
|
|
812
854
|
};
|
|
813
|
-
|
|
814
|
-
|
|
855
|
+
QueryInfo.prototype.getDiffOptions = function (variables) {
|
|
856
|
+
var _a;
|
|
857
|
+
if (variables === void 0) { variables = this.variables; }
|
|
858
|
+
return {
|
|
859
|
+
query: this.document,
|
|
860
|
+
variables: variables,
|
|
861
|
+
returnPartialData: true,
|
|
862
|
+
optimistic: true,
|
|
863
|
+
canonizeResults: (_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.options.canonizeResults,
|
|
864
|
+
};
|
|
815
865
|
};
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
866
|
+
QueryInfo.prototype.setDiff = function (diff) {
|
|
867
|
+
var _this = this;
|
|
868
|
+
var _a;
|
|
869
|
+
var oldDiff = this.lastDiff && this.lastDiff.diff;
|
|
870
|
+
if (diff && !diff.complete && ((_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.getLastError())) {
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
this.updateLastDiff(diff);
|
|
874
|
+
if (!this.dirty && !equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
|
|
875
|
+
this.dirty = true;
|
|
876
|
+
if (!this.notifyTimeout) {
|
|
877
|
+
this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
|
|
820
878
|
}
|
|
821
879
|
}
|
|
822
|
-
return null;
|
|
823
|
-
};
|
|
824
|
-
LocalState.prototype.serverQuery = function (document) {
|
|
825
|
-
return utilities.removeClientSetsFromDocument(document);
|
|
826
880
|
};
|
|
827
|
-
|
|
828
|
-
var
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
if (
|
|
840
|
-
|
|
881
|
+
QueryInfo.prototype.setObservableQuery = function (oq) {
|
|
882
|
+
var _this = this;
|
|
883
|
+
if (oq === this.observableQuery)
|
|
884
|
+
return;
|
|
885
|
+
if (this.oqListener) {
|
|
886
|
+
this.listeners.delete(this.oqListener);
|
|
887
|
+
}
|
|
888
|
+
this.observableQuery = oq;
|
|
889
|
+
if (oq) {
|
|
890
|
+
oq["queryInfo"] = this;
|
|
891
|
+
this.listeners.add((this.oqListener = function () {
|
|
892
|
+
var diff = _this.getDiff();
|
|
893
|
+
if (diff.fromOptimisticTransaction) {
|
|
894
|
+
oq["observe"]();
|
|
841
895
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
896
|
+
else {
|
|
897
|
+
reobserveCacheFirst(oq);
|
|
898
|
+
}
|
|
899
|
+
}));
|
|
900
|
+
}
|
|
901
|
+
else {
|
|
902
|
+
delete this.oqListener;
|
|
903
|
+
}
|
|
845
904
|
};
|
|
846
|
-
|
|
847
|
-
var
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
return arg.name.value === "always" &&
|
|
854
|
-
arg.value.kind === "BooleanValue" &&
|
|
855
|
-
arg.value.value === true;
|
|
856
|
-
});
|
|
857
|
-
if (forceResolvers) {
|
|
858
|
-
return graphql.BREAK;
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
},
|
|
862
|
-
},
|
|
863
|
-
});
|
|
864
|
-
return forceResolvers;
|
|
905
|
+
QueryInfo.prototype.notify = function () {
|
|
906
|
+
var _this = this;
|
|
907
|
+
cancelNotifyTimeout(this);
|
|
908
|
+
if (this.shouldNotify()) {
|
|
909
|
+
this.listeners.forEach(function (listener) { return listener(_this); });
|
|
910
|
+
}
|
|
911
|
+
this.dirty = false;
|
|
865
912
|
};
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
if (context === void 0) { context = {}; }
|
|
878
|
-
if (variables === void 0) { variables = {}; }
|
|
879
|
-
if (fragmentMatcher === void 0) { fragmentMatcher = function () { return true; }; }
|
|
880
|
-
if (onlyRunForcedResolvers === void 0) { onlyRunForcedResolvers = false; }
|
|
881
|
-
return tslib.__generator(this, function (_b) {
|
|
882
|
-
mainDefinition = utilities.getMainDefinition(document);
|
|
883
|
-
fragments = utilities.getFragmentDefinitions(document);
|
|
884
|
-
fragmentMap = utilities.createFragmentMap(fragments);
|
|
885
|
-
selectionsToResolve = this.collectSelectionsToResolve(mainDefinition, fragmentMap);
|
|
886
|
-
definitionOperation = mainDefinition.operation;
|
|
887
|
-
defaultOperationType = definitionOperation ?
|
|
888
|
-
definitionOperation.charAt(0).toUpperCase() +
|
|
889
|
-
definitionOperation.slice(1)
|
|
890
|
-
: "Query";
|
|
891
|
-
_a = this, cache = _a.cache, client = _a.client;
|
|
892
|
-
execContext = {
|
|
893
|
-
fragmentMap: fragmentMap,
|
|
894
|
-
context: tslib.__assign(tslib.__assign({}, context), { cache: cache, client: client }),
|
|
895
|
-
variables: variables,
|
|
896
|
-
fragmentMatcher: fragmentMatcher,
|
|
897
|
-
defaultOperationType: defaultOperationType,
|
|
898
|
-
exportedVariables: {},
|
|
899
|
-
selectionsToResolve: selectionsToResolve,
|
|
900
|
-
onlyRunForcedResolvers: onlyRunForcedResolvers,
|
|
901
|
-
};
|
|
902
|
-
isClientFieldDescendant = false;
|
|
903
|
-
return [2 , this.resolveSelectionSet(mainDefinition.selectionSet, isClientFieldDescendant, rootValue, execContext).then(function (result) { return ({
|
|
904
|
-
result: result,
|
|
905
|
-
exportedVariables: execContext.exportedVariables,
|
|
906
|
-
}); })];
|
|
907
|
-
});
|
|
908
|
-
});
|
|
909
|
-
};
|
|
910
|
-
LocalState.prototype.resolveSelectionSet = function (selectionSet, isClientFieldDescendant, rootValue, execContext) {
|
|
911
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
912
|
-
var fragmentMap, context, variables, resultsToMerge, execute;
|
|
913
|
-
var _this = this;
|
|
914
|
-
return tslib.__generator(this, function (_a) {
|
|
915
|
-
fragmentMap = execContext.fragmentMap, context = execContext.context, variables = execContext.variables;
|
|
916
|
-
resultsToMerge = [rootValue];
|
|
917
|
-
execute = function (selection) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
918
|
-
var fragment, typeCondition;
|
|
919
|
-
return tslib.__generator(this, function (_a) {
|
|
920
|
-
if (!isClientFieldDescendant &&
|
|
921
|
-
!execContext.selectionsToResolve.has(selection)) {
|
|
922
|
-
return [2 ];
|
|
923
|
-
}
|
|
924
|
-
if (!utilities.shouldInclude(selection, variables)) {
|
|
925
|
-
return [2 ];
|
|
926
|
-
}
|
|
927
|
-
if (utilities.isField(selection)) {
|
|
928
|
-
return [2 , this.resolveField(selection, isClientFieldDescendant, rootValue, execContext).then(function (fieldResult) {
|
|
929
|
-
var _a;
|
|
930
|
-
if (typeof fieldResult !== "undefined") {
|
|
931
|
-
resultsToMerge.push((_a = {},
|
|
932
|
-
_a[utilities.resultKeyNameFromField(selection)] = fieldResult,
|
|
933
|
-
_a));
|
|
934
|
-
}
|
|
935
|
-
})];
|
|
936
|
-
}
|
|
937
|
-
if (utilities.isInlineFragment(selection)) {
|
|
938
|
-
fragment = selection;
|
|
939
|
-
}
|
|
940
|
-
else {
|
|
941
|
-
fragment = fragmentMap[selection.name.value];
|
|
942
|
-
globals.invariant(fragment, 18, selection.name.value);
|
|
943
|
-
}
|
|
944
|
-
if (fragment && fragment.typeCondition) {
|
|
945
|
-
typeCondition = fragment.typeCondition.name.value;
|
|
946
|
-
if (execContext.fragmentMatcher(rootValue, typeCondition, context)) {
|
|
947
|
-
return [2 , this.resolveSelectionSet(fragment.selectionSet, isClientFieldDescendant, rootValue, execContext).then(function (fragmentResult) {
|
|
948
|
-
resultsToMerge.push(fragmentResult);
|
|
949
|
-
})];
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
return [2 ];
|
|
953
|
-
});
|
|
954
|
-
}); };
|
|
955
|
-
return [2 , Promise.all(selectionSet.selections.map(execute)).then(function () {
|
|
956
|
-
return utilities.mergeDeepArray(resultsToMerge);
|
|
957
|
-
})];
|
|
958
|
-
});
|
|
959
|
-
});
|
|
960
|
-
};
|
|
961
|
-
LocalState.prototype.resolveField = function (field, isClientFieldDescendant, rootValue, execContext) {
|
|
962
|
-
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
963
|
-
var variables, fieldName, aliasedFieldName, aliasUsed, defaultResult, resultPromise, resolverType, resolverMap, resolve;
|
|
964
|
-
var _this = this;
|
|
965
|
-
return tslib.__generator(this, function (_a) {
|
|
966
|
-
if (!rootValue) {
|
|
967
|
-
return [2 , null];
|
|
968
|
-
}
|
|
969
|
-
variables = execContext.variables;
|
|
970
|
-
fieldName = field.name.value;
|
|
971
|
-
aliasedFieldName = utilities.resultKeyNameFromField(field);
|
|
972
|
-
aliasUsed = fieldName !== aliasedFieldName;
|
|
973
|
-
defaultResult = rootValue[aliasedFieldName] || rootValue[fieldName];
|
|
974
|
-
resultPromise = Promise.resolve(defaultResult);
|
|
975
|
-
if (!execContext.onlyRunForcedResolvers ||
|
|
976
|
-
this.shouldForceResolvers(field)) {
|
|
977
|
-
resolverType = rootValue.__typename || execContext.defaultOperationType;
|
|
978
|
-
resolverMap = this.resolvers && this.resolvers[resolverType];
|
|
979
|
-
if (resolverMap) {
|
|
980
|
-
resolve = resolverMap[aliasUsed ? fieldName : aliasedFieldName];
|
|
981
|
-
if (resolve) {
|
|
982
|
-
resultPromise = Promise.resolve(
|
|
983
|
-
cache.cacheSlot.withValue(this.cache, resolve, [
|
|
984
|
-
rootValue,
|
|
985
|
-
utilities.argumentsObjectFromField(field, variables),
|
|
986
|
-
execContext.context,
|
|
987
|
-
{ field: field, fragmentMap: execContext.fragmentMap },
|
|
988
|
-
]));
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
return [2 , resultPromise.then(function (result) {
|
|
993
|
-
var _a, _b;
|
|
994
|
-
if (result === void 0) { result = defaultResult; }
|
|
995
|
-
if (field.directives) {
|
|
996
|
-
field.directives.forEach(function (directive) {
|
|
997
|
-
if (directive.name.value === "export" && directive.arguments) {
|
|
998
|
-
directive.arguments.forEach(function (arg) {
|
|
999
|
-
if (arg.name.value === "as" && arg.value.kind === "StringValue") {
|
|
1000
|
-
execContext.exportedVariables[arg.value.value] = result;
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
if (!field.selectionSet) {
|
|
1007
|
-
return result;
|
|
1008
|
-
}
|
|
1009
|
-
if (result == null) {
|
|
1010
|
-
return result;
|
|
1011
|
-
}
|
|
1012
|
-
var isClientField = (_b = (_a = field.directives) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.name.value === "client"; })) !== null && _b !== void 0 ? _b : false;
|
|
1013
|
-
if (Array.isArray(result)) {
|
|
1014
|
-
return _this.resolveSubSelectedArray(field, isClientFieldDescendant || isClientField, result, execContext);
|
|
1015
|
-
}
|
|
1016
|
-
if (field.selectionSet) {
|
|
1017
|
-
return _this.resolveSelectionSet(field.selectionSet, isClientFieldDescendant || isClientField, result, execContext);
|
|
1018
|
-
}
|
|
1019
|
-
})];
|
|
1020
|
-
});
|
|
1021
|
-
});
|
|
1022
|
-
};
|
|
1023
|
-
LocalState.prototype.resolveSubSelectedArray = function (field, isClientFieldDescendant, result, execContext) {
|
|
1024
|
-
var _this = this;
|
|
1025
|
-
return Promise.all(result.map(function (item) {
|
|
1026
|
-
if (item === null) {
|
|
1027
|
-
return null;
|
|
1028
|
-
}
|
|
1029
|
-
if (Array.isArray(item)) {
|
|
1030
|
-
return _this.resolveSubSelectedArray(field, isClientFieldDescendant, item, execContext);
|
|
1031
|
-
}
|
|
1032
|
-
if (field.selectionSet) {
|
|
1033
|
-
return _this.resolveSelectionSet(field.selectionSet, isClientFieldDescendant, item, execContext);
|
|
1034
|
-
}
|
|
1035
|
-
}));
|
|
1036
|
-
};
|
|
1037
|
-
LocalState.prototype.collectSelectionsToResolve = function (mainDefinition, fragmentMap) {
|
|
1038
|
-
var isSingleASTNode = function (node) { return !Array.isArray(node); };
|
|
1039
|
-
var selectionsToResolveCache = this.selectionsToResolveCache;
|
|
1040
|
-
function collectByDefinition(definitionNode) {
|
|
1041
|
-
if (!selectionsToResolveCache.has(definitionNode)) {
|
|
1042
|
-
var matches_1 = new Set();
|
|
1043
|
-
selectionsToResolveCache.set(definitionNode, matches_1);
|
|
1044
|
-
graphql.visit(definitionNode, {
|
|
1045
|
-
Directive: function (node, _, __, ___, ancestors) {
|
|
1046
|
-
if (node.name.value === "client") {
|
|
1047
|
-
ancestors.forEach(function (node) {
|
|
1048
|
-
if (isSingleASTNode(node) && graphql.isSelectionNode(node)) {
|
|
1049
|
-
matches_1.add(node);
|
|
1050
|
-
}
|
|
1051
|
-
});
|
|
1052
|
-
}
|
|
1053
|
-
},
|
|
1054
|
-
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
1055
|
-
var fragment = fragmentMap[spread.name.value];
|
|
1056
|
-
globals.invariant(fragment, 19, spread.name.value);
|
|
1057
|
-
var fragmentSelections = collectByDefinition(fragment);
|
|
1058
|
-
if (fragmentSelections.size > 0) {
|
|
1059
|
-
ancestors.forEach(function (node) {
|
|
1060
|
-
if (isSingleASTNode(node) && graphql.isSelectionNode(node)) {
|
|
1061
|
-
matches_1.add(node);
|
|
1062
|
-
}
|
|
1063
|
-
});
|
|
1064
|
-
matches_1.add(spread);
|
|
1065
|
-
fragmentSelections.forEach(function (selection) {
|
|
1066
|
-
matches_1.add(selection);
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
},
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
return selectionsToResolveCache.get(definitionNode);
|
|
1073
|
-
}
|
|
1074
|
-
return collectByDefinition(mainDefinition);
|
|
1075
|
-
};
|
|
1076
|
-
return LocalState;
|
|
1077
|
-
}());
|
|
1078
|
-
|
|
1079
|
-
var destructiveMethodCounts = new (utilities.canUseWeakMap ? WeakMap : Map)();
|
|
1080
|
-
function wrapDestructiveCacheMethod(cache, methodName) {
|
|
1081
|
-
var original = cache[methodName];
|
|
1082
|
-
if (typeof original === "function") {
|
|
1083
|
-
cache[methodName] = function () {
|
|
1084
|
-
destructiveMethodCounts.set(cache,
|
|
1085
|
-
(destructiveMethodCounts.get(cache) + 1) % 1e15);
|
|
1086
|
-
return original.apply(this, arguments);
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
function cancelNotifyTimeout(info) {
|
|
1091
|
-
if (info["notifyTimeout"]) {
|
|
1092
|
-
clearTimeout(info["notifyTimeout"]);
|
|
1093
|
-
info["notifyTimeout"] = void 0;
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
var QueryInfo = (function () {
|
|
1097
|
-
function QueryInfo(queryManager, queryId) {
|
|
1098
|
-
if (queryId === void 0) { queryId = queryManager.generateQueryId(); }
|
|
1099
|
-
this.queryId = queryId;
|
|
1100
|
-
this.listeners = new Set();
|
|
1101
|
-
this.document = null;
|
|
1102
|
-
this.lastRequestId = 1;
|
|
1103
|
-
this.stopped = false;
|
|
1104
|
-
this.dirty = false;
|
|
1105
|
-
this.observableQuery = null;
|
|
1106
|
-
var cache = (this.cache = queryManager.cache);
|
|
1107
|
-
if (!destructiveMethodCounts.has(cache)) {
|
|
1108
|
-
destructiveMethodCounts.set(cache, 0);
|
|
1109
|
-
wrapDestructiveCacheMethod(cache, "evict");
|
|
1110
|
-
wrapDestructiveCacheMethod(cache, "modify");
|
|
1111
|
-
wrapDestructiveCacheMethod(cache, "reset");
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
QueryInfo.prototype.init = function (query) {
|
|
1115
|
-
var networkStatus = query.networkStatus || exports.NetworkStatus.loading;
|
|
1116
|
-
if (this.variables &&
|
|
1117
|
-
this.networkStatus !== exports.NetworkStatus.loading &&
|
|
1118
|
-
!equal.equal(this.variables, query.variables)) {
|
|
1119
|
-
networkStatus = exports.NetworkStatus.setVariables;
|
|
1120
|
-
}
|
|
1121
|
-
if (!equal.equal(query.variables, this.variables)) {
|
|
1122
|
-
this.lastDiff = void 0;
|
|
1123
|
-
}
|
|
1124
|
-
Object.assign(this, {
|
|
1125
|
-
document: query.document,
|
|
1126
|
-
variables: query.variables,
|
|
1127
|
-
networkError: null,
|
|
1128
|
-
graphQLErrors: this.graphQLErrors || [],
|
|
1129
|
-
networkStatus: networkStatus,
|
|
1130
|
-
});
|
|
1131
|
-
if (query.observableQuery) {
|
|
1132
|
-
this.setObservableQuery(query.observableQuery);
|
|
1133
|
-
}
|
|
1134
|
-
if (query.lastRequestId) {
|
|
1135
|
-
this.lastRequestId = query.lastRequestId;
|
|
1136
|
-
}
|
|
1137
|
-
return this;
|
|
1138
|
-
};
|
|
1139
|
-
QueryInfo.prototype.reset = function () {
|
|
1140
|
-
cancelNotifyTimeout(this);
|
|
1141
|
-
this.dirty = false;
|
|
1142
|
-
};
|
|
1143
|
-
QueryInfo.prototype.resetDiff = function () {
|
|
1144
|
-
this.lastDiff = void 0;
|
|
1145
|
-
};
|
|
1146
|
-
QueryInfo.prototype.getDiff = function () {
|
|
1147
|
-
var options = this.getDiffOptions();
|
|
1148
|
-
if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
|
|
1149
|
-
return this.lastDiff.diff;
|
|
1150
|
-
}
|
|
1151
|
-
this.updateWatch(this.variables);
|
|
1152
|
-
var oq = this.observableQuery;
|
|
1153
|
-
if (oq && oq.options.fetchPolicy === "no-cache") {
|
|
1154
|
-
return { complete: false };
|
|
1155
|
-
}
|
|
1156
|
-
var diff = this.cache.diff(options);
|
|
1157
|
-
this.updateLastDiff(diff, options);
|
|
1158
|
-
return diff;
|
|
1159
|
-
};
|
|
1160
|
-
QueryInfo.prototype.updateLastDiff = function (diff, options) {
|
|
1161
|
-
this.lastDiff =
|
|
1162
|
-
diff ?
|
|
1163
|
-
{
|
|
1164
|
-
diff: diff,
|
|
1165
|
-
options: options || this.getDiffOptions(),
|
|
1166
|
-
}
|
|
1167
|
-
: void 0;
|
|
1168
|
-
};
|
|
1169
|
-
QueryInfo.prototype.getDiffOptions = function (variables) {
|
|
1170
|
-
var _a;
|
|
1171
|
-
if (variables === void 0) { variables = this.variables; }
|
|
1172
|
-
return {
|
|
1173
|
-
query: this.document,
|
|
1174
|
-
variables: variables,
|
|
1175
|
-
returnPartialData: true,
|
|
1176
|
-
optimistic: true,
|
|
1177
|
-
canonizeResults: (_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.options.canonizeResults,
|
|
1178
|
-
};
|
|
1179
|
-
};
|
|
1180
|
-
QueryInfo.prototype.setDiff = function (diff) {
|
|
1181
|
-
var _this = this;
|
|
1182
|
-
var _a;
|
|
1183
|
-
var oldDiff = this.lastDiff && this.lastDiff.diff;
|
|
1184
|
-
if (diff && !diff.complete && ((_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.getLastError())) {
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
this.updateLastDiff(diff);
|
|
1188
|
-
if (!this.dirty && !equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
|
|
1189
|
-
this.dirty = true;
|
|
1190
|
-
if (!this.notifyTimeout) {
|
|
1191
|
-
this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
};
|
|
1195
|
-
QueryInfo.prototype.setObservableQuery = function (oq) {
|
|
1196
|
-
var _this = this;
|
|
1197
|
-
if (oq === this.observableQuery)
|
|
1198
|
-
return;
|
|
1199
|
-
if (this.oqListener) {
|
|
1200
|
-
this.listeners.delete(this.oqListener);
|
|
1201
|
-
}
|
|
1202
|
-
this.observableQuery = oq;
|
|
1203
|
-
if (oq) {
|
|
1204
|
-
oq["queryInfo"] = this;
|
|
1205
|
-
this.listeners.add((this.oqListener = function () {
|
|
1206
|
-
var diff = _this.getDiff();
|
|
1207
|
-
if (diff.fromOptimisticTransaction) {
|
|
1208
|
-
oq["observe"]();
|
|
1209
|
-
}
|
|
1210
|
-
else {
|
|
1211
|
-
reobserveCacheFirst(oq);
|
|
1212
|
-
}
|
|
1213
|
-
}));
|
|
1214
|
-
}
|
|
1215
|
-
else {
|
|
1216
|
-
delete this.oqListener;
|
|
1217
|
-
}
|
|
1218
|
-
};
|
|
1219
|
-
QueryInfo.prototype.notify = function () {
|
|
1220
|
-
var _this = this;
|
|
1221
|
-
cancelNotifyTimeout(this);
|
|
1222
|
-
if (this.shouldNotify()) {
|
|
1223
|
-
this.listeners.forEach(function (listener) { return listener(_this); });
|
|
1224
|
-
}
|
|
1225
|
-
this.dirty = false;
|
|
1226
|
-
};
|
|
1227
|
-
QueryInfo.prototype.shouldNotify = function () {
|
|
1228
|
-
if (!this.dirty || !this.listeners.size) {
|
|
1229
|
-
return false;
|
|
1230
|
-
}
|
|
1231
|
-
if (isNetworkRequestInFlight(this.networkStatus) && this.observableQuery) {
|
|
1232
|
-
var fetchPolicy = this.observableQuery.options.fetchPolicy;
|
|
1233
|
-
if (fetchPolicy !== "cache-only" && fetchPolicy !== "cache-and-network") {
|
|
1234
|
-
return false;
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
return true;
|
|
913
|
+
QueryInfo.prototype.shouldNotify = function () {
|
|
914
|
+
if (!this.dirty || !this.listeners.size) {
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
917
|
+
if (isNetworkRequestInFlight(this.networkStatus) && this.observableQuery) {
|
|
918
|
+
var fetchPolicy = this.observableQuery.options.fetchPolicy;
|
|
919
|
+
if (fetchPolicy !== "cache-only" && fetchPolicy !== "cache-and-network") {
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
return true;
|
|
1238
924
|
};
|
|
1239
925
|
QueryInfo.prototype.stop = function () {
|
|
1240
926
|
if (!this.stopped) {
|
|
@@ -1357,8 +1043,7 @@ function shouldWriteResult(result, errorPolicy) {
|
|
|
1357
1043
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1358
1044
|
var IGNORE = Object.create(null);
|
|
1359
1045
|
var QueryManager = (function () {
|
|
1360
|
-
function QueryManager(
|
|
1361
|
-
var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, documentTransform = _a.documentTransform, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, onBroadcast = _a.onBroadcast, _c = _a.ssrMode, ssrMode = _c === void 0 ? false : _c, _d = _a.clientAwareness, clientAwareness = _d === void 0 ? {} : _d, localState = _a.localState, _e = _a.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? !!cache.assumeImmutableResults : _e, defaultContext = _a.defaultContext;
|
|
1046
|
+
function QueryManager(options) {
|
|
1362
1047
|
var _this = this;
|
|
1363
1048
|
this.clientAwareness = {};
|
|
1364
1049
|
this.queries = new Map();
|
|
@@ -1371,22 +1056,23 @@ var QueryManager = (function () {
|
|
|
1371
1056
|
this.inFlightLinkObservables = new trie.Trie(false);
|
|
1372
1057
|
var defaultDocumentTransform = new utilities.DocumentTransform(function (document) { return _this.cache.transformDocument(document); },
|
|
1373
1058
|
{ cache: false });
|
|
1374
|
-
this.cache = cache;
|
|
1375
|
-
this.link = link;
|
|
1376
|
-
this.defaultOptions = defaultOptions
|
|
1377
|
-
this.queryDeduplication = queryDeduplication;
|
|
1378
|
-
this.clientAwareness = clientAwareness;
|
|
1379
|
-
this.localState = localState
|
|
1380
|
-
this.ssrMode = ssrMode;
|
|
1381
|
-
this.assumeImmutableResults = assumeImmutableResults;
|
|
1059
|
+
this.cache = options.cache;
|
|
1060
|
+
this.link = options.link;
|
|
1061
|
+
this.defaultOptions = options.defaultOptions;
|
|
1062
|
+
this.queryDeduplication = options.queryDeduplication;
|
|
1063
|
+
this.clientAwareness = options.clientAwareness;
|
|
1064
|
+
this.localState = options.localState;
|
|
1065
|
+
this.ssrMode = options.ssrMode;
|
|
1066
|
+
this.assumeImmutableResults = options.assumeImmutableResults;
|
|
1067
|
+
var documentTransform = options.documentTransform;
|
|
1382
1068
|
this.documentTransform =
|
|
1383
1069
|
documentTransform ?
|
|
1384
1070
|
defaultDocumentTransform
|
|
1385
1071
|
.concat(documentTransform)
|
|
1386
1072
|
.concat(defaultDocumentTransform)
|
|
1387
1073
|
: defaultDocumentTransform;
|
|
1388
|
-
this.defaultContext = defaultContext || Object.create(null);
|
|
1389
|
-
if ((this.onBroadcast = onBroadcast)) {
|
|
1074
|
+
this.defaultContext = options.defaultContext || Object.create(null);
|
|
1075
|
+
if ((this.onBroadcast = options.onBroadcast)) {
|
|
1390
1076
|
this.mutationStore = Object.create(null);
|
|
1391
1077
|
}
|
|
1392
1078
|
}
|
|
@@ -1889,379 +1575,693 @@ var QueryManager = (function () {
|
|
|
1889
1575
|
if (hasProtocolErrors) {
|
|
1890
1576
|
errors$1.protocolErrors = result.extensions[errors.PROTOCOL_ERRORS_SYMBOL];
|
|
1891
1577
|
}
|
|
1892
|
-
if (errorPolicy === "none" || hasProtocolErrors) {
|
|
1893
|
-
throw new errors.ApolloError(errors$1);
|
|
1578
|
+
if (errorPolicy === "none" || hasProtocolErrors) {
|
|
1579
|
+
throw new errors.ApolloError(errors$1);
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
if (errorPolicy === "ignore") {
|
|
1583
|
+
delete result.errors;
|
|
1584
|
+
}
|
|
1585
|
+
return result;
|
|
1586
|
+
});
|
|
1587
|
+
};
|
|
1588
|
+
if (this.getDocumentInfo(query).hasClientExports) {
|
|
1589
|
+
var observablePromise_1 = this.localState
|
|
1590
|
+
.addExportedVariables(query, variables, context)
|
|
1591
|
+
.then(makeObservable);
|
|
1592
|
+
return new utilities.Observable(function (observer) {
|
|
1593
|
+
var sub = null;
|
|
1594
|
+
observablePromise_1.then(function (observable) { return (sub = observable.subscribe(observer)); }, observer.error);
|
|
1595
|
+
return function () { return sub && sub.unsubscribe(); };
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
return makeObservable(variables);
|
|
1599
|
+
};
|
|
1600
|
+
QueryManager.prototype.stopQuery = function (queryId) {
|
|
1601
|
+
this.stopQueryNoBroadcast(queryId);
|
|
1602
|
+
this.broadcastQueries();
|
|
1603
|
+
};
|
|
1604
|
+
QueryManager.prototype.stopQueryNoBroadcast = function (queryId) {
|
|
1605
|
+
this.stopQueryInStoreNoBroadcast(queryId);
|
|
1606
|
+
this.removeQuery(queryId);
|
|
1607
|
+
};
|
|
1608
|
+
QueryManager.prototype.removeQuery = function (queryId) {
|
|
1609
|
+
this.fetchCancelFns.delete(queryId);
|
|
1610
|
+
if (this.queries.has(queryId)) {
|
|
1611
|
+
this.getQuery(queryId).stop();
|
|
1612
|
+
this.queries.delete(queryId);
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
QueryManager.prototype.broadcastQueries = function () {
|
|
1616
|
+
if (this.onBroadcast)
|
|
1617
|
+
this.onBroadcast();
|
|
1618
|
+
this.queries.forEach(function (info) { return info.notify(); });
|
|
1619
|
+
};
|
|
1620
|
+
QueryManager.prototype.getLocalState = function () {
|
|
1621
|
+
return this.localState;
|
|
1622
|
+
};
|
|
1623
|
+
QueryManager.prototype.getObservableFromLink = function (query, context, variables, extensions,
|
|
1624
|
+
deduplication) {
|
|
1625
|
+
var _this = this;
|
|
1626
|
+
var _a;
|
|
1627
|
+
if (deduplication === void 0) { deduplication = (_a = context === null || context === void 0 ? void 0 : context.queryDeduplication) !== null && _a !== void 0 ? _a : this.queryDeduplication; }
|
|
1628
|
+
var observable;
|
|
1629
|
+
var _b = this.getDocumentInfo(query), serverQuery = _b.serverQuery, clientQuery = _b.clientQuery;
|
|
1630
|
+
if (serverQuery) {
|
|
1631
|
+
var _c = this, inFlightLinkObservables_1 = _c.inFlightLinkObservables, link = _c.link;
|
|
1632
|
+
var operation = {
|
|
1633
|
+
query: serverQuery,
|
|
1634
|
+
variables: variables,
|
|
1635
|
+
operationName: utilities.getOperationName(serverQuery) || void 0,
|
|
1636
|
+
context: this.prepareContext(tslib.__assign(tslib.__assign({}, context), { forceFetch: !deduplication })),
|
|
1637
|
+
extensions: extensions,
|
|
1638
|
+
};
|
|
1639
|
+
context = operation.context;
|
|
1640
|
+
if (deduplication) {
|
|
1641
|
+
var printedServerQuery_1 = utilities.print(serverQuery);
|
|
1642
|
+
var varJson_1 = cache.canonicalStringify(variables);
|
|
1643
|
+
var entry = inFlightLinkObservables_1.lookup(printedServerQuery_1, varJson_1);
|
|
1644
|
+
observable = entry.observable;
|
|
1645
|
+
if (!observable) {
|
|
1646
|
+
var concast = new utilities.Concast([
|
|
1647
|
+
core.execute(link, operation),
|
|
1648
|
+
]);
|
|
1649
|
+
observable = entry.observable = concast;
|
|
1650
|
+
concast.beforeNext(function () {
|
|
1651
|
+
inFlightLinkObservables_1.remove(printedServerQuery_1, varJson_1);
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
else {
|
|
1656
|
+
observable = new utilities.Concast([
|
|
1657
|
+
core.execute(link, operation),
|
|
1658
|
+
]);
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
else {
|
|
1662
|
+
observable = new utilities.Concast([utilities.Observable.of({ data: {} })]);
|
|
1663
|
+
context = this.prepareContext(context);
|
|
1664
|
+
}
|
|
1665
|
+
if (clientQuery) {
|
|
1666
|
+
observable = utilities.asyncMap(observable, function (result) {
|
|
1667
|
+
return _this.localState.runResolvers({
|
|
1668
|
+
document: clientQuery,
|
|
1669
|
+
remoteResult: result,
|
|
1670
|
+
context: context,
|
|
1671
|
+
variables: variables,
|
|
1672
|
+
});
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
return observable;
|
|
1676
|
+
};
|
|
1677
|
+
QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
|
|
1678
|
+
var requestId = (queryInfo.lastRequestId = this.generateRequestId());
|
|
1679
|
+
var linkDocument = this.cache.transformForLink(options.query);
|
|
1680
|
+
return utilities.asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
|
|
1681
|
+
var graphQLErrors = utilities.getGraphQLErrorsFromResult(result);
|
|
1682
|
+
var hasErrors = graphQLErrors.length > 0;
|
|
1683
|
+
if (requestId >= queryInfo.lastRequestId) {
|
|
1684
|
+
if (hasErrors && options.errorPolicy === "none") {
|
|
1685
|
+
throw queryInfo.markError(new errors.ApolloError({
|
|
1686
|
+
graphQLErrors: graphQLErrors,
|
|
1687
|
+
}));
|
|
1688
|
+
}
|
|
1689
|
+
queryInfo.markResult(result, linkDocument, options, cacheWriteBehavior);
|
|
1690
|
+
queryInfo.markReady();
|
|
1691
|
+
}
|
|
1692
|
+
var aqr = {
|
|
1693
|
+
data: result.data,
|
|
1694
|
+
loading: false,
|
|
1695
|
+
networkStatus: exports.NetworkStatus.ready,
|
|
1696
|
+
};
|
|
1697
|
+
if (hasErrors && options.errorPolicy !== "ignore") {
|
|
1698
|
+
aqr.errors = graphQLErrors;
|
|
1699
|
+
aqr.networkStatus = exports.NetworkStatus.error;
|
|
1700
|
+
}
|
|
1701
|
+
return aqr;
|
|
1702
|
+
}, function (networkError) {
|
|
1703
|
+
var error = errors.isApolloError(networkError) ? networkError : (new errors.ApolloError({ networkError: networkError }));
|
|
1704
|
+
if (requestId >= queryInfo.lastRequestId) {
|
|
1705
|
+
queryInfo.markError(error);
|
|
1706
|
+
}
|
|
1707
|
+
throw error;
|
|
1708
|
+
});
|
|
1709
|
+
};
|
|
1710
|
+
QueryManager.prototype.fetchConcastWithInfo = function (queryId, options,
|
|
1711
|
+
networkStatus, query) {
|
|
1712
|
+
var _this = this;
|
|
1713
|
+
if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
|
|
1714
|
+
if (query === void 0) { query = options.query; }
|
|
1715
|
+
var variables = this.getVariables(query, options.variables);
|
|
1716
|
+
var queryInfo = this.getQuery(queryId);
|
|
1717
|
+
var defaults = this.defaultOptions.watchQuery;
|
|
1718
|
+
var _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? (defaults && defaults.fetchPolicy) || "cache-first" : _a, _b = options.errorPolicy, errorPolicy = _b === void 0 ? (defaults && defaults.errorPolicy) || "none" : _b, _c = options.returnPartialData, returnPartialData = _c === void 0 ? false : _c, _d = options.notifyOnNetworkStatusChange, notifyOnNetworkStatusChange = _d === void 0 ? false : _d, _e = options.context, context = _e === void 0 ? {} : _e;
|
|
1719
|
+
var normalized = Object.assign({}, options, {
|
|
1720
|
+
query: query,
|
|
1721
|
+
variables: variables,
|
|
1722
|
+
fetchPolicy: fetchPolicy,
|
|
1723
|
+
errorPolicy: errorPolicy,
|
|
1724
|
+
returnPartialData: returnPartialData,
|
|
1725
|
+
notifyOnNetworkStatusChange: notifyOnNetworkStatusChange,
|
|
1726
|
+
context: context,
|
|
1727
|
+
});
|
|
1728
|
+
var fromVariables = function (variables) {
|
|
1729
|
+
normalized.variables = variables;
|
|
1730
|
+
var sourcesWithInfo = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
|
|
1731
|
+
if (
|
|
1732
|
+
normalized.fetchPolicy !== "standby" &&
|
|
1733
|
+
sourcesWithInfo.sources.length > 0 &&
|
|
1734
|
+
queryInfo.observableQuery) {
|
|
1735
|
+
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
|
|
1736
|
+
}
|
|
1737
|
+
return sourcesWithInfo;
|
|
1738
|
+
};
|
|
1739
|
+
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
|
|
1740
|
+
this.fetchCancelFns.set(queryId, function (reason) {
|
|
1741
|
+
cleanupCancelFn();
|
|
1742
|
+
setTimeout(function () { return concast.cancel(reason); });
|
|
1743
|
+
});
|
|
1744
|
+
var concast, containsDataFromLink;
|
|
1745
|
+
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
1746
|
+
concast = new utilities.Concast(this.localState
|
|
1747
|
+
.addExportedVariables(normalized.query, normalized.variables, normalized.context)
|
|
1748
|
+
.then(fromVariables)
|
|
1749
|
+
.then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
|
|
1750
|
+
containsDataFromLink = true;
|
|
1751
|
+
}
|
|
1752
|
+
else {
|
|
1753
|
+
var sourcesWithInfo = fromVariables(normalized.variables);
|
|
1754
|
+
containsDataFromLink = sourcesWithInfo.fromLink;
|
|
1755
|
+
concast = new utilities.Concast(sourcesWithInfo.sources);
|
|
1756
|
+
}
|
|
1757
|
+
concast.promise.then(cleanupCancelFn, cleanupCancelFn);
|
|
1758
|
+
return {
|
|
1759
|
+
concast: concast,
|
|
1760
|
+
fromLink: containsDataFromLink,
|
|
1761
|
+
};
|
|
1762
|
+
};
|
|
1763
|
+
QueryManager.prototype.refetchQueries = function (_a) {
|
|
1764
|
+
var _this = this;
|
|
1765
|
+
var updateCache = _a.updateCache, include = _a.include, _b = _a.optimistic, optimistic = _b === void 0 ? false : _b, _c = _a.removeOptimistic, removeOptimistic = _c === void 0 ? optimistic ? utilities.makeUniqueId("refetchQueries") : void 0 : _c, onQueryUpdated = _a.onQueryUpdated;
|
|
1766
|
+
var includedQueriesById = new Map();
|
|
1767
|
+
if (include) {
|
|
1768
|
+
this.getObservableQueries(include).forEach(function (oq, queryId) {
|
|
1769
|
+
includedQueriesById.set(queryId, {
|
|
1770
|
+
oq: oq,
|
|
1771
|
+
lastDiff: _this.getQuery(queryId).getDiff(),
|
|
1772
|
+
});
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
var results = new Map();
|
|
1776
|
+
if (updateCache) {
|
|
1777
|
+
this.cache.batch({
|
|
1778
|
+
update: updateCache,
|
|
1779
|
+
optimistic: (optimistic && removeOptimistic) || false,
|
|
1780
|
+
removeOptimistic: removeOptimistic,
|
|
1781
|
+
onWatchUpdated: function (watch, diff, lastDiff) {
|
|
1782
|
+
var oq = watch.watcher instanceof QueryInfo && watch.watcher.observableQuery;
|
|
1783
|
+
if (oq) {
|
|
1784
|
+
if (onQueryUpdated) {
|
|
1785
|
+
includedQueriesById.delete(oq.queryId);
|
|
1786
|
+
var result = onQueryUpdated(oq, diff, lastDiff);
|
|
1787
|
+
if (result === true) {
|
|
1788
|
+
result = oq.refetch();
|
|
1789
|
+
}
|
|
1790
|
+
if (result !== false) {
|
|
1791
|
+
results.set(oq, result);
|
|
1792
|
+
}
|
|
1793
|
+
return result;
|
|
1794
|
+
}
|
|
1795
|
+
if (onQueryUpdated !== null) {
|
|
1796
|
+
includedQueriesById.set(oq.queryId, { oq: oq, lastDiff: lastDiff, diff: diff });
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
},
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
if (includedQueriesById.size) {
|
|
1803
|
+
includedQueriesById.forEach(function (_a, queryId) {
|
|
1804
|
+
var oq = _a.oq, lastDiff = _a.lastDiff, diff = _a.diff;
|
|
1805
|
+
var result;
|
|
1806
|
+
if (onQueryUpdated) {
|
|
1807
|
+
if (!diff) {
|
|
1808
|
+
var info = oq["queryInfo"];
|
|
1809
|
+
info.reset();
|
|
1810
|
+
diff = info.getDiff();
|
|
1894
1811
|
}
|
|
1812
|
+
result = onQueryUpdated(oq, diff, lastDiff);
|
|
1895
1813
|
}
|
|
1896
|
-
if (
|
|
1897
|
-
|
|
1814
|
+
if (!onQueryUpdated || result === true) {
|
|
1815
|
+
result = oq.refetch();
|
|
1816
|
+
}
|
|
1817
|
+
if (result !== false) {
|
|
1818
|
+
results.set(oq, result);
|
|
1819
|
+
}
|
|
1820
|
+
if (queryId.indexOf("legacyOneTimeQuery") >= 0) {
|
|
1821
|
+
_this.stopQueryNoBroadcast(queryId);
|
|
1898
1822
|
}
|
|
1899
|
-
return result;
|
|
1900
|
-
});
|
|
1901
|
-
};
|
|
1902
|
-
if (this.getDocumentInfo(query).hasClientExports) {
|
|
1903
|
-
var observablePromise_1 = this.localState
|
|
1904
|
-
.addExportedVariables(query, variables, context)
|
|
1905
|
-
.then(makeObservable);
|
|
1906
|
-
return new utilities.Observable(function (observer) {
|
|
1907
|
-
var sub = null;
|
|
1908
|
-
observablePromise_1.then(function (observable) { return (sub = observable.subscribe(observer)); }, observer.error);
|
|
1909
|
-
return function () { return sub && sub.unsubscribe(); };
|
|
1910
1823
|
});
|
|
1911
1824
|
}
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
QueryManager.prototype.stopQuery = function (queryId) {
|
|
1915
|
-
this.stopQueryNoBroadcast(queryId);
|
|
1916
|
-
this.broadcastQueries();
|
|
1917
|
-
};
|
|
1918
|
-
QueryManager.prototype.stopQueryNoBroadcast = function (queryId) {
|
|
1919
|
-
this.stopQueryInStoreNoBroadcast(queryId);
|
|
1920
|
-
this.removeQuery(queryId);
|
|
1921
|
-
};
|
|
1922
|
-
QueryManager.prototype.removeQuery = function (queryId) {
|
|
1923
|
-
this.fetchCancelFns.delete(queryId);
|
|
1924
|
-
if (this.queries.has(queryId)) {
|
|
1925
|
-
this.getQuery(queryId).stop();
|
|
1926
|
-
this.queries.delete(queryId);
|
|
1825
|
+
if (removeOptimistic) {
|
|
1826
|
+
this.cache.removeOptimistic(removeOptimistic);
|
|
1927
1827
|
}
|
|
1828
|
+
return results;
|
|
1928
1829
|
};
|
|
1929
|
-
QueryManager.prototype.
|
|
1930
|
-
|
|
1931
|
-
this.onBroadcast();
|
|
1932
|
-
this.queries.forEach(function (info) { return info.notify(); });
|
|
1933
|
-
};
|
|
1934
|
-
QueryManager.prototype.getLocalState = function () {
|
|
1935
|
-
return this.localState;
|
|
1936
|
-
};
|
|
1937
|
-
QueryManager.prototype.getObservableFromLink = function (query, context, variables, extensions,
|
|
1938
|
-
deduplication) {
|
|
1830
|
+
QueryManager.prototype.fetchQueryByPolicy = function (queryInfo, _a,
|
|
1831
|
+
networkStatus) {
|
|
1939
1832
|
var _this = this;
|
|
1940
|
-
var _a;
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1833
|
+
var query = _a.query, variables = _a.variables, fetchPolicy = _a.fetchPolicy, refetchWritePolicy = _a.refetchWritePolicy, errorPolicy = _a.errorPolicy, returnPartialData = _a.returnPartialData, context = _a.context, notifyOnNetworkStatusChange = _a.notifyOnNetworkStatusChange;
|
|
1834
|
+
var oldNetworkStatus = queryInfo.networkStatus;
|
|
1835
|
+
queryInfo.init({
|
|
1836
|
+
document: query,
|
|
1837
|
+
variables: variables,
|
|
1838
|
+
networkStatus: networkStatus,
|
|
1839
|
+
});
|
|
1840
|
+
var readCache = function () { return queryInfo.getDiff(); };
|
|
1841
|
+
var resultsFromCache = function (diff, networkStatus) {
|
|
1842
|
+
if (networkStatus === void 0) { networkStatus = queryInfo.networkStatus || exports.NetworkStatus.loading; }
|
|
1843
|
+
var data = diff.result;
|
|
1844
|
+
if (globalThis.__DEV__ !== false && !returnPartialData && !equal.equal(data, {})) {
|
|
1845
|
+
logMissingFieldErrors(diff.missing);
|
|
1846
|
+
}
|
|
1847
|
+
var fromData = function (data) {
|
|
1848
|
+
return utilities.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true })));
|
|
1952
1849
|
};
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1850
|
+
if (data && _this.getDocumentInfo(query).hasForcedResolvers) {
|
|
1851
|
+
return _this.localState
|
|
1852
|
+
.runResolvers({
|
|
1853
|
+
document: query,
|
|
1854
|
+
remoteResult: { data: data },
|
|
1855
|
+
context: context,
|
|
1856
|
+
variables: variables,
|
|
1857
|
+
onlyRunForcedResolvers: true,
|
|
1858
|
+
})
|
|
1859
|
+
.then(function (resolved) { return fromData(resolved.data || void 0); });
|
|
1860
|
+
}
|
|
1861
|
+
if (errorPolicy === "none" &&
|
|
1862
|
+
networkStatus === exports.NetworkStatus.refetch &&
|
|
1863
|
+
Array.isArray(diff.missing)) {
|
|
1864
|
+
return fromData(void 0);
|
|
1865
|
+
}
|
|
1866
|
+
return fromData(data);
|
|
1867
|
+
};
|
|
1868
|
+
var cacheWriteBehavior = fetchPolicy === "no-cache" ? 0
|
|
1869
|
+
: (networkStatus === exports.NetworkStatus.refetch &&
|
|
1870
|
+
refetchWritePolicy !== "merge") ?
|
|
1871
|
+
1
|
|
1872
|
+
: 2 ;
|
|
1873
|
+
var resultsFromLink = function () {
|
|
1874
|
+
return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
|
|
1875
|
+
query: query,
|
|
1876
|
+
variables: variables,
|
|
1877
|
+
context: context,
|
|
1878
|
+
fetchPolicy: fetchPolicy,
|
|
1879
|
+
errorPolicy: errorPolicy,
|
|
1880
|
+
});
|
|
1881
|
+
};
|
|
1882
|
+
var shouldNotify = notifyOnNetworkStatusChange &&
|
|
1883
|
+
typeof oldNetworkStatus === "number" &&
|
|
1884
|
+
oldNetworkStatus !== networkStatus &&
|
|
1885
|
+
isNetworkRequestInFlight(networkStatus);
|
|
1886
|
+
switch (fetchPolicy) {
|
|
1887
|
+
default:
|
|
1888
|
+
case "cache-first": {
|
|
1889
|
+
var diff = readCache();
|
|
1890
|
+
if (diff.complete) {
|
|
1891
|
+
return {
|
|
1892
|
+
fromLink: false,
|
|
1893
|
+
sources: [resultsFromCache(diff, queryInfo.markReady())],
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
if (returnPartialData || shouldNotify) {
|
|
1897
|
+
return {
|
|
1898
|
+
fromLink: true,
|
|
1899
|
+
sources: [resultsFromCache(diff), resultsFromLink()],
|
|
1900
|
+
};
|
|
1967
1901
|
}
|
|
1902
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
1968
1903
|
}
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1904
|
+
case "cache-and-network": {
|
|
1905
|
+
var diff = readCache();
|
|
1906
|
+
if (diff.complete || returnPartialData || shouldNotify) {
|
|
1907
|
+
return {
|
|
1908
|
+
fromLink: true,
|
|
1909
|
+
sources: [resultsFromCache(diff), resultsFromLink()],
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
1973
1913
|
}
|
|
1914
|
+
case "cache-only":
|
|
1915
|
+
return {
|
|
1916
|
+
fromLink: false,
|
|
1917
|
+
sources: [resultsFromCache(readCache(), queryInfo.markReady())],
|
|
1918
|
+
};
|
|
1919
|
+
case "network-only":
|
|
1920
|
+
if (shouldNotify) {
|
|
1921
|
+
return {
|
|
1922
|
+
fromLink: true,
|
|
1923
|
+
sources: [resultsFromCache(readCache()), resultsFromLink()],
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
1927
|
+
case "no-cache":
|
|
1928
|
+
if (shouldNotify) {
|
|
1929
|
+
return {
|
|
1930
|
+
fromLink: true,
|
|
1931
|
+
sources: [resultsFromCache(queryInfo.getDiff()), resultsFromLink()],
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
1935
|
+
case "standby":
|
|
1936
|
+
return { fromLink: false, sources: [] };
|
|
1937
|
+
}
|
|
1938
|
+
};
|
|
1939
|
+
QueryManager.prototype.getQuery = function (queryId) {
|
|
1940
|
+
if (queryId && !this.queries.has(queryId)) {
|
|
1941
|
+
this.queries.set(queryId, new QueryInfo(this, queryId));
|
|
1942
|
+
}
|
|
1943
|
+
return this.queries.get(queryId);
|
|
1944
|
+
};
|
|
1945
|
+
QueryManager.prototype.prepareContext = function (context) {
|
|
1946
|
+
if (context === void 0) { context = {}; }
|
|
1947
|
+
var newContext = this.localState.prepareContext(context);
|
|
1948
|
+
return tslib.__assign(tslib.__assign(tslib.__assign({}, this.defaultContext), newContext), { clientAwareness: this.clientAwareness });
|
|
1949
|
+
};
|
|
1950
|
+
return QueryManager;
|
|
1951
|
+
}());
|
|
1952
|
+
|
|
1953
|
+
var LocalState = (function () {
|
|
1954
|
+
function LocalState(_a) {
|
|
1955
|
+
var cache = _a.cache, client = _a.client, resolvers = _a.resolvers, fragmentMatcher = _a.fragmentMatcher;
|
|
1956
|
+
this.selectionsToResolveCache = new WeakMap();
|
|
1957
|
+
this.cache = cache;
|
|
1958
|
+
if (client) {
|
|
1959
|
+
this.client = client;
|
|
1960
|
+
}
|
|
1961
|
+
if (resolvers) {
|
|
1962
|
+
this.addResolvers(resolvers);
|
|
1963
|
+
}
|
|
1964
|
+
if (fragmentMatcher) {
|
|
1965
|
+
this.setFragmentMatcher(fragmentMatcher);
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
LocalState.prototype.addResolvers = function (resolvers) {
|
|
1969
|
+
var _this = this;
|
|
1970
|
+
this.resolvers = this.resolvers || {};
|
|
1971
|
+
if (Array.isArray(resolvers)) {
|
|
1972
|
+
resolvers.forEach(function (resolverGroup) {
|
|
1973
|
+
_this.resolvers = utilities.mergeDeep(_this.resolvers, resolverGroup);
|
|
1974
|
+
});
|
|
1974
1975
|
}
|
|
1975
1976
|
else {
|
|
1976
|
-
|
|
1977
|
-
context = this.prepareContext(context);
|
|
1977
|
+
this.resolvers = utilities.mergeDeep(this.resolvers, resolvers);
|
|
1978
1978
|
}
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1979
|
+
};
|
|
1980
|
+
LocalState.prototype.setResolvers = function (resolvers) {
|
|
1981
|
+
this.resolvers = {};
|
|
1982
|
+
this.addResolvers(resolvers);
|
|
1983
|
+
};
|
|
1984
|
+
LocalState.prototype.getResolvers = function () {
|
|
1985
|
+
return this.resolvers || {};
|
|
1986
|
+
};
|
|
1987
|
+
LocalState.prototype.runResolvers = function (_a) {
|
|
1988
|
+
return tslib.__awaiter(this, arguments, void 0, function (_b) {
|
|
1989
|
+
var document = _b.document, remoteResult = _b.remoteResult, context = _b.context, variables = _b.variables, _c = _b.onlyRunForcedResolvers, onlyRunForcedResolvers = _c === void 0 ? false : _c;
|
|
1990
|
+
return tslib.__generator(this, function (_d) {
|
|
1991
|
+
if (document) {
|
|
1992
|
+
return [2 , this.resolveDocument(document, remoteResult.data, context, variables, this.fragmentMatcher, onlyRunForcedResolvers).then(function (localResult) { return (tslib.__assign(tslib.__assign({}, remoteResult), { data: localResult.result })); })];
|
|
1993
|
+
}
|
|
1994
|
+
return [2 , remoteResult];
|
|
1987
1995
|
});
|
|
1996
|
+
});
|
|
1997
|
+
};
|
|
1998
|
+
LocalState.prototype.setFragmentMatcher = function (fragmentMatcher) {
|
|
1999
|
+
this.fragmentMatcher = fragmentMatcher;
|
|
2000
|
+
};
|
|
2001
|
+
LocalState.prototype.getFragmentMatcher = function () {
|
|
2002
|
+
return this.fragmentMatcher;
|
|
2003
|
+
};
|
|
2004
|
+
LocalState.prototype.clientQuery = function (document) {
|
|
2005
|
+
if (utilities.hasDirectives(["client"], document)) {
|
|
2006
|
+
if (this.resolvers) {
|
|
2007
|
+
return document;
|
|
2008
|
+
}
|
|
1988
2009
|
}
|
|
1989
|
-
return
|
|
2010
|
+
return null;
|
|
1990
2011
|
};
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2012
|
+
LocalState.prototype.serverQuery = function (document) {
|
|
2013
|
+
return utilities.removeClientSetsFromDocument(document);
|
|
2014
|
+
};
|
|
2015
|
+
LocalState.prototype.prepareContext = function (context) {
|
|
2016
|
+
var cache = this.cache;
|
|
2017
|
+
return tslib.__assign(tslib.__assign({}, context), { cache: cache,
|
|
2018
|
+
getCacheKey: function (obj) {
|
|
2019
|
+
return cache.identify(obj);
|
|
2020
|
+
} });
|
|
2021
|
+
};
|
|
2022
|
+
LocalState.prototype.addExportedVariables = function (document_1) {
|
|
2023
|
+
return tslib.__awaiter(this, arguments, void 0, function (document, variables, context) {
|
|
2024
|
+
if (variables === void 0) { variables = {}; }
|
|
2025
|
+
if (context === void 0) { context = {}; }
|
|
2026
|
+
return tslib.__generator(this, function (_a) {
|
|
2027
|
+
if (document) {
|
|
2028
|
+
return [2 , this.resolveDocument(document, this.buildRootValueFromCache(document, variables) || {}, this.prepareContext(context), variables).then(function (data) { return (tslib.__assign(tslib.__assign({}, variables), data.exportedVariables)); })];
|
|
2002
2029
|
}
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
}
|
|
2006
|
-
var aqr = {
|
|
2007
|
-
data: result.data,
|
|
2008
|
-
loading: false,
|
|
2009
|
-
networkStatus: exports.NetworkStatus.ready,
|
|
2010
|
-
};
|
|
2011
|
-
if (hasErrors && options.errorPolicy !== "ignore") {
|
|
2012
|
-
aqr.errors = graphQLErrors;
|
|
2013
|
-
aqr.networkStatus = exports.NetworkStatus.error;
|
|
2014
|
-
}
|
|
2015
|
-
return aqr;
|
|
2016
|
-
}, function (networkError) {
|
|
2017
|
-
var error = errors.isApolloError(networkError) ? networkError : (new errors.ApolloError({ networkError: networkError }));
|
|
2018
|
-
if (requestId >= queryInfo.lastRequestId) {
|
|
2019
|
-
queryInfo.markError(error);
|
|
2020
|
-
}
|
|
2021
|
-
throw error;
|
|
2030
|
+
return [2 , tslib.__assign({}, variables)];
|
|
2031
|
+
});
|
|
2022
2032
|
});
|
|
2023
2033
|
};
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
});
|
|
2042
|
-
var fromVariables = function (variables) {
|
|
2043
|
-
normalized.variables = variables;
|
|
2044
|
-
var sourcesWithInfo = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
|
|
2045
|
-
if (
|
|
2046
|
-
normalized.fetchPolicy !== "standby" &&
|
|
2047
|
-
sourcesWithInfo.sources.length > 0 &&
|
|
2048
|
-
queryInfo.observableQuery) {
|
|
2049
|
-
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
|
|
2050
|
-
}
|
|
2051
|
-
return sourcesWithInfo;
|
|
2052
|
-
};
|
|
2053
|
-
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
|
|
2054
|
-
this.fetchCancelFns.set(queryId, function (reason) {
|
|
2055
|
-
cleanupCancelFn();
|
|
2056
|
-
setTimeout(function () { return concast.cancel(reason); });
|
|
2034
|
+
LocalState.prototype.shouldForceResolvers = function (document) {
|
|
2035
|
+
var forceResolvers = false;
|
|
2036
|
+
graphql.visit(document, {
|
|
2037
|
+
Directive: {
|
|
2038
|
+
enter: function (node) {
|
|
2039
|
+
if (node.name.value === "client" && node.arguments) {
|
|
2040
|
+
forceResolvers = node.arguments.some(function (arg) {
|
|
2041
|
+
return arg.name.value === "always" &&
|
|
2042
|
+
arg.value.kind === "BooleanValue" &&
|
|
2043
|
+
arg.value.value === true;
|
|
2044
|
+
});
|
|
2045
|
+
if (forceResolvers) {
|
|
2046
|
+
return graphql.BREAK;
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
},
|
|
2050
|
+
},
|
|
2057
2051
|
});
|
|
2058
|
-
|
|
2059
|
-
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
2060
|
-
concast = new utilities.Concast(this.localState
|
|
2061
|
-
.addExportedVariables(normalized.query, normalized.variables, normalized.context)
|
|
2062
|
-
.then(fromVariables)
|
|
2063
|
-
.then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
|
|
2064
|
-
containsDataFromLink = true;
|
|
2065
|
-
}
|
|
2066
|
-
else {
|
|
2067
|
-
var sourcesWithInfo = fromVariables(normalized.variables);
|
|
2068
|
-
containsDataFromLink = sourcesWithInfo.fromLink;
|
|
2069
|
-
concast = new utilities.Concast(sourcesWithInfo.sources);
|
|
2070
|
-
}
|
|
2071
|
-
concast.promise.then(cleanupCancelFn, cleanupCancelFn);
|
|
2072
|
-
return {
|
|
2073
|
-
concast: concast,
|
|
2074
|
-
fromLink: containsDataFromLink,
|
|
2075
|
-
};
|
|
2052
|
+
return forceResolvers;
|
|
2076
2053
|
};
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2054
|
+
LocalState.prototype.buildRootValueFromCache = function (document, variables) {
|
|
2055
|
+
return this.cache.diff({
|
|
2056
|
+
query: utilities.buildQueryFromSelectionSet(document),
|
|
2057
|
+
variables: variables,
|
|
2058
|
+
returnPartialData: true,
|
|
2059
|
+
optimistic: false,
|
|
2060
|
+
}).result;
|
|
2061
|
+
};
|
|
2062
|
+
LocalState.prototype.resolveDocument = function (document_1, rootValue_1) {
|
|
2063
|
+
return tslib.__awaiter(this, arguments, void 0, function (document, rootValue, context, variables, fragmentMatcher, onlyRunForcedResolvers) {
|
|
2064
|
+
var mainDefinition, fragments, fragmentMap, selectionsToResolve, definitionOperation, defaultOperationType, _a, cache, client, execContext, isClientFieldDescendant;
|
|
2065
|
+
if (context === void 0) { context = {}; }
|
|
2066
|
+
if (variables === void 0) { variables = {}; }
|
|
2067
|
+
if (fragmentMatcher === void 0) { fragmentMatcher = function () { return true; }; }
|
|
2068
|
+
if (onlyRunForcedResolvers === void 0) { onlyRunForcedResolvers = false; }
|
|
2069
|
+
return tslib.__generator(this, function (_b) {
|
|
2070
|
+
mainDefinition = utilities.getMainDefinition(document);
|
|
2071
|
+
fragments = utilities.getFragmentDefinitions(document);
|
|
2072
|
+
fragmentMap = utilities.createFragmentMap(fragments);
|
|
2073
|
+
selectionsToResolve = this.collectSelectionsToResolve(mainDefinition, fragmentMap);
|
|
2074
|
+
definitionOperation = mainDefinition.operation;
|
|
2075
|
+
defaultOperationType = definitionOperation ?
|
|
2076
|
+
definitionOperation.charAt(0).toUpperCase() +
|
|
2077
|
+
definitionOperation.slice(1)
|
|
2078
|
+
: "Query";
|
|
2079
|
+
_a = this, cache = _a.cache, client = _a.client;
|
|
2080
|
+
execContext = {
|
|
2081
|
+
fragmentMap: fragmentMap,
|
|
2082
|
+
context: tslib.__assign(tslib.__assign({}, context), { cache: cache, client: client }),
|
|
2083
|
+
variables: variables,
|
|
2084
|
+
fragmentMatcher: fragmentMatcher,
|
|
2085
|
+
defaultOperationType: defaultOperationType,
|
|
2086
|
+
exportedVariables: {},
|
|
2087
|
+
selectionsToResolve: selectionsToResolve,
|
|
2088
|
+
onlyRunForcedResolvers: onlyRunForcedResolvers,
|
|
2089
|
+
};
|
|
2090
|
+
isClientFieldDescendant = false;
|
|
2091
|
+
return [2 , this.resolveSelectionSet(mainDefinition.selectionSet, isClientFieldDescendant, rootValue, execContext).then(function (result) { return ({
|
|
2092
|
+
result: result,
|
|
2093
|
+
exportedVariables: execContext.exportedVariables,
|
|
2094
|
+
}); })];
|
|
2087
2095
|
});
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
}
|
|
2104
|
-
if (result !== false) {
|
|
2105
|
-
results.set(oq, result);
|
|
2106
|
-
}
|
|
2107
|
-
return result;
|
|
2096
|
+
});
|
|
2097
|
+
};
|
|
2098
|
+
LocalState.prototype.resolveSelectionSet = function (selectionSet, isClientFieldDescendant, rootValue, execContext) {
|
|
2099
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2100
|
+
var fragmentMap, context, variables, resultsToMerge, execute;
|
|
2101
|
+
var _this = this;
|
|
2102
|
+
return tslib.__generator(this, function (_a) {
|
|
2103
|
+
fragmentMap = execContext.fragmentMap, context = execContext.context, variables = execContext.variables;
|
|
2104
|
+
resultsToMerge = [rootValue];
|
|
2105
|
+
execute = function (selection) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
2106
|
+
var fragment, typeCondition;
|
|
2107
|
+
return tslib.__generator(this, function (_a) {
|
|
2108
|
+
if (!isClientFieldDescendant &&
|
|
2109
|
+
!execContext.selectionsToResolve.has(selection)) {
|
|
2110
|
+
return [2 ];
|
|
2108
2111
|
}
|
|
2109
|
-
if (
|
|
2110
|
-
|
|
2112
|
+
if (!utilities.shouldInclude(selection, variables)) {
|
|
2113
|
+
return [2 ];
|
|
2114
|
+
}
|
|
2115
|
+
if (utilities.isField(selection)) {
|
|
2116
|
+
return [2 , this.resolveField(selection, isClientFieldDescendant, rootValue, execContext).then(function (fieldResult) {
|
|
2117
|
+
var _a;
|
|
2118
|
+
if (typeof fieldResult !== "undefined") {
|
|
2119
|
+
resultsToMerge.push((_a = {},
|
|
2120
|
+
_a[utilities.resultKeyNameFromField(selection)] = fieldResult,
|
|
2121
|
+
_a));
|
|
2122
|
+
}
|
|
2123
|
+
})];
|
|
2124
|
+
}
|
|
2125
|
+
if (utilities.isInlineFragment(selection)) {
|
|
2126
|
+
fragment = selection;
|
|
2127
|
+
}
|
|
2128
|
+
else {
|
|
2129
|
+
fragment = fragmentMap[selection.name.value];
|
|
2130
|
+
globals.invariant(fragment, 18, selection.name.value);
|
|
2131
|
+
}
|
|
2132
|
+
if (fragment && fragment.typeCondition) {
|
|
2133
|
+
typeCondition = fragment.typeCondition.name.value;
|
|
2134
|
+
if (execContext.fragmentMatcher(rootValue, typeCondition, context)) {
|
|
2135
|
+
return [2 , this.resolveSelectionSet(fragment.selectionSet, isClientFieldDescendant, rootValue, execContext).then(function (fragmentResult) {
|
|
2136
|
+
resultsToMerge.push(fragmentResult);
|
|
2137
|
+
})];
|
|
2138
|
+
}
|
|
2111
2139
|
}
|
|
2112
|
-
|
|
2113
|
-
|
|
2140
|
+
return [2 ];
|
|
2141
|
+
});
|
|
2142
|
+
}); };
|
|
2143
|
+
return [2 , Promise.all(selectionSet.selections.map(execute)).then(function () {
|
|
2144
|
+
return utilities.mergeDeepArray(resultsToMerge);
|
|
2145
|
+
})];
|
|
2114
2146
|
});
|
|
2115
|
-
}
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
diff = info.getDiff();
|
|
2125
|
-
}
|
|
2126
|
-
result = onQueryUpdated(oq, diff, lastDiff);
|
|
2127
|
-
}
|
|
2128
|
-
if (!onQueryUpdated || result === true) {
|
|
2129
|
-
result = oq.refetch();
|
|
2130
|
-
}
|
|
2131
|
-
if (result !== false) {
|
|
2132
|
-
results.set(oq, result);
|
|
2147
|
+
});
|
|
2148
|
+
};
|
|
2149
|
+
LocalState.prototype.resolveField = function (field, isClientFieldDescendant, rootValue, execContext) {
|
|
2150
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
2151
|
+
var variables, fieldName, aliasedFieldName, aliasUsed, defaultResult, resultPromise, resolverType, resolverMap, resolve;
|
|
2152
|
+
var _this = this;
|
|
2153
|
+
return tslib.__generator(this, function (_a) {
|
|
2154
|
+
if (!rootValue) {
|
|
2155
|
+
return [2 , null];
|
|
2133
2156
|
}
|
|
2134
|
-
|
|
2135
|
-
|
|
2157
|
+
variables = execContext.variables;
|
|
2158
|
+
fieldName = field.name.value;
|
|
2159
|
+
aliasedFieldName = utilities.resultKeyNameFromField(field);
|
|
2160
|
+
aliasUsed = fieldName !== aliasedFieldName;
|
|
2161
|
+
defaultResult = rootValue[aliasedFieldName] || rootValue[fieldName];
|
|
2162
|
+
resultPromise = Promise.resolve(defaultResult);
|
|
2163
|
+
if (!execContext.onlyRunForcedResolvers ||
|
|
2164
|
+
this.shouldForceResolvers(field)) {
|
|
2165
|
+
resolverType = rootValue.__typename || execContext.defaultOperationType;
|
|
2166
|
+
resolverMap = this.resolvers && this.resolvers[resolverType];
|
|
2167
|
+
if (resolverMap) {
|
|
2168
|
+
resolve = resolverMap[aliasUsed ? fieldName : aliasedFieldName];
|
|
2169
|
+
if (resolve) {
|
|
2170
|
+
resultPromise = Promise.resolve(
|
|
2171
|
+
cache.cacheSlot.withValue(this.cache, resolve, [
|
|
2172
|
+
rootValue,
|
|
2173
|
+
utilities.argumentsObjectFromField(field, variables),
|
|
2174
|
+
execContext.context,
|
|
2175
|
+
{ field: field, fragmentMap: execContext.fragmentMap },
|
|
2176
|
+
]));
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2136
2179
|
}
|
|
2180
|
+
return [2 , resultPromise.then(function (result) {
|
|
2181
|
+
var _a, _b;
|
|
2182
|
+
if (result === void 0) { result = defaultResult; }
|
|
2183
|
+
if (field.directives) {
|
|
2184
|
+
field.directives.forEach(function (directive) {
|
|
2185
|
+
if (directive.name.value === "export" && directive.arguments) {
|
|
2186
|
+
directive.arguments.forEach(function (arg) {
|
|
2187
|
+
if (arg.name.value === "as" && arg.value.kind === "StringValue") {
|
|
2188
|
+
execContext.exportedVariables[arg.value.value] = result;
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
if (!field.selectionSet) {
|
|
2195
|
+
return result;
|
|
2196
|
+
}
|
|
2197
|
+
if (result == null) {
|
|
2198
|
+
return result;
|
|
2199
|
+
}
|
|
2200
|
+
var isClientField = (_b = (_a = field.directives) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.name.value === "client"; })) !== null && _b !== void 0 ? _b : false;
|
|
2201
|
+
if (Array.isArray(result)) {
|
|
2202
|
+
return _this.resolveSubSelectedArray(field, isClientFieldDescendant || isClientField, result, execContext);
|
|
2203
|
+
}
|
|
2204
|
+
if (field.selectionSet) {
|
|
2205
|
+
return _this.resolveSelectionSet(field.selectionSet, isClientFieldDescendant || isClientField, result, execContext);
|
|
2206
|
+
}
|
|
2207
|
+
})];
|
|
2137
2208
|
});
|
|
2138
|
-
}
|
|
2139
|
-
if (removeOptimistic) {
|
|
2140
|
-
this.cache.removeOptimistic(removeOptimistic);
|
|
2141
|
-
}
|
|
2142
|
-
return results;
|
|
2209
|
+
});
|
|
2143
2210
|
};
|
|
2144
|
-
|
|
2145
|
-
networkStatus) {
|
|
2211
|
+
LocalState.prototype.resolveSubSelectedArray = function (field, isClientFieldDescendant, result, execContext) {
|
|
2146
2212
|
var _this = this;
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
document: query,
|
|
2151
|
-
variables: variables,
|
|
2152
|
-
networkStatus: networkStatus,
|
|
2153
|
-
});
|
|
2154
|
-
var readCache = function () { return queryInfo.getDiff(); };
|
|
2155
|
-
var resultsFromCache = function (diff, networkStatus) {
|
|
2156
|
-
if (networkStatus === void 0) { networkStatus = queryInfo.networkStatus || exports.NetworkStatus.loading; }
|
|
2157
|
-
var data = diff.result;
|
|
2158
|
-
if (globalThis.__DEV__ !== false && !returnPartialData && !equal.equal(data, {})) {
|
|
2159
|
-
logMissingFieldErrors(diff.missing);
|
|
2160
|
-
}
|
|
2161
|
-
var fromData = function (data) {
|
|
2162
|
-
return utilities.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true })));
|
|
2163
|
-
};
|
|
2164
|
-
if (data && _this.getDocumentInfo(query).hasForcedResolvers) {
|
|
2165
|
-
return _this.localState
|
|
2166
|
-
.runResolvers({
|
|
2167
|
-
document: query,
|
|
2168
|
-
remoteResult: { data: data },
|
|
2169
|
-
context: context,
|
|
2170
|
-
variables: variables,
|
|
2171
|
-
onlyRunForcedResolvers: true,
|
|
2172
|
-
})
|
|
2173
|
-
.then(function (resolved) { return fromData(resolved.data || void 0); });
|
|
2174
|
-
}
|
|
2175
|
-
if (errorPolicy === "none" &&
|
|
2176
|
-
networkStatus === exports.NetworkStatus.refetch &&
|
|
2177
|
-
Array.isArray(diff.missing)) {
|
|
2178
|
-
return fromData(void 0);
|
|
2213
|
+
return Promise.all(result.map(function (item) {
|
|
2214
|
+
if (item === null) {
|
|
2215
|
+
return null;
|
|
2179
2216
|
}
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
var cacheWriteBehavior = fetchPolicy === "no-cache" ? 0
|
|
2183
|
-
: (networkStatus === exports.NetworkStatus.refetch &&
|
|
2184
|
-
refetchWritePolicy !== "merge") ?
|
|
2185
|
-
1
|
|
2186
|
-
: 2 ;
|
|
2187
|
-
var resultsFromLink = function () {
|
|
2188
|
-
return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
|
|
2189
|
-
query: query,
|
|
2190
|
-
variables: variables,
|
|
2191
|
-
context: context,
|
|
2192
|
-
fetchPolicy: fetchPolicy,
|
|
2193
|
-
errorPolicy: errorPolicy,
|
|
2194
|
-
});
|
|
2195
|
-
};
|
|
2196
|
-
var shouldNotify = notifyOnNetworkStatusChange &&
|
|
2197
|
-
typeof oldNetworkStatus === "number" &&
|
|
2198
|
-
oldNetworkStatus !== networkStatus &&
|
|
2199
|
-
isNetworkRequestInFlight(networkStatus);
|
|
2200
|
-
switch (fetchPolicy) {
|
|
2201
|
-
default:
|
|
2202
|
-
case "cache-first": {
|
|
2203
|
-
var diff = readCache();
|
|
2204
|
-
if (diff.complete) {
|
|
2205
|
-
return {
|
|
2206
|
-
fromLink: false,
|
|
2207
|
-
sources: [resultsFromCache(diff, queryInfo.markReady())],
|
|
2208
|
-
};
|
|
2209
|
-
}
|
|
2210
|
-
if (returnPartialData || shouldNotify) {
|
|
2211
|
-
return {
|
|
2212
|
-
fromLink: true,
|
|
2213
|
-
sources: [resultsFromCache(diff), resultsFromLink()],
|
|
2214
|
-
};
|
|
2215
|
-
}
|
|
2216
|
-
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2217
|
+
if (Array.isArray(item)) {
|
|
2218
|
+
return _this.resolveSubSelectedArray(field, isClientFieldDescendant, item, execContext);
|
|
2217
2219
|
}
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
if (diff.complete || returnPartialData || shouldNotify) {
|
|
2221
|
-
return {
|
|
2222
|
-
fromLink: true,
|
|
2223
|
-
sources: [resultsFromCache(diff), resultsFromLink()],
|
|
2224
|
-
};
|
|
2225
|
-
}
|
|
2226
|
-
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2220
|
+
if (field.selectionSet) {
|
|
2221
|
+
return _this.resolveSelectionSet(field.selectionSet, isClientFieldDescendant, item, execContext);
|
|
2227
2222
|
}
|
|
2228
|
-
|
|
2229
|
-
return {
|
|
2230
|
-
fromLink: false,
|
|
2231
|
-
sources: [resultsFromCache(readCache(), queryInfo.markReady())],
|
|
2232
|
-
};
|
|
2233
|
-
case "network-only":
|
|
2234
|
-
if (shouldNotify) {
|
|
2235
|
-
return {
|
|
2236
|
-
fromLink: true,
|
|
2237
|
-
sources: [resultsFromCache(readCache()), resultsFromLink()],
|
|
2238
|
-
};
|
|
2239
|
-
}
|
|
2240
|
-
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2241
|
-
case "no-cache":
|
|
2242
|
-
if (shouldNotify) {
|
|
2243
|
-
return {
|
|
2244
|
-
fromLink: true,
|
|
2245
|
-
sources: [resultsFromCache(queryInfo.getDiff()), resultsFromLink()],
|
|
2246
|
-
};
|
|
2247
|
-
}
|
|
2248
|
-
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2249
|
-
case "standby":
|
|
2250
|
-
return { fromLink: false, sources: [] };
|
|
2251
|
-
}
|
|
2223
|
+
}));
|
|
2252
2224
|
};
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2225
|
+
LocalState.prototype.collectSelectionsToResolve = function (mainDefinition, fragmentMap) {
|
|
2226
|
+
var isSingleASTNode = function (node) { return !Array.isArray(node); };
|
|
2227
|
+
var selectionsToResolveCache = this.selectionsToResolveCache;
|
|
2228
|
+
function collectByDefinition(definitionNode) {
|
|
2229
|
+
if (!selectionsToResolveCache.has(definitionNode)) {
|
|
2230
|
+
var matches_1 = new Set();
|
|
2231
|
+
selectionsToResolveCache.set(definitionNode, matches_1);
|
|
2232
|
+
graphql.visit(definitionNode, {
|
|
2233
|
+
Directive: function (node, _, __, ___, ancestors) {
|
|
2234
|
+
if (node.name.value === "client") {
|
|
2235
|
+
ancestors.forEach(function (node) {
|
|
2236
|
+
if (isSingleASTNode(node) && graphql.isSelectionNode(node)) {
|
|
2237
|
+
matches_1.add(node);
|
|
2238
|
+
}
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
},
|
|
2242
|
+
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
2243
|
+
var fragment = fragmentMap[spread.name.value];
|
|
2244
|
+
globals.invariant(fragment, 19, spread.name.value);
|
|
2245
|
+
var fragmentSelections = collectByDefinition(fragment);
|
|
2246
|
+
if (fragmentSelections.size > 0) {
|
|
2247
|
+
ancestors.forEach(function (node) {
|
|
2248
|
+
if (isSingleASTNode(node) && graphql.isSelectionNode(node)) {
|
|
2249
|
+
matches_1.add(node);
|
|
2250
|
+
}
|
|
2251
|
+
});
|
|
2252
|
+
matches_1.add(spread);
|
|
2253
|
+
fragmentSelections.forEach(function (selection) {
|
|
2254
|
+
matches_1.add(selection);
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
},
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2260
|
+
return selectionsToResolveCache.get(definitionNode);
|
|
2256
2261
|
}
|
|
2257
|
-
return
|
|
2258
|
-
};
|
|
2259
|
-
QueryManager.prototype.prepareContext = function (context) {
|
|
2260
|
-
if (context === void 0) { context = {}; }
|
|
2261
|
-
var newContext = this.localState.prepareContext(context);
|
|
2262
|
-
return tslib.__assign(tslib.__assign(tslib.__assign({}, this.defaultContext), newContext), { clientAwareness: this.clientAwareness });
|
|
2262
|
+
return collectByDefinition(mainDefinition);
|
|
2263
2263
|
};
|
|
2264
|
-
return
|
|
2264
|
+
return LocalState;
|
|
2265
2265
|
}());
|
|
2266
2266
|
|
|
2267
2267
|
var cacheSizeSymbol = Symbol.for("apollo.cacheSize");
|
|
@@ -2395,7 +2395,7 @@ var ApolloClient = (function () {
|
|
|
2395
2395
|
},
|
|
2396
2396
|
localState: this.localState,
|
|
2397
2397
|
assumeImmutableResults: assumeImmutableResults,
|
|
2398
|
-
onBroadcast:
|
|
2398
|
+
onBroadcast: this.devtoolsConfig.enabled ?
|
|
2399
2399
|
function () {
|
|
2400
2400
|
if (_this.devToolsHookCb) {
|
|
2401
2401
|
_this.devToolsHookCb({
|