@apollo/client 3.13.4 → 3.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/apollo-client.cjs +36 -24
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/ObservableQuery.d.ts +8 -0
- package/core/ObservableQuery.js +19 -3
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +1 -0
- package/core/QueryInfo.js +8 -7
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +2 -2
- package/core/QueryManager.js +13 -15
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +33 -22
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +33 -22
- 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/hooks/hooks.cjs +3 -1
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +3 -1
- package/react/hooks/useQuery.d.ts +2 -2
- package/react/hooks/useQuery.js +4 -2
- 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/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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 3.13.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#12285](https://github.com/apollographql/apollo-client/pull/12285) [`cdc55ff`](https://github.com/apollographql/apollo-client/commit/cdc55ff54bf4c83ec8571508ec4bf8156af1bc97) Thanks [@phryneas](https://github.com/phryneas)! - keep ObservableQuery created by useQuery non-active before it is first subscribed
|
|
8
|
+
|
|
9
|
+
## 3.13.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#12461](https://github.com/apollographql/apollo-client/pull/12461) [`12c8d06`](https://github.com/apollographql/apollo-client/commit/12c8d06f1ef7cfbece8e3a63b7ad09d91334f663) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where a `cache-first` query would return the result for previous variables when a cache update is issued after simultaneously changing variables and skipping the query.
|
|
14
|
+
|
|
3
15
|
## 3.13.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/apollo-client.cjs
CHANGED
|
@@ -7,10 +7,10 @@ var tsInvariant = require('ts-invariant');
|
|
|
7
7
|
var equal = require('@wry/equality');
|
|
8
8
|
var graphql = require('graphql');
|
|
9
9
|
var caches = require('@wry/caches');
|
|
10
|
+
var optimism = require('optimism');
|
|
10
11
|
var zenObservableTs = require('zen-observable-ts');
|
|
11
12
|
require('symbol-observable');
|
|
12
13
|
var trie = require('@wry/trie');
|
|
13
|
-
var optimism = require('optimism');
|
|
14
14
|
var graphqlTag = require('graphql-tag');
|
|
15
15
|
var React = require('rehackt');
|
|
16
16
|
|
|
@@ -31,7 +31,7 @@ function _interopNamespace(e) {
|
|
|
31
31
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
32
32
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
33
33
|
|
|
34
|
-
var version = "3.13.
|
|
34
|
+
var version = "3.13.6";
|
|
35
35
|
|
|
36
36
|
function maybe(thunk) {
|
|
37
37
|
try {
|
|
@@ -5169,7 +5169,13 @@ var ObservableQuery = (function (_super) {
|
|
|
5169
5169
|
tslib.__extends(ObservableQuery, _super);
|
|
5170
5170
|
function ObservableQuery(_a) {
|
|
5171
5171
|
var queryManager = _a.queryManager, queryInfo = _a.queryInfo, options = _a.options;
|
|
5172
|
-
var _this =
|
|
5172
|
+
var _this = this;
|
|
5173
|
+
var startedInactive = ObservableQuery.inactiveOnCreation.getValue();
|
|
5174
|
+
_this = _super.call(this, function (observer) {
|
|
5175
|
+
if (startedInactive) {
|
|
5176
|
+
queryManager["queries"].set(_this.queryId, queryInfo);
|
|
5177
|
+
startedInactive = false;
|
|
5178
|
+
}
|
|
5173
5179
|
try {
|
|
5174
5180
|
var subObserver = observer._subscription._observer;
|
|
5175
5181
|
if (subObserver && !subObserver.error) {
|
|
@@ -5549,8 +5555,9 @@ var ObservableQuery = (function (_super) {
|
|
|
5549
5555
|
return options.fetchPolicy;
|
|
5550
5556
|
};
|
|
5551
5557
|
ObservableQuery.prototype.fetch = function (options, newNetworkStatus, query) {
|
|
5552
|
-
this.queryManager.
|
|
5553
|
-
|
|
5558
|
+
var queryInfo = this.queryManager.getOrCreateQuery(this.queryId);
|
|
5559
|
+
queryInfo.setObservableQuery(this);
|
|
5560
|
+
return this.queryManager["fetchConcastWithInfo"](queryInfo, options, newNetworkStatus, query);
|
|
5554
5561
|
};
|
|
5555
5562
|
ObservableQuery.prototype.updatePolling = function () {
|
|
5556
5563
|
var _this = this;
|
|
@@ -5732,6 +5739,7 @@ var ObservableQuery = (function (_super) {
|
|
|
5732
5739
|
id: this.queryId,
|
|
5733
5740
|
}) }) : result;
|
|
5734
5741
|
};
|
|
5742
|
+
ObservableQuery.inactiveOnCreation = new optimism.Slot();
|
|
5735
5743
|
return ObservableQuery;
|
|
5736
5744
|
}(zenObservableTs.Observable));
|
|
5737
5745
|
fixObservableSubclass(ObservableQuery);
|
|
@@ -5809,6 +5817,7 @@ var QueryInfo = (function () {
|
|
|
5809
5817
|
}
|
|
5810
5818
|
if (!equal.equal(query.variables, this.variables)) {
|
|
5811
5819
|
this.lastDiff = void 0;
|
|
5820
|
+
this.cancel();
|
|
5812
5821
|
}
|
|
5813
5822
|
Object.assign(this, {
|
|
5814
5823
|
document: query.document,
|
|
@@ -5930,13 +5939,16 @@ var QueryInfo = (function () {
|
|
|
5930
5939
|
this.stopped = true;
|
|
5931
5940
|
this.reset();
|
|
5932
5941
|
this.cancel();
|
|
5933
|
-
this.cancel = QueryInfo.prototype.cancel;
|
|
5934
5942
|
var oq = this.observableQuery;
|
|
5935
5943
|
if (oq)
|
|
5936
5944
|
oq.stopPolling();
|
|
5937
5945
|
}
|
|
5938
5946
|
};
|
|
5939
|
-
QueryInfo.prototype.cancel = function () {
|
|
5947
|
+
QueryInfo.prototype.cancel = function () {
|
|
5948
|
+
var _a;
|
|
5949
|
+
(_a = this.cancelWatch) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
5950
|
+
this.cancelWatch = void 0;
|
|
5951
|
+
};
|
|
5940
5952
|
QueryInfo.prototype.updateWatch = function (variables) {
|
|
5941
5953
|
var _this = this;
|
|
5942
5954
|
if (variables === void 0) { variables = this.variables; }
|
|
@@ -5947,7 +5959,7 @@ var QueryInfo = (function () {
|
|
|
5947
5959
|
var watchOptions = tslib.__assign(tslib.__assign({}, this.getDiffOptions(variables)), { watcher: this, callback: function (diff) { return _this.setDiff(diff); } });
|
|
5948
5960
|
if (!this.lastWatch || !equal.equal(watchOptions, this.lastWatch)) {
|
|
5949
5961
|
this.cancel();
|
|
5950
|
-
this.
|
|
5962
|
+
this.cancelWatch = this.cache.watch((this.lastWatch = watchOptions));
|
|
5951
5963
|
}
|
|
5952
5964
|
};
|
|
5953
5965
|
QueryInfo.prototype.resetLastWrite = function () {
|
|
@@ -6350,8 +6362,7 @@ var QueryManager = (function () {
|
|
|
6350
6362
|
return true;
|
|
6351
6363
|
};
|
|
6352
6364
|
QueryManager.prototype.fetchQuery = function (queryId, options, networkStatus) {
|
|
6353
|
-
return this.fetchConcastWithInfo(queryId, options, networkStatus).concast
|
|
6354
|
-
.promise;
|
|
6365
|
+
return this.fetchConcastWithInfo(this.getOrCreateQuery(queryId), options, networkStatus).concast.promise;
|
|
6355
6366
|
};
|
|
6356
6367
|
QueryManager.prototype.getQueryStore = function () {
|
|
6357
6368
|
var store = Object.create(null);
|
|
@@ -6419,7 +6430,9 @@ var QueryManager = (function () {
|
|
|
6419
6430
|
options: options,
|
|
6420
6431
|
});
|
|
6421
6432
|
observable["lastQuery"] = query;
|
|
6422
|
-
|
|
6433
|
+
if (!ObservableQuery["inactiveOnCreation"].getValue()) {
|
|
6434
|
+
this.queries.set(observable.queryId, queryInfo);
|
|
6435
|
+
}
|
|
6423
6436
|
queryInfo.init({
|
|
6424
6437
|
document: query,
|
|
6425
6438
|
observableQuery: observable,
|
|
@@ -6531,7 +6544,7 @@ var QueryManager = (function () {
|
|
|
6531
6544
|
if (legacyQueryOptions.size) {
|
|
6532
6545
|
legacyQueryOptions.forEach(function (options) {
|
|
6533
6546
|
var queryId = makeUniqueId("legacyOneTimeQuery");
|
|
6534
|
-
var queryInfo = _this.
|
|
6547
|
+
var queryInfo = _this.getOrCreateQuery(queryId).init({
|
|
6535
6548
|
document: options.query,
|
|
6536
6549
|
variables: options.variables,
|
|
6537
6550
|
});
|
|
@@ -6571,14 +6584,11 @@ var QueryManager = (function () {
|
|
|
6571
6584
|
(fetchPolicy !== "standby" && fetchPolicy !== "cache-only")) {
|
|
6572
6585
|
observableQueryPromises.push(observableQuery.refetch());
|
|
6573
6586
|
}
|
|
6574
|
-
_this.
|
|
6587
|
+
(_this.queries.get(queryId) || observableQuery["queryInfo"]).setDiff(null);
|
|
6575
6588
|
});
|
|
6576
6589
|
this.broadcastQueries();
|
|
6577
6590
|
return Promise.all(observableQueryPromises);
|
|
6578
6591
|
};
|
|
6579
|
-
QueryManager.prototype.setObservableQuery = function (observableQuery) {
|
|
6580
|
-
this.getQuery(observableQuery.queryId).setObservableQuery(observableQuery);
|
|
6581
|
-
};
|
|
6582
6592
|
QueryManager.prototype.startGraphQLSubscription = function (options) {
|
|
6583
6593
|
var _this = this;
|
|
6584
6594
|
var query = options.query, variables = options.variables;
|
|
@@ -6639,9 +6649,10 @@ var QueryManager = (function () {
|
|
|
6639
6649
|
this.removeQuery(queryId);
|
|
6640
6650
|
};
|
|
6641
6651
|
QueryManager.prototype.removeQuery = function (queryId) {
|
|
6652
|
+
var _a;
|
|
6642
6653
|
this.fetchCancelFns.delete(queryId);
|
|
6643
6654
|
if (this.queries.has(queryId)) {
|
|
6644
|
-
this.
|
|
6655
|
+
(_a = this.queries.get(queryId)) === null || _a === void 0 ? void 0 : _a.stop();
|
|
6645
6656
|
this.queries.delete(queryId);
|
|
6646
6657
|
}
|
|
6647
6658
|
};
|
|
@@ -6749,13 +6760,12 @@ var QueryManager = (function () {
|
|
|
6749
6760
|
throw error;
|
|
6750
6761
|
});
|
|
6751
6762
|
};
|
|
6752
|
-
QueryManager.prototype.fetchConcastWithInfo = function (
|
|
6763
|
+
QueryManager.prototype.fetchConcastWithInfo = function (queryInfo, options,
|
|
6753
6764
|
networkStatus, query) {
|
|
6754
6765
|
var _this = this;
|
|
6755
6766
|
if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
|
|
6756
6767
|
if (query === void 0) { query = options.query; }
|
|
6757
6768
|
var variables = this.getVariables(query, options.variables);
|
|
6758
|
-
var queryInfo = this.getQuery(queryId);
|
|
6759
6769
|
var defaults = this.defaultOptions.watchQuery;
|
|
6760
6770
|
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;
|
|
6761
6771
|
var normalized = Object.assign({}, options, {
|
|
@@ -6778,8 +6788,8 @@ var QueryManager = (function () {
|
|
|
6778
6788
|
}
|
|
6779
6789
|
return sourcesWithInfo;
|
|
6780
6790
|
};
|
|
6781
|
-
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
|
|
6782
|
-
this.fetchCancelFns.set(queryId, function (reason) {
|
|
6791
|
+
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryInfo.queryId); };
|
|
6792
|
+
this.fetchCancelFns.set(queryInfo.queryId, function (reason) {
|
|
6783
6793
|
cleanupCancelFn();
|
|
6784
6794
|
setTimeout(function () { return concast.cancel(reason); });
|
|
6785
6795
|
});
|
|
@@ -6810,7 +6820,7 @@ var QueryManager = (function () {
|
|
|
6810
6820
|
this.getObservableQueries(include).forEach(function (oq, queryId) {
|
|
6811
6821
|
includedQueriesById.set(queryId, {
|
|
6812
6822
|
oq: oq,
|
|
6813
|
-
lastDiff: _this.
|
|
6823
|
+
lastDiff: (_this.queries.get(queryId) || oq["queryInfo"]).getDiff(),
|
|
6814
6824
|
});
|
|
6815
6825
|
});
|
|
6816
6826
|
}
|
|
@@ -7006,7 +7016,7 @@ var QueryManager = (function () {
|
|
|
7006
7016
|
return { fromLink: false, sources: [] };
|
|
7007
7017
|
}
|
|
7008
7018
|
};
|
|
7009
|
-
QueryManager.prototype.
|
|
7019
|
+
QueryManager.prototype.getOrCreateQuery = function (queryId) {
|
|
7010
7020
|
if (queryId && !this.queries.has(queryId)) {
|
|
7011
7021
|
this.queries.set(queryId, new QueryInfo(this, queryId));
|
|
7012
7022
|
}
|
|
@@ -7897,7 +7907,9 @@ function useInternalState(client, query, options, renderPromises, makeWatchQuery
|
|
|
7897
7907
|
observable:
|
|
7898
7908
|
(renderPromises &&
|
|
7899
7909
|
renderPromises.getSSRObservable(makeWatchQueryOptions())) ||
|
|
7900
|
-
|
|
7910
|
+
ObservableQuery["inactiveOnCreation"].withValue(!renderPromises, function () {
|
|
7911
|
+
return client.watchQuery(getObsQueryOptions(void 0, client, options, makeWatchQueryOptions()));
|
|
7912
|
+
}),
|
|
7901
7913
|
resultData: {
|
|
7902
7914
|
previousData: (_a = previous === null || previous === void 0 ? void 0 : previous.resultData.current) === null || _a === void 0 ? void 0 : _a.data,
|
|
7903
7915
|
},
|