@apollo/client 3.13.8 → 3.14.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/.changeset/chilled-cameras-scream.md +5 -0
- package/.changeset/great-suns-cover.md +5 -0
- package/.changeset/perfect-donuts-roll.md +5 -0
- package/.changeset/popular-waves-drop.md +5 -0
- package/.changeset/pre.json +16 -0
- package/.changeset/shy-dragons-tease.md +5 -0
- package/.changeset/smooth-countries-cough.md +5 -0
- package/.changeset/spotty-walls-repair.md +5 -0
- package/CHANGELOG.md +20 -0
- package/README.md +80 -31
- package/apollo-client.cjs +354 -132
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +78 -21
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +78 -21
- package/cache/core/cache.js +27 -4
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +4 -4
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +2 -2
- package/cache/inmemory/inMemoryCache.js +15 -4
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.js +18 -13
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +7 -0
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +14 -3
- package/cache/inmemory/types.js.map +1 -1
- package/core/ApolloClient.d.ts +191 -2
- package/core/ApolloClient.js +93 -7
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.js +10 -6
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js +8 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +15 -12
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +93 -30
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +93 -30
- package/core/watchQueryOptions.d.ts +2 -2
- package/dev/dev.cjs +144 -84
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +144 -84
- package/invariantErrorCodes.js +158 -83
- package/link/core/ApolloLink.js +2 -2
- package/link/core/core.cjs +2 -2
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -2
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/http.cjs +3 -3
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +3 -3
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/persisted-queries.cjs +2 -2
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
- package/link/utils/toPromise.js +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/masking.cjs +6 -6
- package/masking/masking.cjs.map +1 -1
- package/masking/masking.cjs.native.js +6 -6
- package/masking/utils.js +1 -1
- package/package.json +1 -1
- package/react/components/Mutation.js +5 -0
- package/react/components/Mutation.js.map +1 -1
- package/react/components/Query.js +5 -0
- package/react/components/Query.js.map +1 -1
- package/react/components/Subscription.js +5 -0
- package/react/components/Subscription.js.map +1 -1
- package/react/components/components.cjs +34 -0
- package/react/components/components.cjs.map +1 -1
- package/react/components/components.cjs.native.js +34 -0
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +7 -2
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +9 -4
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +9 -4
- package/react/hoc/graphql.js +17 -4
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +55 -9
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +55 -9
- package/react/hoc/mutation-hoc.js +8 -1
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.js +8 -1
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.js +8 -1
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +264 -31
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +264 -31
- package/react/hooks/internal/index.d.ts +2 -0
- package/react/hooks/internal/index.js +2 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useWarnRemoved.d.ts +2 -0
- package/react/hooks/internal/useWarnRemoved.js +14 -0
- package/react/hooks/internal/useWarnRemoved.js.map +1 -0
- package/react/hooks/internal/useWarnRemovedOption.d.ts +2 -0
- package/react/hooks/internal/useWarnRemovedOption.js +14 -0
- package/react/hooks/internal/useWarnRemovedOption.js.map +1 -0
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useBackgroundQuery.js +11 -3
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.js +30 -21
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +65 -0
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.js +12 -5
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.js +5 -1
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +2 -2
- package/react/hooks/useQuery.js +25 -7
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +3 -3
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +12 -6
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.d.ts +16 -0
- package/react/internal/cache/QueryReference.js +1 -1
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/internal.cjs +2 -2
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +2 -2
- package/react/parser/index.d.ts +7 -0
- package/react/parser/index.js +17 -7
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +28 -7
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +28 -7
- package/react/query-preloader/createQueryPreloader.d.ts +2 -1
- package/react/query-preloader/createQueryPreloader.js +14 -5
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/react.cjs +40 -6
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +40 -6
- package/react/types/types.d.ts +303 -9
- package/react/types/types.documentation.d.ts +2 -3
- package/react/types/types.documentation.js.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +2 -2
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +2 -2
- package/testing/core/mocking/mockLink.js +2 -2
- package/testing/react/MockedProvider.d.ts +27 -1
- package/testing/react/MockedProvider.js +16 -10
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +42 -11
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +42 -11
- package/utilities/deprecation/index.d.ts +11 -0
- package/utilities/deprecation/index.js +28 -0
- package/utilities/deprecation/index.js.map +1 -0
- 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/graphql/DocumentTransform.js +1 -1
- package/utilities/graphql/directives.js +7 -7
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/transform.js +2 -2
- package/utilities/utilities.cjs +22 -22
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +22 -22
- package/version.js +1 -1
package/core/core.cjs.native.js
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.
|
|
25
|
+
var version = "3.14.0-alpha.0";
|
|
26
26
|
|
|
27
27
|
function isNonNullObject(obj) {
|
|
28
28
|
return obj !== null && typeof obj === "object";
|
|
@@ -195,6 +195,31 @@ function directiveIsNonreactive(dir) {
|
|
|
195
195
|
return dir.name.value === "nonreactive";
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
var slot = new optimism.Slot();
|
|
199
|
+
function isMuted(name) {
|
|
200
|
+
return (slot.getValue() || []).includes(name);
|
|
201
|
+
}
|
|
202
|
+
function muteDeprecations(name) {
|
|
203
|
+
var args = [];
|
|
204
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
205
|
+
args[_i - 1] = arguments[_i];
|
|
206
|
+
}
|
|
207
|
+
return slot.withValue.apply(slot, tslib.__spreadArray([Array.isArray(name) ? name : [name]], args, false));
|
|
208
|
+
}
|
|
209
|
+
function warnRemovedOption(options, name, callSite, recommendation) {
|
|
210
|
+
if (recommendation === void 0) { recommendation = "Please remove this option."; }
|
|
211
|
+
warnDeprecated(name, function () {
|
|
212
|
+
if (name in options) {
|
|
213
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(91, callSite, name, recommendation);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function warnDeprecated(name, cb) {
|
|
218
|
+
if (!isMuted(name)) {
|
|
219
|
+
cb();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
198
223
|
var assign = Object.assign, hasOwnProperty$1 = Object.hasOwnProperty;
|
|
199
224
|
var ObservableQuery = (function (_super) {
|
|
200
225
|
tslib.__extends(ObservableQuery, _super);
|
|
@@ -395,7 +420,7 @@ var ObservableQuery = (function (_super) {
|
|
|
395
420
|
var vars = queryDef.variableDefinitions;
|
|
396
421
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
397
422
|
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
398
|
-
|
|
423
|
+
22,
|
|
399
424
|
variables,
|
|
400
425
|
((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
|
|
401
426
|
);
|
|
@@ -427,7 +452,7 @@ var ObservableQuery = (function (_super) {
|
|
|
427
452
|
var updateQuery = fetchMoreOptions === null || fetchMoreOptions === void 0 ? void 0 : fetchMoreOptions.updateQuery;
|
|
428
453
|
var isCached = this.options.fetchPolicy !== "no-cache";
|
|
429
454
|
if (!isCached) {
|
|
430
|
-
globals.invariant(updateQuery,
|
|
455
|
+
globals.invariant(updateQuery, 23);
|
|
431
456
|
}
|
|
432
457
|
return this.queryManager
|
|
433
458
|
.fetchQuery(qid, combinedOptions, exports.NetworkStatus.fetchMore)
|
|
@@ -504,7 +529,7 @@ var ObservableQuery = (function (_super) {
|
|
|
504
529
|
options.onError(err);
|
|
505
530
|
return;
|
|
506
531
|
}
|
|
507
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
532
|
+
globalThis.__DEV__ !== false && globals.invariant.error(24, err);
|
|
508
533
|
},
|
|
509
534
|
});
|
|
510
535
|
this.subscriptions.add(subscription);
|
|
@@ -515,6 +540,9 @@ var ObservableQuery = (function (_super) {
|
|
|
515
540
|
};
|
|
516
541
|
};
|
|
517
542
|
ObservableQuery.prototype.setOptions = function (newOptions) {
|
|
543
|
+
if (globalThis.__DEV__ !== false) {
|
|
544
|
+
warnRemovedOption(newOptions, "canonizeResults", "setOptions");
|
|
545
|
+
}
|
|
518
546
|
return this.reobserve(newOptions);
|
|
519
547
|
};
|
|
520
548
|
ObservableQuery.prototype.silentSetOptions = function (newOptions) {
|
|
@@ -607,7 +635,7 @@ var ObservableQuery = (function (_super) {
|
|
|
607
635
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
608
636
|
return;
|
|
609
637
|
}
|
|
610
|
-
globals.invariant(pollInterval,
|
|
638
|
+
globals.invariant(pollInterval, 25);
|
|
611
639
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
612
640
|
info.interval = pollInterval;
|
|
613
641
|
var maybeFetch = function () {
|
|
@@ -828,11 +856,11 @@ var ObservableQuery = (function (_super) {
|
|
|
828
856
|
}(utilities.Observable));
|
|
829
857
|
utilities.fixObservableSubclass(ObservableQuery);
|
|
830
858
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
831
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
859
|
+
globalThis.__DEV__ !== false && globals.invariant.error(26, error.message, error.stack);
|
|
832
860
|
}
|
|
833
861
|
function logMissingFieldErrors(missing) {
|
|
834
862
|
if (globalThis.__DEV__ !== false && missing) {
|
|
835
|
-
globalThis.__DEV__ !== false && globals.invariant.debug(
|
|
863
|
+
globalThis.__DEV__ !== false && globals.invariant.debug(27, missing);
|
|
836
864
|
}
|
|
837
865
|
}
|
|
838
866
|
function skipCacheDataFor(fetchPolicy ) {
|
|
@@ -898,6 +926,7 @@ var QueryInfo = (function () {
|
|
|
898
926
|
this.lastDiff = void 0;
|
|
899
927
|
};
|
|
900
928
|
QueryInfo.prototype.getDiff = function () {
|
|
929
|
+
var _this = this;
|
|
901
930
|
var options = this.getDiffOptions();
|
|
902
931
|
if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
|
|
903
932
|
return this.lastDiff.diff;
|
|
@@ -907,7 +936,9 @@ var QueryInfo = (function () {
|
|
|
907
936
|
if (oq && oq.options.fetchPolicy === "no-cache") {
|
|
908
937
|
return { complete: false };
|
|
909
938
|
}
|
|
910
|
-
var diff =
|
|
939
|
+
var diff = muteDeprecations("canonizeResults", function () {
|
|
940
|
+
return _this.cache.diff(options);
|
|
941
|
+
});
|
|
911
942
|
this.updateLastDiff(diff, options);
|
|
912
943
|
return diff;
|
|
913
944
|
};
|
|
@@ -1030,7 +1061,9 @@ var QueryInfo = (function () {
|
|
|
1030
1061
|
}
|
|
1031
1062
|
}
|
|
1032
1063
|
var diffOptions = _this.getDiffOptions(options.variables);
|
|
1033
|
-
var diff =
|
|
1064
|
+
var diff = muteDeprecations("canonizeResults", function () {
|
|
1065
|
+
return cache.diff(diffOptions);
|
|
1066
|
+
});
|
|
1034
1067
|
if (!_this.stopped && equal.equal(_this.variables, options.variables)) {
|
|
1035
1068
|
_this.updateWatch(options.variables);
|
|
1036
1069
|
}
|
|
@@ -1117,7 +1150,7 @@ var QueryManager = (function () {
|
|
|
1117
1150
|
this.queries.forEach(function (_info, queryId) {
|
|
1118
1151
|
_this.stopQueryNoBroadcast(queryId);
|
|
1119
1152
|
});
|
|
1120
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1153
|
+
this.cancelPendingFetches(globals.newInvariantError(28));
|
|
1121
1154
|
};
|
|
1122
1155
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
1123
1156
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -1131,8 +1164,8 @@ var QueryManager = (function () {
|
|
|
1131
1164
|
return tslib.__generator(this, function (_j) {
|
|
1132
1165
|
switch (_j.label) {
|
|
1133
1166
|
case 0:
|
|
1134
|
-
globals.invariant(mutation,
|
|
1135
|
-
globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache",
|
|
1167
|
+
globals.invariant(mutation, 29);
|
|
1168
|
+
globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 30);
|
|
1136
1169
|
mutationId = this.generateMutationId();
|
|
1137
1170
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
1138
1171
|
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
@@ -1462,10 +1495,10 @@ var QueryManager = (function () {
|
|
|
1462
1495
|
QueryManager.prototype.query = function (options, queryId) {
|
|
1463
1496
|
var _this = this;
|
|
1464
1497
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
1465
|
-
globals.invariant(options.query,
|
|
1466
|
-
globals.invariant(options.query.kind === "Document",
|
|
1467
|
-
globals.invariant(!options.returnPartialData,
|
|
1468
|
-
globals.invariant(!options.pollInterval,
|
|
1498
|
+
globals.invariant(options.query, 31);
|
|
1499
|
+
globals.invariant(options.query.kind === "Document", 32);
|
|
1500
|
+
globals.invariant(!options.returnPartialData, 33);
|
|
1501
|
+
globals.invariant(!options.pollInterval, 34);
|
|
1469
1502
|
var query = this.transform(options.query);
|
|
1470
1503
|
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: query }))
|
|
1471
1504
|
.then(function (result) {
|
|
@@ -1500,7 +1533,7 @@ var QueryManager = (function () {
|
|
|
1500
1533
|
if (options === void 0) { options = {
|
|
1501
1534
|
discardWatches: true,
|
|
1502
1535
|
}; }
|
|
1503
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1536
|
+
this.cancelPendingFetches(globals.newInvariantError(35));
|
|
1504
1537
|
this.queries.forEach(function (queryInfo) {
|
|
1505
1538
|
if (queryInfo.observableQuery) {
|
|
1506
1539
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -1582,10 +1615,10 @@ var QueryManager = (function () {
|
|
|
1582
1615
|
if (!included) {
|
|
1583
1616
|
var queryName = queryNames.get(nameOrQueryString);
|
|
1584
1617
|
if (queryName) {
|
|
1585
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
1618
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(36, queryName);
|
|
1586
1619
|
}
|
|
1587
1620
|
else {
|
|
1588
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
1621
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(37);
|
|
1589
1622
|
}
|
|
1590
1623
|
}
|
|
1591
1624
|
});
|
|
@@ -1876,7 +1909,9 @@ var QueryManager = (function () {
|
|
|
1876
1909
|
var result;
|
|
1877
1910
|
if (onQueryUpdated) {
|
|
1878
1911
|
if (!diff) {
|
|
1879
|
-
diff =
|
|
1912
|
+
diff = muteDeprecations("canonizeResults", function () {
|
|
1913
|
+
return _this.cache.diff(oq["queryInfo"]["getDiffOptions"]());
|
|
1914
|
+
});
|
|
1880
1915
|
}
|
|
1881
1916
|
result = onQueryUpdated(oq, diff, lastDiff);
|
|
1882
1917
|
}
|
|
@@ -1909,7 +1944,7 @@ var QueryManager = (function () {
|
|
|
1909
1944
|
!this.noCacheWarningsByQueryId.has(operationId)) {
|
|
1910
1945
|
this.noCacheWarningsByQueryId.add(operationId);
|
|
1911
1946
|
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
1912
|
-
|
|
1947
|
+
38,
|
|
1913
1948
|
(_c = utilities.getOperationName(document)) !== null && _c !== void 0 ? _c : "Unnamed ".concat(operationType !== null && operationType !== void 0 ? operationType : "operation")
|
|
1914
1949
|
);
|
|
1915
1950
|
}
|
|
@@ -2224,7 +2259,7 @@ var LocalState = (function () {
|
|
|
2224
2259
|
}
|
|
2225
2260
|
else {
|
|
2226
2261
|
fragment = fragmentMap[selection.name.value];
|
|
2227
|
-
globals.invariant(fragment,
|
|
2262
|
+
globals.invariant(fragment, 20, selection.name.value);
|
|
2228
2263
|
}
|
|
2229
2264
|
if (fragment && fragment.typeCondition) {
|
|
2230
2265
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -2338,7 +2373,7 @@ var LocalState = (function () {
|
|
|
2338
2373
|
},
|
|
2339
2374
|
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
2340
2375
|
var fragment = fragmentMap[spread.name.value];
|
|
2341
|
-
globals.invariant(fragment,
|
|
2376
|
+
globals.invariant(fragment, 21, spread.name.value);
|
|
2342
2377
|
var fragmentSelections = collectByDefinition(fragment);
|
|
2343
2378
|
if (fragmentSelections.size > 0) {
|
|
2344
2379
|
ancestors.forEach(function (node) {
|
|
@@ -2437,14 +2472,26 @@ var hasSuggestedDevtools = false;
|
|
|
2437
2472
|
var ApolloClient = (function () {
|
|
2438
2473
|
function ApolloClient(options) {
|
|
2439
2474
|
var _this = this;
|
|
2440
|
-
var _a;
|
|
2475
|
+
var _a, _b, _c;
|
|
2441
2476
|
this.resetStoreCallbacks = [];
|
|
2442
2477
|
this.clearStoreCallbacks = [];
|
|
2443
2478
|
if (!options.cache) {
|
|
2444
2479
|
throw globals.newInvariantError(16);
|
|
2445
2480
|
}
|
|
2446
|
-
var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform,
|
|
2447
|
-
connectToDevTools = options.connectToDevTools,
|
|
2481
|
+
var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform, _d = options.ssrMode, ssrMode = _d === void 0 ? false : _d, _e = options.ssrForceFetchDelay, ssrForceFetchDelay = _e === void 0 ? 0 : _e,
|
|
2482
|
+
connectToDevTools = options.connectToDevTools, _f = options.queryDeduplication, queryDeduplication = _f === void 0 ? true : _f, defaultOptions = options.defaultOptions, defaultContext = options.defaultContext, _g = options.assumeImmutableResults, assumeImmutableResults = _g === void 0 ? cache.assumeImmutableResults : _g, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwareness = options.clientAwareness, clientAwarenessName = options.name, clientAwarenessVersion = options.version, devtools = options.devtools, dataMasking = options.dataMasking;
|
|
2483
|
+
if (globalThis.__DEV__ !== false) {
|
|
2484
|
+
warnRemovedOption(options, "connectToDevTools", "ApolloClient", "Please use `devtools.enabled` instead.");
|
|
2485
|
+
warnRemovedOption(options, "uri", "ApolloClient", "Please initialize an instance of `HttpLink` with `uri` instead.");
|
|
2486
|
+
warnRemovedOption(options, "credentials", "ApolloClient", "Please initialize an instance of `HttpLink` with `credentials` instead.");
|
|
2487
|
+
warnRemovedOption(options, "headers", "ApolloClient", "Please initialize an instance of `HttpLink` with `headers` instead.");
|
|
2488
|
+
warnRemovedOption(options, "name", "ApolloClient", "Please use the `clientAwareness.name` option instead.");
|
|
2489
|
+
warnRemovedOption(options, "version", "ApolloClient", "Please use the `clientAwareness.version` option instead.");
|
|
2490
|
+
warnRemovedOption(options, "typeDefs", "ApolloClient");
|
|
2491
|
+
if (!options.link) {
|
|
2492
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(17);
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2448
2495
|
var link = options.link;
|
|
2449
2496
|
if (!link) {
|
|
2450
2497
|
link =
|
|
@@ -2486,8 +2533,8 @@ var ApolloClient = (function () {
|
|
|
2486
2533
|
ssrMode: ssrMode,
|
|
2487
2534
|
dataMasking: !!dataMasking,
|
|
2488
2535
|
clientAwareness: {
|
|
2489
|
-
name: clientAwarenessName,
|
|
2490
|
-
version: clientAwarenessVersion,
|
|
2536
|
+
name: (_b = clientAwareness === null || clientAwareness === void 0 ? void 0 : clientAwareness.name) !== null && _b !== void 0 ? _b : clientAwarenessName,
|
|
2537
|
+
version: (_c = clientAwareness === null || clientAwareness === void 0 ? void 0 : clientAwareness.version) !== null && _c !== void 0 ? _c : clientAwarenessVersion,
|
|
2491
2538
|
},
|
|
2492
2539
|
localState: this.localState,
|
|
2493
2540
|
assumeImmutableResults: assumeImmutableResults,
|
|
@@ -2509,6 +2556,16 @@ var ApolloClient = (function () {
|
|
|
2509
2556
|
if (this.devtoolsConfig.enabled)
|
|
2510
2557
|
this.connectToDevTools();
|
|
2511
2558
|
}
|
|
2559
|
+
Object.defineProperty(ApolloClient.prototype, "prioritizeCacheValues", {
|
|
2560
|
+
get: function () {
|
|
2561
|
+
return this.disableNetworkFetches;
|
|
2562
|
+
},
|
|
2563
|
+
set: function (value) {
|
|
2564
|
+
this.disableNetworkFetches = value;
|
|
2565
|
+
},
|
|
2566
|
+
enumerable: false,
|
|
2567
|
+
configurable: true
|
|
2568
|
+
});
|
|
2512
2569
|
ApolloClient.prototype.connectToDevTools = function () {
|
|
2513
2570
|
if (typeof window === "undefined") {
|
|
2514
2571
|
return;
|
|
@@ -2567,16 +2624,22 @@ var ApolloClient = (function () {
|
|
|
2567
2624
|
options.fetchPolicy === "cache-and-network")) {
|
|
2568
2625
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "cache-first" });
|
|
2569
2626
|
}
|
|
2627
|
+
if (globalThis.__DEV__ !== false) {
|
|
2628
|
+
warnRemovedOption(options, "canonizeResults", "client.watchQuery");
|
|
2629
|
+
}
|
|
2570
2630
|
return this.queryManager.watchQuery(options);
|
|
2571
2631
|
};
|
|
2572
2632
|
ApolloClient.prototype.query = function (options) {
|
|
2573
2633
|
if (this.defaultOptions.query) {
|
|
2574
2634
|
options = utilities.mergeOptions(this.defaultOptions.query, options);
|
|
2575
2635
|
}
|
|
2576
|
-
globals.invariant(options.fetchPolicy !== "cache-and-network",
|
|
2636
|
+
globals.invariant(options.fetchPolicy !== "cache-and-network", 18);
|
|
2577
2637
|
if (this.disableNetworkFetches && options.fetchPolicy === "network-only") {
|
|
2578
2638
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "cache-first" });
|
|
2579
2639
|
}
|
|
2640
|
+
if (globalThis.__DEV__ !== false) {
|
|
2641
|
+
warnRemovedOption(options, "canonizeResults", "client.query");
|
|
2642
|
+
}
|
|
2580
2643
|
return this.queryManager.query(options);
|
|
2581
2644
|
};
|
|
2582
2645
|
ApolloClient.prototype.mutate = function (options) {
|
|
@@ -2679,7 +2742,7 @@ var ApolloClient = (function () {
|
|
|
2679
2742
|
result.queries = queries;
|
|
2680
2743
|
result.results = results;
|
|
2681
2744
|
result.catch(function (error) {
|
|
2682
|
-
globalThis.__DEV__ !== false && globals.invariant.debug(
|
|
2745
|
+
globalThis.__DEV__ !== false && globals.invariant.debug(19, error);
|
|
2683
2746
|
});
|
|
2684
2747
|
return result;
|
|
2685
2748
|
};
|
|
@@ -126,7 +126,7 @@ export interface QueryOptions<TVariables = OperationVariables, TData = any> {
|
|
|
126
126
|
*
|
|
127
127
|
* @deprecated
|
|
128
128
|
*
|
|
129
|
-
* Using `canonizeResults` can result in memory leaks so we generally do not recommend using this option
|
|
129
|
+
* Using `canonizeResults` can result in memory leaks so we generally do not recommend using this option. `canonizeResults` will be removed in Apollo Client 4.0.
|
|
130
130
|
*/
|
|
131
131
|
canonizeResults?: boolean;
|
|
132
132
|
}
|
|
@@ -255,7 +255,7 @@ export interface SharedWatchQueryOptions<TVariables extends OperationVariables,
|
|
|
255
255
|
*
|
|
256
256
|
* @deprecated
|
|
257
257
|
*
|
|
258
|
-
* Using `canonizeResults` can result in memory leaks so we generally do not recommend using this option
|
|
258
|
+
* Using `canonizeResults` can result in memory leaks so we generally do not recommend using this option. `canonizeResults` will be removed in Apollo Client 4.0.
|
|
259
259
|
*/
|
|
260
260
|
canonizeResults?: boolean;
|
|
261
261
|
/**
|