@apollo/client 3.6.0-rc.0 → 3.7.0-alpha.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 +33 -22
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/ApolloClient.d.ts +2 -3
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +2 -6
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +2 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +15 -9
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.js +3 -3
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +27 -25
- package/core/core.cjs.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/package.json +17 -17
- package/react/hooks/hooks.cjs +9 -6
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +6 -3
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +0 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +3 -3
- package/react/hooks/useQuery.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +5 -0
- package/utilities/common/mergeOptions.d.ts.map +1 -0
- package/utilities/common/mergeOptions.js +8 -0
- package/utilities/common/mergeOptions.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/utilities.cjs +7 -0
- package/utilities/utilities.cjs.map +1 -1
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -1088,6 +1088,12 @@ function stringifyForDisplay(value) {
|
|
|
1088
1088
|
}).split(JSON.stringify(undefId)).join("<undefined>");
|
|
1089
1089
|
}
|
|
1090
1090
|
|
|
1091
|
+
function mergeOptions(defaults, options) {
|
|
1092
|
+
return compact(defaults, options, options.variables && {
|
|
1093
|
+
variables: tslib.__assign(tslib.__assign({}, defaults.variables), options.variables),
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1091
1097
|
function fromError(errorValue) {
|
|
1092
1098
|
return new zenObservableTs.Observable(function (observer) {
|
|
1093
1099
|
observer.error(errorValue);
|
|
@@ -1292,7 +1298,7 @@ var concat = ApolloLink.concat;
|
|
|
1292
1298
|
|
|
1293
1299
|
var execute = ApolloLink.execute;
|
|
1294
1300
|
|
|
1295
|
-
var version = '3.
|
|
1301
|
+
var version = '3.7.0-alpha.0';
|
|
1296
1302
|
|
|
1297
1303
|
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1298
1304
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -3939,15 +3945,22 @@ var ObservableQuery = (function (_super) {
|
|
|
3939
3945
|
}) || this;
|
|
3940
3946
|
_this.observers = new Set();
|
|
3941
3947
|
_this.subscriptions = new Set();
|
|
3948
|
+
_this.queryInfo = queryInfo;
|
|
3949
|
+
_this.queryManager = queryManager;
|
|
3942
3950
|
_this.isTornDown = false;
|
|
3943
3951
|
_this.options = tslib.__assign({ initialFetchPolicy: options.fetchPolicy || "cache-first" }, options);
|
|
3944
3952
|
_this.queryId = queryInfo.queryId || queryManager.generateQueryId();
|
|
3945
|
-
var opDef = getOperationDefinition(
|
|
3953
|
+
var opDef = getOperationDefinition(_this.query);
|
|
3946
3954
|
_this.queryName = opDef && opDef.name && opDef.name.value;
|
|
3947
|
-
_this.queryManager = queryManager;
|
|
3948
|
-
_this.queryInfo = queryInfo;
|
|
3949
3955
|
return _this;
|
|
3950
3956
|
}
|
|
3957
|
+
Object.defineProperty(ObservableQuery.prototype, "query", {
|
|
3958
|
+
get: function () {
|
|
3959
|
+
return this.queryManager.transform(this.options.query).document;
|
|
3960
|
+
},
|
|
3961
|
+
enumerable: false,
|
|
3962
|
+
configurable: true
|
|
3963
|
+
});
|
|
3951
3964
|
Object.defineProperty(ObservableQuery.prototype, "variables", {
|
|
3952
3965
|
get: function () {
|
|
3953
3966
|
return this.options.variables;
|
|
@@ -4061,7 +4074,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4061
4074
|
reobserveOptions.fetchPolicy = 'network-only';
|
|
4062
4075
|
}
|
|
4063
4076
|
if (__DEV__ && variables && hasOwnProperty$2.call(variables, "variables")) {
|
|
4064
|
-
var queryDef = getQueryDefinition(this.
|
|
4077
|
+
var queryDef = getQueryDefinition(this.query);
|
|
4065
4078
|
var vars = queryDef.variableDefinitions;
|
|
4066
4079
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
4067
4080
|
__DEV__ && tsInvariant.invariant.warn("Called refetch(".concat(JSON.stringify(variables), ") for query ").concat(((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || JSON.stringify(queryDef), ", which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?"));
|
|
@@ -4075,7 +4088,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4075
4088
|
};
|
|
4076
4089
|
ObservableQuery.prototype.fetchMore = function (fetchMoreOptions) {
|
|
4077
4090
|
var _this = this;
|
|
4078
|
-
var combinedOptions = tslib.__assign(tslib.__assign({}, (fetchMoreOptions.query ? fetchMoreOptions : tslib.__assign(tslib.__assign(tslib.__assign({}, this.options), fetchMoreOptions), { variables: tslib.__assign(tslib.__assign({}, this.options.variables), fetchMoreOptions.variables) }))), { fetchPolicy: "no-cache" });
|
|
4091
|
+
var combinedOptions = tslib.__assign(tslib.__assign({}, (fetchMoreOptions.query ? fetchMoreOptions : tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign({}, this.options), { query: this.query }), fetchMoreOptions), { variables: tslib.__assign(tslib.__assign({}, this.options.variables), fetchMoreOptions.variables) }))), { fetchPolicy: "no-cache" });
|
|
4079
4092
|
var qid = this.queryManager.generateQueryId();
|
|
4080
4093
|
var queryInfo = this.queryInfo;
|
|
4081
4094
|
var originalNetworkStatus = queryInfo.networkStatus;
|
|
@@ -4094,7 +4107,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4094
4107
|
var updateQuery = fetchMoreOptions.updateQuery;
|
|
4095
4108
|
if (updateQuery) {
|
|
4096
4109
|
cache.updateQuery({
|
|
4097
|
-
query: _this.
|
|
4110
|
+
query: _this.query,
|
|
4098
4111
|
variables: _this.variables,
|
|
4099
4112
|
returnPartialData: true,
|
|
4100
4113
|
optimistic: false,
|
|
@@ -4117,7 +4130,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4117
4130
|
});
|
|
4118
4131
|
return fetchMoreResult;
|
|
4119
4132
|
}).finally(function () {
|
|
4120
|
-
if (!updatedQuerySet.has(_this.
|
|
4133
|
+
if (!updatedQuerySet.has(_this.query)) {
|
|
4121
4134
|
reobserveCacheFirst(_this);
|
|
4122
4135
|
}
|
|
4123
4136
|
});
|
|
@@ -5236,9 +5249,9 @@ var QueryManager = (function () {
|
|
|
5236
5249
|
});
|
|
5237
5250
|
this.queries.set(observable.queryId, queryInfo);
|
|
5238
5251
|
queryInfo.init({
|
|
5239
|
-
document:
|
|
5252
|
+
document: observable.query,
|
|
5240
5253
|
observableQuery: observable,
|
|
5241
|
-
variables:
|
|
5254
|
+
variables: observable.variables,
|
|
5242
5255
|
});
|
|
5243
5256
|
return observable;
|
|
5244
5257
|
};
|
|
@@ -5634,7 +5647,7 @@ var QueryManager = (function () {
|
|
|
5634
5647
|
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, fetchBlockingPromise = _a.fetchBlockingPromise;
|
|
5635
5648
|
var oldNetworkStatus = queryInfo.networkStatus;
|
|
5636
5649
|
queryInfo.init({
|
|
5637
|
-
document: query,
|
|
5650
|
+
document: this.transform(query).document,
|
|
5638
5651
|
variables: variables,
|
|
5639
5652
|
networkStatus: networkStatus,
|
|
5640
5653
|
});
|
|
@@ -5759,11 +5772,6 @@ var QueryManager = (function () {
|
|
|
5759
5772
|
}());
|
|
5760
5773
|
|
|
5761
5774
|
var hasSuggestedDevtools = false;
|
|
5762
|
-
function mergeOptions(defaults, options) {
|
|
5763
|
-
return compact(defaults, options, options.variables && {
|
|
5764
|
-
variables: tslib.__assign(tslib.__assign({}, defaults.variables), options.variables),
|
|
5765
|
-
});
|
|
5766
|
-
}
|
|
5767
5775
|
var ApolloClient = (function () {
|
|
5768
5776
|
function ApolloClient(options) {
|
|
5769
5777
|
var _this = this;
|
|
@@ -6232,8 +6240,6 @@ var InternalState = (function () {
|
|
|
6232
6240
|
}
|
|
6233
6241
|
}
|
|
6234
6242
|
useUnblockFetchEffect(this.renderPromises, resolveFetchBlockingPromise);
|
|
6235
|
-
this.ssrDisabled = !!(options.ssr === false ||
|
|
6236
|
-
options.skip);
|
|
6237
6243
|
this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;
|
|
6238
6244
|
this.onError = options.onError || InternalState.prototype.onError;
|
|
6239
6245
|
if ((this.renderPromises || this.client.disableNetworkFetches) &&
|
|
@@ -6318,7 +6324,9 @@ var InternalState = (function () {
|
|
|
6318
6324
|
}); }, [obsQuery]);
|
|
6319
6325
|
if (this.renderPromises) {
|
|
6320
6326
|
this.renderPromises.registerSSRObservable(obsQuery);
|
|
6321
|
-
|
|
6327
|
+
var ssrAllowed = !(this.queryHookOptions.ssr === false ||
|
|
6328
|
+
this.queryHookOptions.skip);
|
|
6329
|
+
if (ssrAllowed && obsQuery.getCurrentResult().loading) {
|
|
6322
6330
|
this.renderPromises.addObservableQueryPromise(obsQuery);
|
|
6323
6331
|
}
|
|
6324
6332
|
}
|
|
@@ -6535,9 +6543,12 @@ function useMutation(mutation, options) {
|
|
|
6535
6543
|
var reset = React.useCallback(function () {
|
|
6536
6544
|
setResult({ called: false, loading: false, client: client });
|
|
6537
6545
|
}, []);
|
|
6538
|
-
React.useEffect(function () {
|
|
6539
|
-
ref.current.isMounted =
|
|
6540
|
-
|
|
6546
|
+
React.useEffect(function () {
|
|
6547
|
+
ref.current.isMounted = true;
|
|
6548
|
+
return function () {
|
|
6549
|
+
ref.current.isMounted = false;
|
|
6550
|
+
};
|
|
6551
|
+
}, []);
|
|
6541
6552
|
return [execute, tslib.__assign({ reset: reset }, result)];
|
|
6542
6553
|
}
|
|
6543
6554
|
|