@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/react/hooks/hooks.cjs
CHANGED
|
@@ -11,6 +11,8 @@ 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
|
+
var tsInvariant = require('ts-invariant');
|
|
14
16
|
var internal = require('../internal');
|
|
15
17
|
var cache = require('../../cache');
|
|
16
18
|
|
|
@@ -34,7 +36,7 @@ var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
|
34
36
|
function useApolloClient(override) {
|
|
35
37
|
var context$1 = React__namespace.useContext(context.getApolloContext());
|
|
36
38
|
var client = override || context$1.client;
|
|
37
|
-
globals.invariant(!!client,
|
|
39
|
+
globals.invariant(!!client, 68);
|
|
38
40
|
return client;
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -49,7 +51,7 @@ var useSyncExternalStore = realHook$1 ||
|
|
|
49
51
|
!didWarnUncachedGetSnapshot &&
|
|
50
52
|
value !== getSnapshot()) {
|
|
51
53
|
didWarnUncachedGetSnapshot = true;
|
|
52
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
54
|
+
globalThis.__DEV__ !== false && globals.invariant.error(81);
|
|
53
55
|
}
|
|
54
56
|
var _a = React__namespace.useState({
|
|
55
57
|
inst: { value: value, getSnapshot: getSnapshot },
|
|
@@ -120,6 +122,41 @@ function useRenderGuard() {
|
|
|
120
122
|
}, []);
|
|
121
123
|
}
|
|
122
124
|
|
|
125
|
+
var slot = new optimism.Slot();
|
|
126
|
+
function isMuted(name) {
|
|
127
|
+
return (slot.getValue() || []).includes(name);
|
|
128
|
+
}
|
|
129
|
+
function muteDeprecations(name) {
|
|
130
|
+
var args = [];
|
|
131
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
132
|
+
args[_i - 1] = arguments[_i];
|
|
133
|
+
}
|
|
134
|
+
return slot.withValue.apply(slot, tslib.__spreadArray([Array.isArray(name) ? name : [name]], args, false));
|
|
135
|
+
}
|
|
136
|
+
function warnRemovedOption(options, name, callSite, recommendation) {
|
|
137
|
+
if (recommendation === void 0) { recommendation = "Please remove this option."; }
|
|
138
|
+
warnDeprecated(name, function () {
|
|
139
|
+
if (name in options) {
|
|
140
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(91, callSite, name, recommendation);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function warnDeprecated(name, cb) {
|
|
145
|
+
if (!isMuted(name)) {
|
|
146
|
+
cb();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function useWarnRemovedOption(options, name, callSite, recommendation) {
|
|
151
|
+
"use no memo";
|
|
152
|
+
if (recommendation === void 0) { recommendation = "Please remove this option."; }
|
|
153
|
+
var didWarn = React__namespace.useRef(false);
|
|
154
|
+
if (name in options && !didWarn.current) {
|
|
155
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(67, callSite, name, recommendation);
|
|
156
|
+
didWarn.current = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
123
160
|
var useKey = "use";
|
|
124
161
|
var realHook = React__namespace[useKey];
|
|
125
162
|
var __use = realHook ||
|
|
@@ -148,10 +185,16 @@ function noop() { }
|
|
|
148
185
|
var lastWatchOptions = Symbol();
|
|
149
186
|
function useQuery(query, options) {
|
|
150
187
|
if (options === void 0) { options = Object.create(null); }
|
|
151
|
-
return wrapHook("useQuery",
|
|
152
|
-
useQuery_, useApolloClient(options && options.client))(query, options);
|
|
188
|
+
return wrapHook("useQuery", useQuery_, useApolloClient(options && options.client))(query, options);
|
|
153
189
|
}
|
|
154
190
|
function useQuery_(query, options) {
|
|
191
|
+
if (globalThis.__DEV__ !== false) {
|
|
192
|
+
useWarnRemovedOption(options, "canonizeResults", "useQuery");
|
|
193
|
+
useWarnRemovedOption(options, "partialRefetch", "useQuery");
|
|
194
|
+
useWarnRemovedOption(options, "defaultOptions", "useQuery", "Pass the options directly to the hook instead.");
|
|
195
|
+
useWarnRemovedOption(options, "onCompleted", "useQuery", "If your `onCompleted` callback sets local state, switch to use derived state using `data` returned from the hook instead. Use `useEffect` to perform side-effects as a result of updates to `data`.");
|
|
196
|
+
useWarnRemovedOption(options, "onError", "useQuery", "If your `onError` callback sets local state, switch to use derived state using `data`, `error` or `errors` returned from the hook instead. Use `useEffect` if you need to perform side-effects as a result of updates to `data`, `error` or `errors`.");
|
|
197
|
+
}
|
|
155
198
|
var _a = useQueryInternals(query, options), result = _a.result, obsQueryFields = _a.obsQueryFields;
|
|
156
199
|
return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, result), obsQueryFields)); }, [result, obsQueryFields]);
|
|
157
200
|
}
|
|
@@ -166,7 +209,9 @@ function useInternalState(client, query, options, renderPromises, makeWatchQuery
|
|
|
166
209
|
(renderPromises &&
|
|
167
210
|
renderPromises.getSSRObservable(makeWatchQueryOptions())) ||
|
|
168
211
|
core.ObservableQuery["inactiveOnCreation"].withValue(!renderPromises, function () {
|
|
169
|
-
return
|
|
212
|
+
return muteDeprecations("canonizeResults", function () {
|
|
213
|
+
return client.watchQuery(getObsQueryOptions(void 0, client, options, makeWatchQueryOptions()));
|
|
214
|
+
});
|
|
170
215
|
}),
|
|
171
216
|
resultData: {
|
|
172
217
|
previousData: (_a = previous === null || previous === void 0 ? void 0 : previous.resultData.current) === null || _a === void 0 ? void 0 : _a.data,
|
|
@@ -433,7 +478,16 @@ var skipStandbyResult = utilities.maybeDeepFreeze({
|
|
|
433
478
|
function bindObservableMethods(observable) {
|
|
434
479
|
return {
|
|
435
480
|
refetch: observable.refetch.bind(observable),
|
|
436
|
-
reobserve:
|
|
481
|
+
reobserve: function () {
|
|
482
|
+
var args = [];
|
|
483
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
484
|
+
args[_i] = arguments[_i];
|
|
485
|
+
}
|
|
486
|
+
if (globalThis.__DEV__ !== false) {
|
|
487
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(73);
|
|
488
|
+
}
|
|
489
|
+
return observable.reobserve.apply(observable, args);
|
|
490
|
+
},
|
|
437
491
|
fetchMore: observable.fetchMore.bind(observable),
|
|
438
492
|
updateQuery: observable.updateQuery.bind(observable),
|
|
439
493
|
startPolling: observable.startPolling.bind(observable),
|
|
@@ -442,6 +496,101 @@ function bindObservableMethods(observable) {
|
|
|
442
496
|
};
|
|
443
497
|
}
|
|
444
498
|
|
|
499
|
+
var version = "3.14.0-alpha.0";
|
|
500
|
+
|
|
501
|
+
function maybe(thunk) {
|
|
502
|
+
try {
|
|
503
|
+
return thunk();
|
|
504
|
+
}
|
|
505
|
+
catch (_a) { }
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
var global$1 = (maybe(function () { return globalThis; }) ||
|
|
509
|
+
maybe(function () { return window; }) ||
|
|
510
|
+
maybe(function () { return self; }) ||
|
|
511
|
+
maybe(function () { return global; }) ||
|
|
512
|
+
maybe(function () {
|
|
513
|
+
return maybe.constructor("return this")();
|
|
514
|
+
}));
|
|
515
|
+
|
|
516
|
+
var prefixCounts = new Map();
|
|
517
|
+
function makeUniqueId(prefix) {
|
|
518
|
+
var count = prefixCounts.get(prefix) || 1;
|
|
519
|
+
prefixCounts.set(prefix, count + 1);
|
|
520
|
+
return "".concat(prefix, ":").concat(count, ":").concat(Math.random().toString(36).slice(2));
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
function stringifyForDisplay(value, space) {
|
|
524
|
+
if (space === void 0) { space = 0; }
|
|
525
|
+
var undefId = makeUniqueId("stringifyForDisplay");
|
|
526
|
+
return JSON.stringify(value, function (key, value) {
|
|
527
|
+
return value === void 0 ? undefId : value;
|
|
528
|
+
}, space)
|
|
529
|
+
.split(JSON.stringify(undefId))
|
|
530
|
+
.join("<undefined>");
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function wrap(fn) {
|
|
534
|
+
return function (message) {
|
|
535
|
+
var args = [];
|
|
536
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
537
|
+
args[_i - 1] = arguments[_i];
|
|
538
|
+
}
|
|
539
|
+
if (typeof message === "number") {
|
|
540
|
+
var arg0 = message;
|
|
541
|
+
message = getHandledErrorMsg(arg0);
|
|
542
|
+
if (!message) {
|
|
543
|
+
message = getFallbackErrorMsg(arg0, args);
|
|
544
|
+
args = [];
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
fn.apply(void 0, [message].concat(args));
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
var invariant = Object.assign(function invariant(condition, message) {
|
|
551
|
+
var args = [];
|
|
552
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
553
|
+
args[_i - 2] = arguments[_i];
|
|
554
|
+
}
|
|
555
|
+
if (!condition) {
|
|
556
|
+
tsInvariant.invariant(condition, getHandledErrorMsg(message, args) || getFallbackErrorMsg(message, args));
|
|
557
|
+
}
|
|
558
|
+
}, {
|
|
559
|
+
debug: wrap(tsInvariant.invariant.debug),
|
|
560
|
+
log: wrap(tsInvariant.invariant.log),
|
|
561
|
+
warn: wrap(tsInvariant.invariant.warn),
|
|
562
|
+
error: wrap(tsInvariant.invariant.error),
|
|
563
|
+
});
|
|
564
|
+
var ApolloErrorMessageHandler = Symbol.for("ApolloErrorMessageHandler_" + version);
|
|
565
|
+
function stringify(arg) {
|
|
566
|
+
if (typeof arg == "string") {
|
|
567
|
+
return arg;
|
|
568
|
+
}
|
|
569
|
+
try {
|
|
570
|
+
return stringifyForDisplay(arg, 2).slice(0, 1000);
|
|
571
|
+
}
|
|
572
|
+
catch (_a) {
|
|
573
|
+
return "<non-serializable>";
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
function getHandledErrorMsg(message, messageArgs) {
|
|
577
|
+
if (messageArgs === void 0) { messageArgs = []; }
|
|
578
|
+
if (!message)
|
|
579
|
+
return;
|
|
580
|
+
return (global$1[ApolloErrorMessageHandler] &&
|
|
581
|
+
global$1[ApolloErrorMessageHandler](message, messageArgs.map(stringify)));
|
|
582
|
+
}
|
|
583
|
+
function getFallbackErrorMsg(message, messageArgs) {
|
|
584
|
+
if (messageArgs === void 0) { messageArgs = []; }
|
|
585
|
+
if (!message)
|
|
586
|
+
return;
|
|
587
|
+
return "An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({
|
|
588
|
+
version: version,
|
|
589
|
+
message: message,
|
|
590
|
+
args: messageArgs.map(stringify),
|
|
591
|
+
})));
|
|
592
|
+
}
|
|
593
|
+
|
|
445
594
|
var EAGER_METHODS = [
|
|
446
595
|
"refetch",
|
|
447
596
|
"reobserve",
|
|
@@ -451,8 +600,40 @@ var EAGER_METHODS = [
|
|
|
451
600
|
"stopPolling",
|
|
452
601
|
"subscribeToMore",
|
|
453
602
|
];
|
|
603
|
+
var REMOVED_EXECUTE_OPTIONS = [
|
|
604
|
+
"initialFetchPolicy",
|
|
605
|
+
"onCompleted",
|
|
606
|
+
"onError",
|
|
607
|
+
"defaultOptions",
|
|
608
|
+
"partialRefetch",
|
|
609
|
+
"canonizeResults",
|
|
610
|
+
];
|
|
611
|
+
var DEPRECATED_EXECUTE_OPTIONS = [
|
|
612
|
+
"query",
|
|
613
|
+
"ssr",
|
|
614
|
+
"client",
|
|
615
|
+
"fetchPolicy",
|
|
616
|
+
"nextFetchPolicy",
|
|
617
|
+
"refetchWritePolicy",
|
|
618
|
+
"errorPolicy",
|
|
619
|
+
"pollInterval",
|
|
620
|
+
"notifyOnNetworkStatusChange",
|
|
621
|
+
"returnPartialData",
|
|
622
|
+
"skipPollAttempt",
|
|
623
|
+
];
|
|
454
624
|
function useLazyQuery(query, options) {
|
|
455
625
|
var _a;
|
|
626
|
+
if (globalThis.__DEV__ !== false) {
|
|
627
|
+
var warnOpts = options || {};
|
|
628
|
+
useWarnRemovedOption(warnOpts, "canonizeResults", "useLazyQuery");
|
|
629
|
+
useWarnRemovedOption(warnOpts, "variables", "useLazyQuery", "Pass all `variables` to the returned `execute` function instead.");
|
|
630
|
+
useWarnRemovedOption(warnOpts, "context", "useLazyQuery", "Pass `context` to the returned `execute` function instead.");
|
|
631
|
+
useWarnRemovedOption(warnOpts, "onCompleted", "useLazyQuery", "If your `onCompleted` callback sets local state, switch to use derived state using `data` returned from the hook instead. Use `useEffect` to perform side-effects as a result of updates to `data`.");
|
|
632
|
+
useWarnRemovedOption(warnOpts, "onError", "useLazyQuery", "If your `onError` callback sets local state, switch to use derived state using `data`, `error` or `errors` returned from the hook instead. Use `useEffect` if you need to perform side-effects as a result of updates to `data`, `error` or `errors`.");
|
|
633
|
+
useWarnRemovedOption(warnOpts, "defaultOptions", "useLazyQuery", "Pass the options directly to the hook instead.");
|
|
634
|
+
useWarnRemovedOption(warnOpts, "initialFetchPolicy", "useLazyQuery", "Use the `fetchPolicy` option instead.");
|
|
635
|
+
useWarnRemovedOption(warnOpts, "partialRefetch", "useLazyQuery");
|
|
636
|
+
}
|
|
456
637
|
var execOptionsRef = React__namespace.useRef(void 0);
|
|
457
638
|
var optionsRef = React__namespace.useRef(void 0);
|
|
458
639
|
var queryRef = React__namespace.useRef(void 0);
|
|
@@ -470,6 +651,11 @@ function useLazyQuery(query, options) {
|
|
|
470
651
|
var _loop_1 = function (key) {
|
|
471
652
|
var method = obsQueryFields[key];
|
|
472
653
|
eagerMethods[key] = function () {
|
|
654
|
+
if (globalThis.__DEV__ !== false) {
|
|
655
|
+
if (key === "reobserve") {
|
|
656
|
+
globalThis.__DEV__ !== false && invariant.warn(69);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
473
659
|
if (!execOptionsRef.current) {
|
|
474
660
|
execOptionsRef.current = Object.create(null);
|
|
475
661
|
forceUpdateState();
|
|
@@ -485,7 +671,28 @@ function useLazyQuery(query, options) {
|
|
|
485
671
|
}, [forceUpdateState, obsQueryFields]);
|
|
486
672
|
var called = !!execOptionsRef.current;
|
|
487
673
|
var result = React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign(tslib.__assign({}, useQueryResult), eagerMethods), { called: called })); }, [useQueryResult, eagerMethods, called]);
|
|
674
|
+
var calledDuringRender = useRenderGuard();
|
|
675
|
+
var warnRef = React__namespace.useRef(new Set());
|
|
488
676
|
var execute = React__namespace.useCallback(function (executeOptions) {
|
|
677
|
+
if (globalThis.__DEV__ !== false) {
|
|
678
|
+
if (calledDuringRender()) {
|
|
679
|
+
globalThis.__DEV__ !== false && invariant.warn(70);
|
|
680
|
+
}
|
|
681
|
+
for (var _i = 0, REMOVED_EXECUTE_OPTIONS_1 = REMOVED_EXECUTE_OPTIONS; _i < REMOVED_EXECUTE_OPTIONS_1.length; _i++) {
|
|
682
|
+
var name_1 = REMOVED_EXECUTE_OPTIONS_1[_i];
|
|
683
|
+
if (!warnRef.current.has(name_1)) {
|
|
684
|
+
warnRemovedOption(executeOptions || {}, name_1, "useLazyQuery.execute");
|
|
685
|
+
warnRef.current.add(name_1);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
for (var _a = 0, DEPRECATED_EXECUTE_OPTIONS_1 = DEPRECATED_EXECUTE_OPTIONS; _a < DEPRECATED_EXECUTE_OPTIONS_1.length; _a++) {
|
|
689
|
+
var name_2 = DEPRECATED_EXECUTE_OPTIONS_1[_a];
|
|
690
|
+
if (!warnRef.current.has(name_2)) {
|
|
691
|
+
warnRemovedOption(executeOptions || {}, name_2, "useLazyQuery.execute", "Please pass the option to the `useLazyQuery` hook instead.");
|
|
692
|
+
warnRef.current.add(name_2);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
489
696
|
execOptionsRef.current =
|
|
490
697
|
executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
491
698
|
fetchPolicy: initialFetchPolicy,
|
|
@@ -495,6 +702,7 @@ function useLazyQuery(query, options) {
|
|
|
495
702
|
promise.catch(function () { });
|
|
496
703
|
return promise;
|
|
497
704
|
}, [
|
|
705
|
+
calledDuringRender,
|
|
498
706
|
client,
|
|
499
707
|
document,
|
|
500
708
|
eagerMethods,
|
|
@@ -538,6 +746,9 @@ function executeQuery(resultData, observable, client, currentQuery, options, onQ
|
|
|
538
746
|
}
|
|
539
747
|
|
|
540
748
|
function useMutation(mutation, options) {
|
|
749
|
+
if (globalThis.__DEV__ !== false) {
|
|
750
|
+
useWarnRemovedOption(options || {}, "ignoreResults", "useMutation", "If you don't want to synchronize component state with the mutation, please use the `useApolloClient` hook to get the client instance and call `client.mutate` directly.");
|
|
751
|
+
}
|
|
541
752
|
var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
|
|
542
753
|
parser.verifyDocumentType(mutation, parser.DocumentType.Mutation);
|
|
543
754
|
var _a = React__namespace.useState({
|
|
@@ -656,10 +867,10 @@ function useSubscription(subscription, options) {
|
|
|
656
867
|
if (!hasIssuedDeprecationWarningRef.current) {
|
|
657
868
|
hasIssuedDeprecationWarningRef.current = true;
|
|
658
869
|
if (options.onSubscriptionData) {
|
|
659
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(options.onData ?
|
|
870
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(options.onData ? 74 : 75);
|
|
660
871
|
}
|
|
661
872
|
if (options.onSubscriptionComplete) {
|
|
662
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(options.onComplete ?
|
|
873
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(options.onComplete ? 76 : 77);
|
|
663
874
|
}
|
|
664
875
|
}
|
|
665
876
|
var skip = options.skip, fetchPolicy = options.fetchPolicy, errorPolicy = options.errorPolicy, shouldResubscribe = options.shouldResubscribe, context = options.context, extensions = options.extensions, ignoreResults = options.ignoreResults;
|
|
@@ -780,7 +991,7 @@ function useSubscription(subscription, options) {
|
|
|
780
991
|
: fallbackResult;
|
|
781
992
|
}, function () { return fallbackResult; });
|
|
782
993
|
var restart = React__namespace.useCallback(function () {
|
|
783
|
-
globals.invariant(!optionsRef.current.skip,
|
|
994
|
+
globals.invariant(!optionsRef.current.skip, 78);
|
|
784
995
|
setObservable(recreateRef.current());
|
|
785
996
|
}, [optionsRef, recreateRef]);
|
|
786
997
|
return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, ret), { restart: restart })); }, [ret, restart]);
|
|
@@ -828,6 +1039,9 @@ function useFragment(options) {
|
|
|
828
1039
|
useFragment_, useApolloClient(options.client))(options);
|
|
829
1040
|
}
|
|
830
1041
|
function useFragment_(options) {
|
|
1042
|
+
if (globalThis.__DEV__ !== false) {
|
|
1043
|
+
useWarnRemovedOption(options, "canonizeResults", "useFragment");
|
|
1044
|
+
}
|
|
831
1045
|
var client = useApolloClient(options.client);
|
|
832
1046
|
var cache = client.cache;
|
|
833
1047
|
var from = options.from, rest = tslib.__rest(options, ["from"]);
|
|
@@ -848,7 +1062,9 @@ function useFragment_(options) {
|
|
|
848
1062
|
};
|
|
849
1063
|
}
|
|
850
1064
|
var cache = client.cache;
|
|
851
|
-
var diff =
|
|
1065
|
+
var diff = muteDeprecations("canonizeResults", function () {
|
|
1066
|
+
return cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic }));
|
|
1067
|
+
});
|
|
852
1068
|
return {
|
|
853
1069
|
result: diffToResult(tslib.__assign(tslib.__assign({}, diff), { result: client["queryManager"].maskFragment({
|
|
854
1070
|
fragment: fragment,
|
|
@@ -860,17 +1076,19 @@ function useFragment_(options) {
|
|
|
860
1076
|
var getSnapshot = React__namespace.useCallback(function () { return diff.result; }, [diff]);
|
|
861
1077
|
return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
862
1078
|
var lastTimeout = 0;
|
|
863
|
-
var subscription =
|
|
864
|
-
null
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
1079
|
+
var subscription = muteDeprecations("canonizeResults", function () {
|
|
1080
|
+
return stableOptions.from === null ?
|
|
1081
|
+
null
|
|
1082
|
+
: client.watchFragment(stableOptions).subscribe({
|
|
1083
|
+
next: function (result) {
|
|
1084
|
+
if (equal__default(result, diff.result))
|
|
1085
|
+
return;
|
|
1086
|
+
diff.result = result;
|
|
1087
|
+
clearTimeout(lastTimeout);
|
|
1088
|
+
lastTimeout = setTimeout(forceUpdate);
|
|
1089
|
+
},
|
|
1090
|
+
});
|
|
1091
|
+
});
|
|
874
1092
|
return function () {
|
|
875
1093
|
subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
|
|
876
1094
|
clearTimeout(lastTimeout);
|
|
@@ -896,6 +1114,9 @@ function useSuspenseQuery(query, options) {
|
|
|
896
1114
|
useSuspenseQuery_, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
|
|
897
1115
|
}
|
|
898
1116
|
function useSuspenseQuery_(query, options) {
|
|
1117
|
+
if (globalThis.__DEV__ !== false) {
|
|
1118
|
+
useWarnRemovedOption(typeof options === "symbol" ? {} : options, "canonizeResults", "useSuspenseQuery");
|
|
1119
|
+
}
|
|
899
1120
|
var client = useApolloClient(options.client);
|
|
900
1121
|
var suspenseCache = internal.getSuspenseCache(client);
|
|
901
1122
|
var watchQueryOptions = useWatchQueryOptions({
|
|
@@ -909,8 +1130,10 @@ function useSuspenseQuery_(query, options) {
|
|
|
909
1130
|
query,
|
|
910
1131
|
cache.canonicalStringify(variables)
|
|
911
1132
|
], [].concat(queryKey), true);
|
|
912
|
-
var queryRef =
|
|
913
|
-
return
|
|
1133
|
+
var queryRef = muteDeprecations("canonizeResults", function () {
|
|
1134
|
+
return suspenseCache.getQueryRef(cacheKey, function () {
|
|
1135
|
+
return client.watchQuery(watchQueryOptions);
|
|
1136
|
+
});
|
|
914
1137
|
});
|
|
915
1138
|
var _b = React__namespace.useState([queryRef.key, queryRef.promise]), current = _b[0], setPromise = _b[1];
|
|
916
1139
|
if (current[0] !== queryRef.key) {
|
|
@@ -979,11 +1202,11 @@ function validateFetchPolicy(fetchPolicy) {
|
|
|
979
1202
|
"no-cache",
|
|
980
1203
|
"cache-and-network",
|
|
981
1204
|
];
|
|
982
|
-
globals.invariant(supportedFetchPolicies.includes(fetchPolicy),
|
|
1205
|
+
globals.invariant(supportedFetchPolicies.includes(fetchPolicy), 79, fetchPolicy);
|
|
983
1206
|
}
|
|
984
1207
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
985
1208
|
if (fetchPolicy === "no-cache" && returnPartialData) {
|
|
986
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
1209
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(80);
|
|
987
1210
|
}
|
|
988
1211
|
}
|
|
989
1212
|
function toApolloError(result) {
|
|
@@ -1018,6 +1241,9 @@ function useBackgroundQuery(query, options) {
|
|
|
1018
1241
|
useBackgroundQuery_, useApolloClient(typeof options === "object" ? options.client : undefined))(query, options);
|
|
1019
1242
|
}
|
|
1020
1243
|
function useBackgroundQuery_(query, options) {
|
|
1244
|
+
if (globalThis.__DEV__ !== false) {
|
|
1245
|
+
useWarnRemovedOption(typeof options === "symbol" ? {} : options, "canonizeResults", "useBackgroundQuery");
|
|
1246
|
+
}
|
|
1021
1247
|
var client = useApolloClient(options.client);
|
|
1022
1248
|
var suspenseCache = internal.getSuspenseCache(client);
|
|
1023
1249
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
@@ -1029,8 +1255,10 @@ function useBackgroundQuery_(query, options) {
|
|
|
1029
1255
|
query,
|
|
1030
1256
|
cache.canonicalStringify(variables)
|
|
1031
1257
|
], [].concat(queryKey), true);
|
|
1032
|
-
var queryRef =
|
|
1033
|
-
return
|
|
1258
|
+
var queryRef = muteDeprecations("canonizeResults", function () {
|
|
1259
|
+
return suspenseCache.getQueryRef(cacheKey, function () {
|
|
1260
|
+
return client.watchQuery(watchQueryOptions);
|
|
1261
|
+
});
|
|
1034
1262
|
});
|
|
1035
1263
|
var _b = React__namespace.useState(internal.wrapQueryRef(queryRef)), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
|
|
1036
1264
|
if (internal.unwrapQueryRef(wrappedQueryRef) !== queryRef) {
|
|
@@ -1112,6 +1340,9 @@ function useSuspenseFragment_(options) {
|
|
|
1112
1340
|
|
|
1113
1341
|
function useLoadableQuery(query, options) {
|
|
1114
1342
|
if (options === void 0) { options = Object.create(null); }
|
|
1343
|
+
if (globalThis.__DEV__ !== false) {
|
|
1344
|
+
useWarnRemovedOption(options, "canonizeResults", "useLoadableQuery");
|
|
1345
|
+
}
|
|
1115
1346
|
var client = useApolloClient(options.client);
|
|
1116
1347
|
var suspenseCache = internal.getSuspenseCache(client);
|
|
1117
1348
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
@@ -1145,14 +1376,16 @@ function useLoadableQuery(query, options) {
|
|
|
1145
1376
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1146
1377
|
args[_i] = arguments[_i];
|
|
1147
1378
|
}
|
|
1148
|
-
globals.invariant(!calledDuringRender(),
|
|
1379
|
+
globals.invariant(!calledDuringRender(), 71);
|
|
1149
1380
|
var variables = args[0];
|
|
1150
1381
|
var cacheKey = tslib.__spreadArray([
|
|
1151
1382
|
query,
|
|
1152
1383
|
cache.canonicalStringify(variables)
|
|
1153
1384
|
], [].concat(queryKey), true);
|
|
1154
|
-
var queryRef =
|
|
1155
|
-
return
|
|
1385
|
+
var queryRef = muteDeprecations("canonizeResults", function () {
|
|
1386
|
+
return suspenseCache.getQueryRef(cacheKey, function () {
|
|
1387
|
+
return client.watchQuery(tslib.__assign(tslib.__assign({}, watchQueryOptions), { variables: variables }));
|
|
1388
|
+
});
|
|
1156
1389
|
});
|
|
1157
1390
|
setQueryRef(internal.wrapQueryRef(queryRef));
|
|
1158
1391
|
}, [
|
|
@@ -1164,7 +1397,7 @@ function useLoadableQuery(query, options) {
|
|
|
1164
1397
|
client,
|
|
1165
1398
|
]);
|
|
1166
1399
|
var subscribeToMore = React__namespace.useCallback(function (options) {
|
|
1167
|
-
globals.invariant(internalQueryRef,
|
|
1400
|
+
globals.invariant(internalQueryRef, 72);
|
|
1168
1401
|
return internalQueryRef.observable.subscribeToMore(
|
|
1169
1402
|
options);
|
|
1170
1403
|
}, [internalQueryRef]);
|