@apollo/client 3.13.6 → 3.13.8
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 +14 -0
- package/apollo-client.cjs +66 -80
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/ObservableQuery.d.ts +10 -1
- package/core/ObservableQuery.js +84 -31
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +0 -8
- package/core/QueryInfo.js +10 -73
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +2 -4
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +66 -80
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +66 -80
- package/core/types.d.ts +0 -2
- package/core/types.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 +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/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/subscriptions/urql/index.js +6 -1
- package/utilities/subscriptions/urql/index.js.map +1 -1
- package/utilities/subscriptions/urql/urql.cjs +6 -2
- package/utilities/subscriptions/urql/urql.cjs.map +1 -1
- package/utilities/subscriptions/urql/urql.cjs.native.js +6 -2
- package/version.js +1 -1
package/core/core.cjs
CHANGED
|
@@ -22,7 +22,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
22
22
|
|
|
23
23
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
24
24
|
|
|
25
|
-
var version = "3.13.
|
|
25
|
+
var version = "3.13.8";
|
|
26
26
|
|
|
27
27
|
function isNonNullObject(obj) {
|
|
28
28
|
return obj !== null && typeof obj === "object";
|
|
@@ -234,6 +234,7 @@ var ObservableQuery = (function (_super) {
|
|
|
234
234
|
}) || this;
|
|
235
235
|
_this.observers = new Set();
|
|
236
236
|
_this.subscriptions = new Set();
|
|
237
|
+
_this.dirty = false;
|
|
237
238
|
_this.queryInfo = queryInfo;
|
|
238
239
|
_this.queryManager = queryManager;
|
|
239
240
|
_this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy);
|
|
@@ -477,7 +478,7 @@ var ObservableQuery = (function (_super) {
|
|
|
477
478
|
})
|
|
478
479
|
.finally(function () {
|
|
479
480
|
if (isCached && !updatedQuerySet.has(_this.query)) {
|
|
480
|
-
reobserveCacheFirst(
|
|
481
|
+
_this.reobserveCacheFirst();
|
|
481
482
|
}
|
|
482
483
|
});
|
|
483
484
|
};
|
|
@@ -770,26 +771,62 @@ var ObservableQuery = (function (_super) {
|
|
|
770
771
|
id: this.queryId,
|
|
771
772
|
}) }) : result;
|
|
772
773
|
};
|
|
774
|
+
ObservableQuery.prototype.resetNotifications = function () {
|
|
775
|
+
this.cancelNotifyTimeout();
|
|
776
|
+
this.dirty = false;
|
|
777
|
+
};
|
|
778
|
+
ObservableQuery.prototype.cancelNotifyTimeout = function () {
|
|
779
|
+
if (this.notifyTimeout) {
|
|
780
|
+
clearTimeout(this.notifyTimeout);
|
|
781
|
+
this.notifyTimeout = void 0;
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
ObservableQuery.prototype.scheduleNotify = function () {
|
|
785
|
+
var _this = this;
|
|
786
|
+
if (this.dirty)
|
|
787
|
+
return;
|
|
788
|
+
this.dirty = true;
|
|
789
|
+
if (!this.notifyTimeout) {
|
|
790
|
+
this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
ObservableQuery.prototype.notify = function () {
|
|
794
|
+
this.cancelNotifyTimeout();
|
|
795
|
+
if (this.dirty) {
|
|
796
|
+
if (this.options.fetchPolicy == "cache-only" ||
|
|
797
|
+
this.options.fetchPolicy == "cache-and-network" ||
|
|
798
|
+
!isNetworkRequestInFlight(this.queryInfo.networkStatus)) {
|
|
799
|
+
var diff = this.queryInfo.getDiff();
|
|
800
|
+
if (diff.fromOptimisticTransaction) {
|
|
801
|
+
this.observe();
|
|
802
|
+
}
|
|
803
|
+
else {
|
|
804
|
+
this.reobserveCacheFirst();
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
this.dirty = false;
|
|
809
|
+
};
|
|
810
|
+
ObservableQuery.prototype.reobserveCacheFirst = function () {
|
|
811
|
+
var _a = this.options, fetchPolicy = _a.fetchPolicy, nextFetchPolicy = _a.nextFetchPolicy;
|
|
812
|
+
if (fetchPolicy === "cache-and-network" || fetchPolicy === "network-only") {
|
|
813
|
+
return this.reobserve({
|
|
814
|
+
fetchPolicy: "cache-first",
|
|
815
|
+
nextFetchPolicy: function (currentFetchPolicy, context) {
|
|
816
|
+
this.nextFetchPolicy = nextFetchPolicy;
|
|
817
|
+
if (typeof this.nextFetchPolicy === "function") {
|
|
818
|
+
return this.nextFetchPolicy(currentFetchPolicy, context);
|
|
819
|
+
}
|
|
820
|
+
return fetchPolicy;
|
|
821
|
+
},
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
return this.reobserve();
|
|
825
|
+
};
|
|
773
826
|
ObservableQuery.inactiveOnCreation = new optimism.Slot();
|
|
774
827
|
return ObservableQuery;
|
|
775
828
|
}(utilities.Observable));
|
|
776
829
|
utilities.fixObservableSubclass(ObservableQuery);
|
|
777
|
-
function reobserveCacheFirst(obsQuery) {
|
|
778
|
-
var _a = obsQuery.options, fetchPolicy = _a.fetchPolicy, nextFetchPolicy = _a.nextFetchPolicy;
|
|
779
|
-
if (fetchPolicy === "cache-and-network" || fetchPolicy === "network-only") {
|
|
780
|
-
return obsQuery.reobserve({
|
|
781
|
-
fetchPolicy: "cache-first",
|
|
782
|
-
nextFetchPolicy: function (currentFetchPolicy, context) {
|
|
783
|
-
this.nextFetchPolicy = nextFetchPolicy;
|
|
784
|
-
if (typeof this.nextFetchPolicy === "function") {
|
|
785
|
-
return this.nextFetchPolicy(currentFetchPolicy, context);
|
|
786
|
-
}
|
|
787
|
-
return fetchPolicy;
|
|
788
|
-
},
|
|
789
|
-
});
|
|
790
|
-
}
|
|
791
|
-
return obsQuery.reobserve();
|
|
792
|
-
}
|
|
793
830
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
794
831
|
globalThis.__DEV__ !== false && globals.invariant.error(25, error.message, error.stack);
|
|
795
832
|
}
|
|
@@ -815,21 +852,13 @@ function wrapDestructiveCacheMethod(cache, methodName) {
|
|
|
815
852
|
};
|
|
816
853
|
}
|
|
817
854
|
}
|
|
818
|
-
function cancelNotifyTimeout(info) {
|
|
819
|
-
if (info["notifyTimeout"]) {
|
|
820
|
-
clearTimeout(info["notifyTimeout"]);
|
|
821
|
-
info["notifyTimeout"] = void 0;
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
855
|
var QueryInfo = (function () {
|
|
825
856
|
function QueryInfo(queryManager, queryId) {
|
|
826
857
|
if (queryId === void 0) { queryId = queryManager.generateQueryId(); }
|
|
827
858
|
this.queryId = queryId;
|
|
828
|
-
this.listeners = new Set();
|
|
829
859
|
this.document = null;
|
|
830
860
|
this.lastRequestId = 1;
|
|
831
861
|
this.stopped = false;
|
|
832
|
-
this.dirty = false;
|
|
833
862
|
this.observableQuery = null;
|
|
834
863
|
var cache = (this.cache = queryManager.cache);
|
|
835
864
|
if (!destructiveMethodCounts.has(cache)) {
|
|
@@ -865,10 +894,6 @@ var QueryInfo = (function () {
|
|
|
865
894
|
}
|
|
866
895
|
return this;
|
|
867
896
|
};
|
|
868
|
-
QueryInfo.prototype.reset = function () {
|
|
869
|
-
cancelNotifyTimeout(this);
|
|
870
|
-
this.dirty = false;
|
|
871
|
-
};
|
|
872
897
|
QueryInfo.prototype.resetDiff = function () {
|
|
873
898
|
this.lastDiff = void 0;
|
|
874
899
|
};
|
|
@@ -907,68 +932,29 @@ var QueryInfo = (function () {
|
|
|
907
932
|
};
|
|
908
933
|
};
|
|
909
934
|
QueryInfo.prototype.setDiff = function (diff) {
|
|
910
|
-
var
|
|
911
|
-
var _a;
|
|
935
|
+
var _a, _b;
|
|
912
936
|
var oldDiff = this.lastDiff && this.lastDiff.diff;
|
|
913
937
|
if (diff && !diff.complete && ((_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.getLastError())) {
|
|
914
938
|
return;
|
|
915
939
|
}
|
|
916
940
|
this.updateLastDiff(diff);
|
|
917
|
-
if (!
|
|
918
|
-
this.
|
|
919
|
-
if (!this.notifyTimeout) {
|
|
920
|
-
this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
|
|
921
|
-
}
|
|
941
|
+
if (!equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
|
|
942
|
+
(_b = this.observableQuery) === null || _b === void 0 ? void 0 : _b["scheduleNotify"]();
|
|
922
943
|
}
|
|
923
944
|
};
|
|
924
945
|
QueryInfo.prototype.setObservableQuery = function (oq) {
|
|
925
|
-
var _this = this;
|
|
926
946
|
if (oq === this.observableQuery)
|
|
927
947
|
return;
|
|
928
|
-
if (this.oqListener) {
|
|
929
|
-
this.listeners.delete(this.oqListener);
|
|
930
|
-
}
|
|
931
948
|
this.observableQuery = oq;
|
|
932
949
|
if (oq) {
|
|
933
950
|
oq["queryInfo"] = this;
|
|
934
|
-
this.listeners.add((this.oqListener = function () {
|
|
935
|
-
var diff = _this.getDiff();
|
|
936
|
-
if (diff.fromOptimisticTransaction) {
|
|
937
|
-
oq["observe"]();
|
|
938
|
-
}
|
|
939
|
-
else {
|
|
940
|
-
reobserveCacheFirst(oq);
|
|
941
|
-
}
|
|
942
|
-
}));
|
|
943
|
-
}
|
|
944
|
-
else {
|
|
945
|
-
delete this.oqListener;
|
|
946
951
|
}
|
|
947
952
|
};
|
|
948
|
-
QueryInfo.prototype.notify = function () {
|
|
949
|
-
var _this = this;
|
|
950
|
-
cancelNotifyTimeout(this);
|
|
951
|
-
if (this.shouldNotify()) {
|
|
952
|
-
this.listeners.forEach(function (listener) { return listener(_this); });
|
|
953
|
-
}
|
|
954
|
-
this.dirty = false;
|
|
955
|
-
};
|
|
956
|
-
QueryInfo.prototype.shouldNotify = function () {
|
|
957
|
-
if (!this.dirty || !this.listeners.size) {
|
|
958
|
-
return false;
|
|
959
|
-
}
|
|
960
|
-
if (isNetworkRequestInFlight(this.networkStatus) && this.observableQuery) {
|
|
961
|
-
var fetchPolicy = this.observableQuery.options.fetchPolicy;
|
|
962
|
-
if (fetchPolicy !== "cache-only" && fetchPolicy !== "cache-and-network") {
|
|
963
|
-
return false;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
return true;
|
|
967
|
-
};
|
|
968
953
|
QueryInfo.prototype.stop = function () {
|
|
954
|
+
var _a;
|
|
969
955
|
if (!this.stopped) {
|
|
970
956
|
this.stopped = true;
|
|
971
|
-
this.
|
|
957
|
+
(_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a["resetNotifications"]();
|
|
972
958
|
this.cancel();
|
|
973
959
|
var oq = this.observableQuery;
|
|
974
960
|
if (oq)
|
|
@@ -1005,9 +991,10 @@ var QueryInfo = (function () {
|
|
|
1005
991
|
};
|
|
1006
992
|
QueryInfo.prototype.markResult = function (result, document, options, cacheWriteBehavior) {
|
|
1007
993
|
var _this = this;
|
|
994
|
+
var _a;
|
|
1008
995
|
var merger = new utilities.DeepMerger();
|
|
1009
996
|
var graphQLErrors = utilities.isNonEmptyArray(result.errors) ? result.errors.slice(0) : [];
|
|
1010
|
-
this.
|
|
997
|
+
(_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a["resetNotifications"]();
|
|
1011
998
|
if ("incremental" in result && utilities.isNonEmptyArray(result.incremental)) {
|
|
1012
999
|
var mergedData = utilities.mergeIncrementalData(this.getDiff().result, result);
|
|
1013
1000
|
result.data = mergedData;
|
|
@@ -1063,9 +1050,10 @@ var QueryInfo = (function () {
|
|
|
1063
1050
|
return (this.networkStatus = exports.NetworkStatus.ready);
|
|
1064
1051
|
};
|
|
1065
1052
|
QueryInfo.prototype.markError = function (error) {
|
|
1053
|
+
var _a;
|
|
1066
1054
|
this.networkStatus = exports.NetworkStatus.error;
|
|
1067
1055
|
this.lastWrite = void 0;
|
|
1068
|
-
this.
|
|
1056
|
+
(_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a["resetNotifications"]();
|
|
1069
1057
|
if (error.graphQLErrors) {
|
|
1070
1058
|
this.graphQLErrors = error.graphQLErrors;
|
|
1071
1059
|
}
|
|
@@ -1690,7 +1678,7 @@ var QueryManager = (function () {
|
|
|
1690
1678
|
QueryManager.prototype.broadcastQueries = function () {
|
|
1691
1679
|
if (this.onBroadcast)
|
|
1692
1680
|
this.onBroadcast();
|
|
1693
|
-
this.queries.forEach(function (info) { return info.notify(); });
|
|
1681
|
+
this.queries.forEach(function (info) { var _a; return (_a = info.observableQuery) === null || _a === void 0 ? void 0 : _a["notify"](); });
|
|
1694
1682
|
};
|
|
1695
1683
|
QueryManager.prototype.getLocalState = function () {
|
|
1696
1684
|
return this.localState;
|
|
@@ -1888,9 +1876,7 @@ var QueryManager = (function () {
|
|
|
1888
1876
|
var result;
|
|
1889
1877
|
if (onQueryUpdated) {
|
|
1890
1878
|
if (!diff) {
|
|
1891
|
-
|
|
1892
|
-
info.reset();
|
|
1893
|
-
diff = info.getDiff();
|
|
1879
|
+
diff = _this.cache.diff(oq["queryInfo"]["getDiffOptions"]());
|
|
1894
1880
|
}
|
|
1895
1881
|
result = onQueryUpdated(oq, diff, lastDiff);
|
|
1896
1882
|
}
|