@apollo/client 3.14.0-rc.0 → 3.14.1
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 +44 -0
- package/apollo-client.cjs +85 -77
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +14 -41
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +14 -41
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/inmemory/inMemoryCache.js +1 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/core/ApolloClient.js +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +1 -0
- package/core/ObservableQuery.js +10 -6
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js +1 -1
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +1 -1
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +38 -61
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +38 -61
- package/dev/dev.cjs +49 -53
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +49 -53
- package/invariantErrorCodes.js +48 -53
- package/link/core/ApolloLink.js +1 -1
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs +1 -15
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +1 -15
- package/package.json +1 -1
- package/react/components/components.cjs +2 -14
- package/react/components/components.cjs.map +1 -1
- package/react/components/components.cjs.native.js +2 -14
- package/react/hoc/graphql.js +1 -1
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc.cjs +12 -31
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +12 -31
- package/react/hoc/mutation-hoc.js +1 -1
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.js +1 -1
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.js +1 -1
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hooks/hooks.cjs +26 -52
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +26 -52
- package/react/hooks/internal/useWarnRemoved.d.ts +1 -1
- package/react/hooks/internal/useWarnRemoved.js +1 -1
- package/react/hooks/internal/useWarnRemoved.js.map +1 -1
- package/react/hooks/internal/useWarnRemovedOption.d.ts +2 -1
- package/react/hooks/internal/useWarnRemovedOption.js +7 -5
- package/react/hooks/internal/useWarnRemovedOption.js.map +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useBackgroundQuery.js +1 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.js +1 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +3 -3
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.js +3 -3
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQuery.js +3 -3
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +3 -3
- package/react/hooks/useSuspenseQuery.js +3 -3
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.js +2 -2
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/internal.cjs +3 -14
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +3 -14
- package/react/parser/index.js +7 -7
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +9 -29
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +9 -29
- package/react/query-preloader/createQueryPreloader.js +1 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/react.cjs +4 -31
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +4 -31
- package/testing/core/core.cjs +4 -4
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +4 -4
- package/testing/core/mocking/mockLink.d.ts +13 -0
- package/testing/core/mocking/mockLink.js +4 -4
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/internal/disposables/index.d.ts +1 -0
- package/testing/internal/disposables/index.js +1 -0
- package/testing/internal/disposables/index.js.map +1 -1
- package/testing/internal/disposables/withMutedDeprecations.d.ts +4 -0
- package/testing/internal/disposables/withMutedDeprecations.js +13 -0
- package/testing/internal/disposables/withMutedDeprecations.js.map +1 -0
- package/testing/react/MockedProvider.js +1 -1
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +5 -32
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +5 -32
- package/utilities/deprecation/index.d.ts +0 -3
- package/utilities/deprecation/index.js +4 -12
- package/utilities/deprecation/index.js.map +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/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/index.d.ts +2 -0
- package/utilities/index.js +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/utilities.cjs +54 -22
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +54 -22
- package/version.js +1 -1
- package/.changeset/breezy-lions-rule.md +0 -5
- package/.changeset/chilled-cameras-scream.md +0 -5
- package/.changeset/great-jobs-fetch.md +0 -5
- package/.changeset/great-suns-cover.md +0 -5
- package/.changeset/perfect-donuts-roll.md +0 -5
- package/.changeset/popular-waves-drop.md +0 -5
- package/.changeset/pre.json +0 -20
- package/.changeset/shy-boxes-exercise.md +0 -5
- package/.changeset/shy-dragons-tease.md +0 -5
- package/.changeset/smooth-countries-cough.md +0 -5
- package/.changeset/spotty-walls-repair.md +0 -5
- package/.changeset/tidy-bulldogs-exercise.md +0 -5
package/react/hooks/hooks.cjs
CHANGED
|
@@ -11,7 +11,6 @@ var equal = require('@wry/equality');
|
|
|
11
11
|
var errors = require('../../errors');
|
|
12
12
|
var core = require('../../core');
|
|
13
13
|
var parser = require('../parser');
|
|
14
|
-
var optimism = require('optimism');
|
|
15
14
|
var tsInvariant = require('ts-invariant');
|
|
16
15
|
var internal = require('../internal');
|
|
17
16
|
var cache = require('../../cache');
|
|
@@ -36,7 +35,7 @@ var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
|
36
35
|
function useApolloClient(override) {
|
|
37
36
|
var context$1 = React__namespace.useContext(context.getApolloContext());
|
|
38
37
|
var client = override || context$1.client;
|
|
39
|
-
globals.invariant(!!client,
|
|
38
|
+
globals.invariant(!!client, 78);
|
|
40
39
|
return client;
|
|
41
40
|
}
|
|
42
41
|
|
|
@@ -51,7 +50,7 @@ var useSyncExternalStore = realHook$1 ||
|
|
|
51
50
|
!didWarnUncachedGetSnapshot &&
|
|
52
51
|
value !== getSnapshot()) {
|
|
53
52
|
didWarnUncachedGetSnapshot = true;
|
|
54
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
53
|
+
globalThis.__DEV__ !== false && globals.invariant.error(91);
|
|
55
54
|
}
|
|
56
55
|
var _a = React__namespace.useState({
|
|
57
56
|
inst: { value: value, getSnapshot: getSnapshot },
|
|
@@ -122,40 +121,15 @@ function useRenderGuard() {
|
|
|
122
121
|
}, []);
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
var muteAllDeprecations = Symbol.for("apollo.deprecations");
|
|
126
|
-
var global$2 = globals.global;
|
|
127
|
-
var slot = new optimism.Slot();
|
|
128
|
-
function isMuted(name) {
|
|
129
|
-
return global$2[muteAllDeprecations] || (slot.getValue() || []).includes(name);
|
|
130
|
-
}
|
|
131
|
-
function muteDeprecations(name) {
|
|
132
|
-
var args = [];
|
|
133
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
134
|
-
args[_i - 1] = arguments[_i];
|
|
135
|
-
}
|
|
136
|
-
return slot.withValue.apply(slot, tslib.__spreadArray([Array.isArray(name) ? name : [name]], args, false));
|
|
137
|
-
}
|
|
138
|
-
function warnRemovedOption(options, name, callSite, recommendation) {
|
|
139
|
-
if (recommendation === void 0) { recommendation = "Please remove this option."; }
|
|
140
|
-
warnDeprecated(name, function () {
|
|
141
|
-
if (name in options) {
|
|
142
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(104, callSite, name, recommendation);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
function warnDeprecated(name, cb) {
|
|
147
|
-
if (!isMuted(name)) {
|
|
148
|
-
cb();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
124
|
function useWarnRemovedOption(options, name, callSite, recommendation) {
|
|
153
125
|
"use no memo";
|
|
154
126
|
if (recommendation === void 0) { recommendation = "Please remove this option."; }
|
|
155
127
|
var didWarn = React__namespace.useRef(false);
|
|
156
|
-
if (
|
|
157
|
-
|
|
158
|
-
|
|
128
|
+
if (globalThis.__DEV__ !== false) {
|
|
129
|
+
if (name in options && !didWarn.current) {
|
|
130
|
+
utilities.warnRemovedOption(options, name, callSite, recommendation);
|
|
131
|
+
didWarn.current = true;
|
|
132
|
+
}
|
|
159
133
|
}
|
|
160
134
|
}
|
|
161
135
|
|
|
@@ -211,7 +185,7 @@ function useInternalState(client, query, options, renderPromises, makeWatchQuery
|
|
|
211
185
|
(renderPromises &&
|
|
212
186
|
renderPromises.getSSRObservable(makeWatchQueryOptions())) ||
|
|
213
187
|
core.ObservableQuery["inactiveOnCreation"].withValue(!renderPromises, function () {
|
|
214
|
-
return muteDeprecations("canonizeResults", function () {
|
|
188
|
+
return utilities.muteDeprecations(["canonizeResults", "partialRefetch"], function () {
|
|
215
189
|
return client.watchQuery(getObsQueryOptions(void 0, client, options, makeWatchQueryOptions()));
|
|
216
190
|
});
|
|
217
191
|
}),
|
|
@@ -486,7 +460,7 @@ function bindObservableMethods(observable) {
|
|
|
486
460
|
args[_i] = arguments[_i];
|
|
487
461
|
}
|
|
488
462
|
if (globalThis.__DEV__ !== false) {
|
|
489
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
463
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(83);
|
|
490
464
|
}
|
|
491
465
|
return observable.reobserve.apply(observable, args);
|
|
492
466
|
},
|
|
@@ -498,7 +472,7 @@ function bindObservableMethods(observable) {
|
|
|
498
472
|
};
|
|
499
473
|
}
|
|
500
474
|
|
|
501
|
-
var version = "3.14.
|
|
475
|
+
var version = "3.14.1";
|
|
502
476
|
|
|
503
477
|
function maybe(thunk) {
|
|
504
478
|
try {
|
|
@@ -655,7 +629,7 @@ function useLazyQuery(query, options) {
|
|
|
655
629
|
eagerMethods[key] = function () {
|
|
656
630
|
if (globalThis.__DEV__ !== false) {
|
|
657
631
|
if (key === "reobserve") {
|
|
658
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
632
|
+
globalThis.__DEV__ !== false && invariant.warn(79);
|
|
659
633
|
}
|
|
660
634
|
}
|
|
661
635
|
if (!execOptionsRef.current) {
|
|
@@ -678,19 +652,19 @@ function useLazyQuery(query, options) {
|
|
|
678
652
|
var execute = React__namespace.useCallback(function (executeOptions) {
|
|
679
653
|
if (globalThis.__DEV__ !== false) {
|
|
680
654
|
if (calledDuringRender()) {
|
|
681
|
-
globalThis.__DEV__ !== false && invariant.warn(
|
|
655
|
+
globalThis.__DEV__ !== false && invariant.warn(80);
|
|
682
656
|
}
|
|
683
657
|
for (var _i = 0, REMOVED_EXECUTE_OPTIONS_1 = REMOVED_EXECUTE_OPTIONS; _i < REMOVED_EXECUTE_OPTIONS_1.length; _i++) {
|
|
684
658
|
var name_1 = REMOVED_EXECUTE_OPTIONS_1[_i];
|
|
685
659
|
if (!warnRef.current.has(name_1)) {
|
|
686
|
-
warnRemovedOption(executeOptions || {}, name_1, "useLazyQuery.execute");
|
|
660
|
+
utilities.warnRemovedOption(executeOptions || {}, name_1, "useLazyQuery.execute");
|
|
687
661
|
warnRef.current.add(name_1);
|
|
688
662
|
}
|
|
689
663
|
}
|
|
690
664
|
for (var _a = 0, DEPRECATED_EXECUTE_OPTIONS_1 = DEPRECATED_EXECUTE_OPTIONS; _a < DEPRECATED_EXECUTE_OPTIONS_1.length; _a++) {
|
|
691
665
|
var name_2 = DEPRECATED_EXECUTE_OPTIONS_1[_a];
|
|
692
666
|
if (!warnRef.current.has(name_2)) {
|
|
693
|
-
warnRemovedOption(executeOptions || {}, name_2, "useLazyQuery.execute", "Please pass the option to the `useLazyQuery` hook instead.");
|
|
667
|
+
utilities.warnRemovedOption(executeOptions || {}, name_2, "useLazyQuery.execute", "Please pass the option to the `useLazyQuery` hook instead.");
|
|
694
668
|
warnRef.current.add(name_2);
|
|
695
669
|
}
|
|
696
670
|
}
|
|
@@ -869,10 +843,10 @@ function useSubscription(subscription, options) {
|
|
|
869
843
|
if (!hasIssuedDeprecationWarningRef.current) {
|
|
870
844
|
hasIssuedDeprecationWarningRef.current = true;
|
|
871
845
|
if (options.onSubscriptionData) {
|
|
872
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(options.onData ?
|
|
846
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(options.onData ? 84 : 85);
|
|
873
847
|
}
|
|
874
848
|
if (options.onSubscriptionComplete) {
|
|
875
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(options.onComplete ?
|
|
849
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(options.onComplete ? 86 : 87);
|
|
876
850
|
}
|
|
877
851
|
}
|
|
878
852
|
var skip = options.skip, fetchPolicy = options.fetchPolicy, errorPolicy = options.errorPolicy, shouldResubscribe = options.shouldResubscribe, context = options.context, extensions = options.extensions, ignoreResults = options.ignoreResults;
|
|
@@ -993,7 +967,7 @@ function useSubscription(subscription, options) {
|
|
|
993
967
|
: fallbackResult;
|
|
994
968
|
}, function () { return fallbackResult; });
|
|
995
969
|
var restart = React__namespace.useCallback(function () {
|
|
996
|
-
globals.invariant(!optionsRef.current.skip,
|
|
970
|
+
globals.invariant(!optionsRef.current.skip, 88);
|
|
997
971
|
setObservable(recreateRef.current());
|
|
998
972
|
}, [optionsRef, recreateRef]);
|
|
999
973
|
return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, ret), { restart: restart })); }, [ret, restart]);
|
|
@@ -1064,7 +1038,7 @@ function useFragment_(options) {
|
|
|
1064
1038
|
};
|
|
1065
1039
|
}
|
|
1066
1040
|
var cache = client.cache;
|
|
1067
|
-
var diff = muteDeprecations("canonizeResults", function () {
|
|
1041
|
+
var diff = utilities.muteDeprecations("canonizeResults", function () {
|
|
1068
1042
|
return cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic }));
|
|
1069
1043
|
});
|
|
1070
1044
|
return {
|
|
@@ -1078,7 +1052,7 @@ function useFragment_(options) {
|
|
|
1078
1052
|
var getSnapshot = React__namespace.useCallback(function () { return diff.result; }, [diff]);
|
|
1079
1053
|
return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
1080
1054
|
var lastTimeout = 0;
|
|
1081
|
-
var subscription = muteDeprecations("canonizeResults", function () {
|
|
1055
|
+
var subscription = utilities.muteDeprecations("canonizeResults", function () {
|
|
1082
1056
|
return stableOptions.from === null ?
|
|
1083
1057
|
null
|
|
1084
1058
|
: client.watchFragment(stableOptions).subscribe({
|
|
@@ -1132,7 +1106,7 @@ function useSuspenseQuery_(query, options) {
|
|
|
1132
1106
|
query,
|
|
1133
1107
|
cache.canonicalStringify(variables)
|
|
1134
1108
|
], [].concat(queryKey), true);
|
|
1135
|
-
var queryRef = muteDeprecations("canonizeResults", function () {
|
|
1109
|
+
var queryRef = utilities.muteDeprecations("canonizeResults", function () {
|
|
1136
1110
|
return suspenseCache.getQueryRef(cacheKey, function () {
|
|
1137
1111
|
return client.watchQuery(watchQueryOptions);
|
|
1138
1112
|
});
|
|
@@ -1204,11 +1178,11 @@ function validateFetchPolicy(fetchPolicy) {
|
|
|
1204
1178
|
"no-cache",
|
|
1205
1179
|
"cache-and-network",
|
|
1206
1180
|
];
|
|
1207
|
-
globals.invariant(supportedFetchPolicies.includes(fetchPolicy),
|
|
1181
|
+
globals.invariant(supportedFetchPolicies.includes(fetchPolicy), 89, fetchPolicy);
|
|
1208
1182
|
}
|
|
1209
1183
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
1210
1184
|
if (fetchPolicy === "no-cache" && returnPartialData) {
|
|
1211
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
1185
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(90);
|
|
1212
1186
|
}
|
|
1213
1187
|
}
|
|
1214
1188
|
function toApolloError(result) {
|
|
@@ -1257,7 +1231,7 @@ function useBackgroundQuery_(query, options) {
|
|
|
1257
1231
|
query,
|
|
1258
1232
|
cache.canonicalStringify(variables)
|
|
1259
1233
|
], [].concat(queryKey), true);
|
|
1260
|
-
var queryRef = muteDeprecations("canonizeResults", function () {
|
|
1234
|
+
var queryRef = utilities.muteDeprecations("canonizeResults", function () {
|
|
1261
1235
|
return suspenseCache.getQueryRef(cacheKey, function () {
|
|
1262
1236
|
return client.watchQuery(watchQueryOptions);
|
|
1263
1237
|
});
|
|
@@ -1378,13 +1352,13 @@ function useLoadableQuery(query, options) {
|
|
|
1378
1352
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1379
1353
|
args[_i] = arguments[_i];
|
|
1380
1354
|
}
|
|
1381
|
-
globals.invariant(!calledDuringRender(),
|
|
1355
|
+
globals.invariant(!calledDuringRender(), 81);
|
|
1382
1356
|
var variables = args[0];
|
|
1383
1357
|
var cacheKey = tslib.__spreadArray([
|
|
1384
1358
|
query,
|
|
1385
1359
|
cache.canonicalStringify(variables)
|
|
1386
1360
|
], [].concat(queryKey), true);
|
|
1387
|
-
var queryRef = muteDeprecations("canonizeResults", function () {
|
|
1361
|
+
var queryRef = utilities.muteDeprecations("canonizeResults", function () {
|
|
1388
1362
|
return suspenseCache.getQueryRef(cacheKey, function () {
|
|
1389
1363
|
return client.watchQuery(tslib.__assign(tslib.__assign({}, watchQueryOptions), { variables: variables }));
|
|
1390
1364
|
});
|
|
@@ -1399,7 +1373,7 @@ function useLoadableQuery(query, options) {
|
|
|
1399
1373
|
client,
|
|
1400
1374
|
]);
|
|
1401
1375
|
var subscribeToMore = React__namespace.useCallback(function (options) {
|
|
1402
|
-
globals.invariant(internalQueryRef,
|
|
1376
|
+
globals.invariant(internalQueryRef, 82);
|
|
1403
1377
|
return internalQueryRef.observable.subscribeToMore(
|
|
1404
1378
|
options);
|
|
1405
1379
|
}, [internalQueryRef]);
|