@apollo/client 3.1.0-pre.4 → 3.1.0
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 +24 -11
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-client.cjs.min.js +1 -1
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +4 -3
- package/core/ApolloClient.js.map +1 -1
- package/core/Reobserver.d.ts.map +1 -1
- package/core/Reobserver.js +2 -7
- package/core/Reobserver.js.map +1 -1
- package/core/core.cjs.js +5 -11
- package/core/core.cjs.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/package.json +2 -2
- package/react/data/MutationData.d.ts.map +1 -1
- package/react/data/MutationData.js +2 -1
- package/react/data/MutationData.js.map +1 -1
- package/react/data/data.cjs.js +2 -1
- package/react/data/data.cjs.js.map +1 -1
- package/testing/testing.cjs.js +6 -6
- package/testing/testing.cjs.js.map +1 -1
- package/utilities/common/compact.d.ts +3 -0
- package/utilities/common/compact.d.ts.map +1 -0
- package/utilities/common/compact.js +19 -0
- package/utilities/common/compact.js.map +1 -0
- package/utilities/index.d.ts +1 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/testing/itAsync.d.ts.map +1 -1
- package/utilities/testing/itAsync.js +6 -6
- package/utilities/testing/itAsync.js.map +1 -1
- package/utilities/utilities.cjs.js +20 -0
- package/utilities/utilities.cjs.js.map +1 -1
package/apollo-client.cjs.js
CHANGED
|
@@ -991,6 +991,25 @@ function graphQLResultHasError(result) {
|
|
|
991
991
|
var canUseWeakMap = typeof WeakMap === 'function' && !(typeof navigator === 'object' &&
|
|
992
992
|
navigator.product === 'ReactNative');
|
|
993
993
|
|
|
994
|
+
function compact() {
|
|
995
|
+
var objects = [];
|
|
996
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
997
|
+
objects[_i] = arguments[_i];
|
|
998
|
+
}
|
|
999
|
+
var result = Object.create(null);
|
|
1000
|
+
objects.forEach(function (obj) {
|
|
1001
|
+
if (!obj)
|
|
1002
|
+
return;
|
|
1003
|
+
Object.keys(obj).forEach(function (key) {
|
|
1004
|
+
var value = obj[key];
|
|
1005
|
+
if (value !== void 0) {
|
|
1006
|
+
result[key] = value;
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
});
|
|
1010
|
+
return result;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
994
1013
|
function fromError(errorValue) {
|
|
995
1014
|
return new Observable(function (observer) {
|
|
996
1015
|
observer.error(errorValue);
|
|
@@ -1558,13 +1577,7 @@ var Reobserver = (function () {
|
|
|
1558
1577
|
return (this.concast = concast).promise;
|
|
1559
1578
|
};
|
|
1560
1579
|
Reobserver.prototype.updateOptions = function (newOptions) {
|
|
1561
|
-
|
|
1562
|
-
Object.keys(newOptions).forEach(function (key) {
|
|
1563
|
-
var value = newOptions[key];
|
|
1564
|
-
if (value !== void 0) {
|
|
1565
|
-
_this.options[key] = value;
|
|
1566
|
-
}
|
|
1567
|
-
});
|
|
1580
|
+
Object.assign(this.options, compact(newOptions));
|
|
1568
1581
|
this.updatePolling();
|
|
1569
1582
|
return this;
|
|
1570
1583
|
};
|
|
@@ -4693,7 +4706,7 @@ var ApolloClient = (function () {
|
|
|
4693
4706
|
};
|
|
4694
4707
|
ApolloClient.prototype.watchQuery = function (options) {
|
|
4695
4708
|
if (this.defaultOptions.watchQuery) {
|
|
4696
|
-
options =
|
|
4709
|
+
options = compact(this.defaultOptions.watchQuery, options);
|
|
4697
4710
|
}
|
|
4698
4711
|
if (this.disableNetworkFetches &&
|
|
4699
4712
|
(options.fetchPolicy === 'network-only' ||
|
|
@@ -4704,7 +4717,7 @@ var ApolloClient = (function () {
|
|
|
4704
4717
|
};
|
|
4705
4718
|
ApolloClient.prototype.query = function (options) {
|
|
4706
4719
|
if (this.defaultOptions.query) {
|
|
4707
|
-
options =
|
|
4720
|
+
options = compact(this.defaultOptions.query, options);
|
|
4708
4721
|
}
|
|
4709
4722
|
process.env.NODE_ENV === "production" ? tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 10) : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
|
|
4710
4723
|
'client.query can only return a single result. Please use client.watchQuery ' +
|
|
@@ -4717,7 +4730,7 @@ var ApolloClient = (function () {
|
|
|
4717
4730
|
};
|
|
4718
4731
|
ApolloClient.prototype.mutate = function (options) {
|
|
4719
4732
|
if (this.defaultOptions.mutate) {
|
|
4720
|
-
options =
|
|
4733
|
+
options = compact(this.defaultOptions.mutate, options);
|
|
4721
4734
|
}
|
|
4722
4735
|
return this.queryManager.mutate(options);
|
|
4723
4736
|
};
|
|
@@ -5125,7 +5138,7 @@ var MutationData = (function (_super) {
|
|
|
5125
5138
|
MutationData.prototype.cleanup = function () {
|
|
5126
5139
|
};
|
|
5127
5140
|
MutationData.prototype.mutate = function (mutationFunctionOptions) {
|
|
5128
|
-
return this.refreshClient().client.mutate(
|
|
5141
|
+
return this.refreshClient().client.mutate(compact(this.getOptions(), mutationFunctionOptions));
|
|
5129
5142
|
};
|
|
5130
5143
|
MutationData.prototype.onMutationStart = function () {
|
|
5131
5144
|
if (!this.result.loading && !this.getOptions().ignoreResults) {
|