@apollo/client 3.4.7 → 3.4.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/apollo-client.cjs.js +79 -56
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-core.cjs.js +71 -48
- package/apollo-core.cjs.js.map +1 -1
- package/apollo-core.cjs.min.js +1 -1
- package/cache/cache.cjs.js +9 -6
- package/cache/cache.cjs.js.map +1 -1
- package/cache/inmemory/policies.js +9 -6
- package/cache/inmemory/policies.js.map +1 -1
- package/core/ObservableQuery.d.ts +7 -6
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +61 -41
- package/core/ObservableQuery.js.map +1 -1
- package/core/core.cjs.js +62 -42
- package/core/core.cjs.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/package.json +5 -5
- package/react/data/QueryData.d.ts.map +1 -1
- package/react/data/QueryData.js +8 -8
- package/react/data/QueryData.js.map +1 -1
- package/react/data/data.cjs.js +8 -8
- package/react/data/data.cjs.js.map +1 -1
- package/version.js +1 -1
package/apollo-client.cjs.js
CHANGED
|
@@ -1307,7 +1307,7 @@ var concat = ApolloLink.concat;
|
|
|
1307
1307
|
|
|
1308
1308
|
var execute = ApolloLink.execute;
|
|
1309
1309
|
|
|
1310
|
-
var version = '3.4.
|
|
1310
|
+
var version = '3.4.8';
|
|
1311
1311
|
|
|
1312
1312
|
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1313
1313
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -3375,24 +3375,27 @@ function makeAliasMap(selectionSet, fragmentMap) {
|
|
|
3375
3375
|
}
|
|
3376
3376
|
function computeKeyObject(response, specifier, strict, aliasMap) {
|
|
3377
3377
|
var keyObj = Object.create(null);
|
|
3378
|
-
var
|
|
3378
|
+
var lastResponseKey;
|
|
3379
|
+
var lastActualKey;
|
|
3379
3380
|
specifier.forEach(function (s) {
|
|
3380
3381
|
if (Array.isArray(s)) {
|
|
3381
|
-
if (typeof
|
|
3382
|
+
if (typeof lastActualKey === "string" &&
|
|
3383
|
+
typeof lastResponseKey === "string") {
|
|
3382
3384
|
var subsets = aliasMap && aliasMap.subsets;
|
|
3383
|
-
var subset = subsets && subsets[
|
|
3384
|
-
keyObj[
|
|
3385
|
+
var subset = subsets && subsets[lastActualKey];
|
|
3386
|
+
keyObj[lastActualKey] =
|
|
3387
|
+
computeKeyObject(response[lastResponseKey], s, strict, subset);
|
|
3385
3388
|
}
|
|
3386
3389
|
}
|
|
3387
3390
|
else {
|
|
3388
3391
|
var aliases = aliasMap && aliasMap.aliases;
|
|
3389
3392
|
var responseName = aliases && aliases[s] || s;
|
|
3390
3393
|
if (hasOwn.call(response, responseName)) {
|
|
3391
|
-
keyObj[
|
|
3394
|
+
keyObj[lastActualKey = s] = response[lastResponseKey = responseName];
|
|
3392
3395
|
}
|
|
3393
3396
|
else {
|
|
3394
3397
|
__DEV__ ? tsInvariant.invariant(!strict, "Missing field '" + responseName + "' while computing key fields") : tsInvariant.invariant(!strict, 5);
|
|
3395
|
-
|
|
3398
|
+
lastResponseKey = lastActualKey = void 0;
|
|
3396
3399
|
}
|
|
3397
3400
|
}
|
|
3398
3401
|
});
|
|
@@ -3751,11 +3754,12 @@ var ObservableQuery = (function (_super) {
|
|
|
3751
3754
|
catch (_a) { }
|
|
3752
3755
|
var first = !_this.observers.size;
|
|
3753
3756
|
_this.observers.add(observer);
|
|
3754
|
-
|
|
3755
|
-
|
|
3757
|
+
var last = _this.last;
|
|
3758
|
+
if (last && last.error) {
|
|
3759
|
+
observer.error && observer.error(last.error);
|
|
3756
3760
|
}
|
|
3757
|
-
else if (
|
|
3758
|
-
observer.next && observer.next(
|
|
3761
|
+
else if (last && last.result) {
|
|
3762
|
+
observer.next && observer.next(last.result);
|
|
3759
3763
|
}
|
|
3760
3764
|
if (first) {
|
|
3761
3765
|
_this.reobserve().catch(function () { });
|
|
@@ -3768,18 +3772,6 @@ var ObservableQuery = (function (_super) {
|
|
|
3768
3772
|
}) || this;
|
|
3769
3773
|
_this.observers = new Set();
|
|
3770
3774
|
_this.subscriptions = new Set();
|
|
3771
|
-
_this.observer = {
|
|
3772
|
-
next: function (result) {
|
|
3773
|
-
if (_this.lastError || _this.isDifferentFromLastResult(result)) {
|
|
3774
|
-
_this.updateLastResult(result);
|
|
3775
|
-
iterateObserversSafely(_this.observers, 'next', result);
|
|
3776
|
-
}
|
|
3777
|
-
},
|
|
3778
|
-
error: function (error) {
|
|
3779
|
-
_this.updateLastResult(tslib.__assign(tslib.__assign({}, _this.lastResult), { error: error, errors: error.graphQLErrors, networkStatus: exports.NetworkStatus.error, loading: false }));
|
|
3780
|
-
iterateObserversSafely(_this.observers, 'error', _this.lastError = error);
|
|
3781
|
-
},
|
|
3782
|
-
};
|
|
3783
3775
|
_this.isTornDown = false;
|
|
3784
3776
|
_this.options = options;
|
|
3785
3777
|
_this.queryId = queryInfo.queryId || queryManager.generateQueryId();
|
|
@@ -3818,15 +3810,20 @@ var ObservableQuery = (function (_super) {
|
|
|
3818
3810
|
};
|
|
3819
3811
|
ObservableQuery.prototype.getCurrentResult = function (saveAsLastResult) {
|
|
3820
3812
|
if (saveAsLastResult === void 0) { saveAsLastResult = true; }
|
|
3821
|
-
var
|
|
3813
|
+
var lastResult = this.getLastResult(true);
|
|
3822
3814
|
var networkStatus = this.queryInfo.networkStatus ||
|
|
3823
3815
|
(lastResult && lastResult.networkStatus) ||
|
|
3824
3816
|
exports.NetworkStatus.ready;
|
|
3825
3817
|
var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
|
|
3826
3818
|
if (!this.queryManager.transform(this.options.query).hasForcedResolvers) {
|
|
3827
3819
|
var diff = this.queryInfo.getDiff();
|
|
3828
|
-
|
|
3829
|
-
|
|
3820
|
+
if (diff.complete || this.options.returnPartialData) {
|
|
3821
|
+
result.data = diff.result;
|
|
3822
|
+
}
|
|
3823
|
+
if (equality.equal(result.data, {})) {
|
|
3824
|
+
result.data = void 0;
|
|
3825
|
+
}
|
|
3826
|
+
var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
|
|
3830
3827
|
if (diff.complete) {
|
|
3831
3828
|
if (result.networkStatus === exports.NetworkStatus.loading &&
|
|
3832
3829
|
(fetchPolicy === 'cache-first' ||
|
|
@@ -3854,18 +3851,24 @@ var ObservableQuery = (function (_super) {
|
|
|
3854
3851
|
return result;
|
|
3855
3852
|
};
|
|
3856
3853
|
ObservableQuery.prototype.isDifferentFromLastResult = function (newResult) {
|
|
3857
|
-
return !equality.equal(this.
|
|
3854
|
+
return !this.last || !equality.equal(this.last.result, newResult);
|
|
3855
|
+
};
|
|
3856
|
+
ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
|
|
3857
|
+
var last = this.last;
|
|
3858
|
+
if (last &&
|
|
3859
|
+
last[key] &&
|
|
3860
|
+
(!variablesMustMatch || equality.equal(last.variables, this.variables))) {
|
|
3861
|
+
return last[key];
|
|
3862
|
+
}
|
|
3858
3863
|
};
|
|
3859
|
-
ObservableQuery.prototype.getLastResult = function () {
|
|
3860
|
-
return this.
|
|
3864
|
+
ObservableQuery.prototype.getLastResult = function (variablesMustMatch) {
|
|
3865
|
+
return this.getLast("result", variablesMustMatch);
|
|
3861
3866
|
};
|
|
3862
|
-
ObservableQuery.prototype.getLastError = function () {
|
|
3863
|
-
return this.
|
|
3867
|
+
ObservableQuery.prototype.getLastError = function (variablesMustMatch) {
|
|
3868
|
+
return this.getLast("error", variablesMustMatch);
|
|
3864
3869
|
};
|
|
3865
3870
|
ObservableQuery.prototype.resetLastResults = function () {
|
|
3866
|
-
delete this.
|
|
3867
|
-
delete this.lastResultSnapshot;
|
|
3868
|
-
delete this.lastError;
|
|
3871
|
+
delete this.last;
|
|
3869
3872
|
this.isTornDown = false;
|
|
3870
3873
|
};
|
|
3871
3874
|
ObservableQuery.prototype.resetQueryStoreErrors = function () {
|
|
@@ -3978,12 +3981,10 @@ var ObservableQuery = (function (_super) {
|
|
|
3978
3981
|
}, exports.NetworkStatus.setVariables);
|
|
3979
3982
|
};
|
|
3980
3983
|
ObservableQuery.prototype.updateQuery = function (mapFn) {
|
|
3981
|
-
var _a;
|
|
3982
3984
|
var queryManager = this.queryManager;
|
|
3983
3985
|
var result = queryManager.cache.diff({
|
|
3984
3986
|
query: this.options.query,
|
|
3985
3987
|
variables: this.variables,
|
|
3986
|
-
previousResult: (_a = this.lastResult) === null || _a === void 0 ? void 0 : _a.data,
|
|
3987
3988
|
returnPartialData: true,
|
|
3988
3989
|
optimistic: false,
|
|
3989
3990
|
}).result;
|
|
@@ -4052,18 +4053,18 @@ var ObservableQuery = (function (_super) {
|
|
|
4052
4053
|
};
|
|
4053
4054
|
poll();
|
|
4054
4055
|
};
|
|
4055
|
-
ObservableQuery.prototype.updateLastResult = function (newResult) {
|
|
4056
|
-
|
|
4057
|
-
this.
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
: cloneDeep(newResult);
|
|
4056
|
+
ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
|
|
4057
|
+
if (variables === void 0) { variables = this.variables; }
|
|
4058
|
+
this.last = tslib.__assign(tslib.__assign({}, this.last), { result: this.queryManager.assumeImmutableResults
|
|
4059
|
+
? newResult
|
|
4060
|
+
: cloneDeep(newResult), variables: variables });
|
|
4061
4061
|
if (!isNonEmptyArray(newResult.errors)) {
|
|
4062
|
-
delete this.
|
|
4062
|
+
delete this.last.error;
|
|
4063
4063
|
}
|
|
4064
|
-
return
|
|
4064
|
+
return this.last;
|
|
4065
4065
|
};
|
|
4066
4066
|
ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
|
|
4067
|
+
var _this = this;
|
|
4067
4068
|
this.isTornDown = false;
|
|
4068
4069
|
var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
|
|
4069
4070
|
newNetworkStatus === exports.NetworkStatus.fetchMore ||
|
|
@@ -4084,18 +4085,39 @@ var ObservableQuery = (function (_super) {
|
|
|
4084
4085
|
}
|
|
4085
4086
|
}
|
|
4086
4087
|
}
|
|
4088
|
+
var variables = options.variables && tslib.__assign({}, options.variables);
|
|
4087
4089
|
var concast = this.fetch(options, newNetworkStatus);
|
|
4090
|
+
var observer = {
|
|
4091
|
+
next: function (result) {
|
|
4092
|
+
_this.reportResult(result, variables);
|
|
4093
|
+
},
|
|
4094
|
+
error: function (error) {
|
|
4095
|
+
_this.reportError(error, variables);
|
|
4096
|
+
},
|
|
4097
|
+
};
|
|
4088
4098
|
if (!useDisposableConcast) {
|
|
4089
|
-
if (this.concast) {
|
|
4099
|
+
if (this.concast && this.observer) {
|
|
4090
4100
|
this.concast.removeObserver(this.observer, true);
|
|
4091
4101
|
}
|
|
4092
4102
|
this.concast = concast;
|
|
4103
|
+
this.observer = observer;
|
|
4093
4104
|
}
|
|
4094
|
-
concast.addObserver(
|
|
4105
|
+
concast.addObserver(observer);
|
|
4095
4106
|
return concast.promise;
|
|
4096
4107
|
};
|
|
4097
4108
|
ObservableQuery.prototype.observe = function () {
|
|
4098
|
-
this.
|
|
4109
|
+
this.reportResult(this.getCurrentResult(false), this.variables);
|
|
4110
|
+
};
|
|
4111
|
+
ObservableQuery.prototype.reportResult = function (result, variables) {
|
|
4112
|
+
if (this.getLastError() || this.isDifferentFromLastResult(result)) {
|
|
4113
|
+
this.updateLastResult(result, variables);
|
|
4114
|
+
iterateObserversSafely(this.observers, 'next', result);
|
|
4115
|
+
}
|
|
4116
|
+
};
|
|
4117
|
+
ObservableQuery.prototype.reportError = function (error, variables) {
|
|
4118
|
+
var errorResult = tslib.__assign(tslib.__assign({}, this.getLastResult()), { error: error, errors: error.graphQLErrors, networkStatus: exports.NetworkStatus.error, loading: false });
|
|
4119
|
+
this.updateLastResult(errorResult, variables);
|
|
4120
|
+
iterateObserversSafely(this.observers, 'error', this.last.error = error);
|
|
4099
4121
|
};
|
|
4100
4122
|
ObservableQuery.prototype.hasObservers = function () {
|
|
4101
4123
|
return this.observers.size > 0;
|
|
@@ -4103,9 +4125,10 @@ var ObservableQuery = (function (_super) {
|
|
|
4103
4125
|
ObservableQuery.prototype.tearDownQuery = function () {
|
|
4104
4126
|
if (this.isTornDown)
|
|
4105
4127
|
return;
|
|
4106
|
-
if (this.concast) {
|
|
4128
|
+
if (this.concast && this.observer) {
|
|
4107
4129
|
this.concast.removeObserver(this.observer);
|
|
4108
4130
|
delete this.concast;
|
|
4131
|
+
delete this.observer;
|
|
4109
4132
|
}
|
|
4110
4133
|
this.stopPolling();
|
|
4111
4134
|
this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
|
|
@@ -6288,14 +6311,14 @@ var QueryData = (function (_super) {
|
|
|
6288
6311
|
this.removeQuerySubscription();
|
|
6289
6312
|
var currentObservable = this.currentObservable;
|
|
6290
6313
|
if (currentObservable) {
|
|
6291
|
-
var
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
}
|
|
6314
|
+
var last = currentObservable["last"];
|
|
6315
|
+
try {
|
|
6316
|
+
currentObservable.resetLastResults();
|
|
6317
|
+
this.startQuerySubscription();
|
|
6318
|
+
}
|
|
6319
|
+
finally {
|
|
6320
|
+
currentObservable["last"] = last;
|
|
6321
|
+
}
|
|
6299
6322
|
}
|
|
6300
6323
|
};
|
|
6301
6324
|
QueryData.prototype.getExecuteResult = function () {
|