@apollo/client 3.14.0-alpha.0 → 3.14.0-alpha.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/.changeset/breezy-lions-rule.md +5 -0
- package/.changeset/great-jobs-fetch.md +5 -0
- package/.changeset/pre.json +4 -1
- package/.changeset/tidy-bulldogs-exercise.md +5 -0
- package/CHANGELOG.md +10 -0
- package/apollo-client.cjs +187 -119
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +7 -2
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +7 -2
- package/cache/inmemory/inMemoryCache.d.ts +8 -0
- package/cache/inmemory/inMemoryCache.js +3 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/core/ApolloClient.d.ts +9 -9
- package/core/ApolloClient.js +6 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.d.ts +51 -6
- package/core/ObservableQuery.js +89 -13
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js +6 -3
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +14 -12
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +85 -33
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +85 -33
- package/core/types.d.ts +177 -3
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +10 -2
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +149 -97
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +149 -97
- package/errors/errors.cjs.map +1 -1
- package/errors/index.d.ts +19 -0
- package/errors/index.js +19 -0
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +161 -96
- package/link/batch-http/batch-http.cjs +9 -0
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +9 -0
- package/link/batch-http/batchHttpLink.js +9 -0
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/core/ApolloLink.d.ts +8 -0
- package/link/core/ApolloLink.js +19 -2
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs +24 -2
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +24 -2
- package/link/core/types.d.ts +20 -0
- package/link/core/types.js.map +1 -1
- package/link/error/index.d.ts +48 -0
- package/link/error/index.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +4 -1
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +6 -3
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +6 -3
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.d.ts +38 -0
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/index.js.map +1 -1
- 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/fromError.d.ts +16 -0
- package/link/utils/fromError.js +16 -0
- package/link/utils/fromError.js.map +1 -1
- package/link/utils/fromPromise.d.ts +16 -0
- package/link/utils/fromPromise.js +16 -0
- package/link/utils/fromPromise.js.map +1 -1
- package/link/utils/throwServerError.d.ts +30 -0
- package/link/utils/throwServerError.js +17 -0
- package/link/utils/throwServerError.js.map +1 -1
- package/link/utils/toPromise.d.ts +16 -0
- package/link/utils/toPromise.js +17 -1
- package/link/utils/toPromise.js.map +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/masking/utils.js.map +1 -1
- package/package.json +1 -1
- package/react/components/Mutation.js +1 -1
- package/react/components/Query.js +1 -1
- package/react/components/Subscription.js +1 -1
- package/react/components/components.cjs +6 -4
- package/react/components/components.cjs.map +1 -1
- package/react/components/components.cjs.native.js +6 -4
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +2 -2
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +4 -4
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +4 -4
- package/react/hoc/graphql.js +1 -1
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +9 -7
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +9 -7
- package/react/hoc/mutation-hoc.js +1 -1
- package/react/hoc/query-hoc.js +1 -1
- package/react/hoc/subscription-hoc.js +1 -1
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +18 -16
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +18 -16
- package/react/hooks/internal/useWarnRemoved.d.ts +2 -1
- package/react/hooks/internal/useWarnRemoved.js.map +1 -1
- package/react/hooks/internal/useWarnRemovedOption.js +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useLazyQuery.js +2 -2
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useQuery.js +1 -1
- package/react/hooks/useSubscription.js +3 -3
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.d.ts +1 -0
- package/react/internal/cache/QueryReference.js +5 -2
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/internal.cjs +16 -3
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +16 -3
- package/react/parser/index.js +6 -6
- package/react/parser/parser.cjs +9 -7
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +9 -7
- package/react/react.cjs +4 -2
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +4 -2
- package/react/types/types.d.ts +40 -0
- package/react/types/types.documentation.d.ts +1 -1
- package/react/types/types.documentation.js.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +17 -3
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +17 -3
- package/testing/core/itAsync.d.ts +5 -0
- package/testing/core/itAsync.js +5 -0
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockClient.d.ts +4 -0
- package/testing/core/mocking/mockClient.js +4 -0
- package/testing/core/mocking/mockClient.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +10 -0
- package/testing/core/mocking/mockLink.js +23 -4
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +4 -0
- package/testing/core/mocking/mockSubscriptionLink.js +4 -0
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/subscribeAndCount.d.ts +4 -0
- package/testing/core/subscribeAndCount.js +4 -0
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/testing/experimental/createSchemaFetch.d.ts +1 -1
- package/testing/experimental/createSchemaFetch.js +1 -1
- package/testing/experimental/createSchemaFetch.js.map +1 -1
- package/testing/experimental/createTestSchema.d.ts +1 -1
- package/testing/experimental/createTestSchema.js +1 -1
- package/testing/experimental/createTestSchema.js.map +1 -1
- package/testing/experimental/experimental.cjs.map +1 -1
- package/testing/testing.cjs +4 -2
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +4 -2
- package/utilities/deprecation/index.d.ts +83 -3
- package/utilities/deprecation/index.js +15 -3
- 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/observables/asyncMap.d.ts +13 -0
- package/utilities/observables/asyncMap.js +13 -0
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/observables/iteration.d.ts +4 -0
- package/utilities/observables/iteration.js +4 -0
- package/utilities/observables/iteration.js.map +1 -1
- package/utilities/subscriptions/urql/index.d.ts +5 -0
- package/utilities/subscriptions/urql/index.js +5 -0
- package/utilities/subscriptions/urql/index.js.map +1 -1
- package/utilities/subscriptions/urql/urql.cjs.map +1 -1
- 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.14.0-alpha.
|
|
25
|
+
var version = "3.14.0-alpha.1";
|
|
26
26
|
|
|
27
27
|
function isNonNullObject(obj) {
|
|
28
28
|
return obj !== null && typeof obj === "object";
|
|
@@ -195,9 +195,11 @@ function directiveIsNonreactive(dir) {
|
|
|
195
195
|
return dir.name.value === "nonreactive";
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
var muteAllDeprecations = Symbol.for("apollo.deprecations");
|
|
199
|
+
var global = globals.global;
|
|
198
200
|
var slot = new optimism.Slot();
|
|
199
201
|
function isMuted(name) {
|
|
200
|
-
return (slot.getValue() || []).includes(name);
|
|
202
|
+
return global[muteAllDeprecations] || (slot.getValue() || []).includes(name);
|
|
201
203
|
}
|
|
202
204
|
function muteDeprecations(name) {
|
|
203
205
|
var args = [];
|
|
@@ -210,7 +212,7 @@ function warnRemovedOption(options, name, callSite, recommendation) {
|
|
|
210
212
|
if (recommendation === void 0) { recommendation = "Please remove this option."; }
|
|
211
213
|
warnDeprecated(name, function () {
|
|
212
214
|
if (name in options) {
|
|
213
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
215
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(104, callSite, name, recommendation);
|
|
214
216
|
}
|
|
215
217
|
});
|
|
216
218
|
}
|
|
@@ -294,6 +296,11 @@ var ObservableQuery = (function (_super) {
|
|
|
294
296
|
});
|
|
295
297
|
ObservableQuery.prototype.result = function () {
|
|
296
298
|
var _this = this;
|
|
299
|
+
if (globalThis.__DEV__ !== false) {
|
|
300
|
+
warnDeprecated("observableQuery.result", function () {
|
|
301
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(23);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
297
304
|
return new Promise(function (resolve, reject) {
|
|
298
305
|
var observer = {
|
|
299
306
|
next: function (result) {
|
|
@@ -315,8 +322,11 @@ var ObservableQuery = (function (_super) {
|
|
|
315
322
|
this.queryInfo.resetDiff();
|
|
316
323
|
};
|
|
317
324
|
ObservableQuery.prototype.getCurrentFullResult = function (saveAsLastResult) {
|
|
325
|
+
var _this = this;
|
|
318
326
|
if (saveAsLastResult === void 0) { saveAsLastResult = true; }
|
|
319
|
-
var lastResult =
|
|
327
|
+
var lastResult = muteDeprecations("getLastResult", function () {
|
|
328
|
+
return _this.getLastResult(true);
|
|
329
|
+
});
|
|
320
330
|
var networkStatus = this.queryInfo.networkStatus ||
|
|
321
331
|
(lastResult && lastResult.networkStatus) ||
|
|
322
332
|
exports.NetworkStatus.ready;
|
|
@@ -391,16 +401,34 @@ var ObservableQuery = (function (_super) {
|
|
|
391
401
|
}
|
|
392
402
|
};
|
|
393
403
|
ObservableQuery.prototype.getLastResult = function (variablesMustMatch) {
|
|
404
|
+
if (globalThis.__DEV__ !== false) {
|
|
405
|
+
warnDeprecated("getLastResult", function () {
|
|
406
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(24);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
394
409
|
return this.getLast("result", variablesMustMatch);
|
|
395
410
|
};
|
|
396
411
|
ObservableQuery.prototype.getLastError = function (variablesMustMatch) {
|
|
412
|
+
if (globalThis.__DEV__ !== false) {
|
|
413
|
+
warnDeprecated("getLastError", function () {
|
|
414
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(25);
|
|
415
|
+
});
|
|
416
|
+
}
|
|
397
417
|
return this.getLast("error", variablesMustMatch);
|
|
398
418
|
};
|
|
399
419
|
ObservableQuery.prototype.resetLastResults = function () {
|
|
420
|
+
if (globalThis.__DEV__ !== false) {
|
|
421
|
+
warnDeprecated("resetLastResults", function () {
|
|
422
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(26);
|
|
423
|
+
});
|
|
424
|
+
}
|
|
400
425
|
delete this.last;
|
|
401
426
|
this.isTornDown = false;
|
|
402
427
|
};
|
|
403
428
|
ObservableQuery.prototype.resetQueryStoreErrors = function () {
|
|
429
|
+
if (globalThis.__DEV__ !== false) {
|
|
430
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(27);
|
|
431
|
+
}
|
|
404
432
|
this.queryManager.resetErrors(this.queryId);
|
|
405
433
|
};
|
|
406
434
|
ObservableQuery.prototype.refetch = function (variables) {
|
|
@@ -420,7 +448,7 @@ var ObservableQuery = (function (_super) {
|
|
|
420
448
|
var vars = queryDef.variableDefinitions;
|
|
421
449
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
422
450
|
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
423
|
-
|
|
451
|
+
28,
|
|
424
452
|
variables,
|
|
425
453
|
((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
|
|
426
454
|
);
|
|
@@ -452,7 +480,7 @@ var ObservableQuery = (function (_super) {
|
|
|
452
480
|
var updateQuery = fetchMoreOptions === null || fetchMoreOptions === void 0 ? void 0 : fetchMoreOptions.updateQuery;
|
|
453
481
|
var isCached = this.options.fetchPolicy !== "no-cache";
|
|
454
482
|
if (!isCached) {
|
|
455
|
-
globals.invariant(updateQuery,
|
|
483
|
+
globals.invariant(updateQuery, 29);
|
|
456
484
|
}
|
|
457
485
|
return this.queryManager
|
|
458
486
|
.fetchQuery(qid, combinedOptions, exports.NetworkStatus.fetchMore)
|
|
@@ -529,7 +557,7 @@ var ObservableQuery = (function (_super) {
|
|
|
529
557
|
options.onError(err);
|
|
530
558
|
return;
|
|
531
559
|
}
|
|
532
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
560
|
+
globalThis.__DEV__ !== false && globals.invariant.error(30, err);
|
|
533
561
|
},
|
|
534
562
|
});
|
|
535
563
|
this.subscriptions.add(subscription);
|
|
@@ -542,6 +570,9 @@ var ObservableQuery = (function (_super) {
|
|
|
542
570
|
ObservableQuery.prototype.setOptions = function (newOptions) {
|
|
543
571
|
if (globalThis.__DEV__ !== false) {
|
|
544
572
|
warnRemovedOption(newOptions, "canonizeResults", "setOptions");
|
|
573
|
+
warnDeprecated("setOptions", function () {
|
|
574
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(31);
|
|
575
|
+
});
|
|
545
576
|
}
|
|
546
577
|
return this.reobserve(newOptions);
|
|
547
578
|
};
|
|
@@ -550,8 +581,11 @@ var ObservableQuery = (function (_super) {
|
|
|
550
581
|
assign(this.options, mergedOptions);
|
|
551
582
|
};
|
|
552
583
|
ObservableQuery.prototype.setVariables = function (variables) {
|
|
584
|
+
var _this = this;
|
|
553
585
|
if (equal.equal(this.variables, variables)) {
|
|
554
|
-
return this.observers.size ?
|
|
586
|
+
return this.observers.size ?
|
|
587
|
+
muteDeprecations("observableQuery.result", function () { return _this.result(); })
|
|
588
|
+
: Promise.resolve();
|
|
555
589
|
}
|
|
556
590
|
this.options.variables = variables;
|
|
557
591
|
if (!this.observers.size) {
|
|
@@ -635,7 +669,7 @@ var ObservableQuery = (function (_super) {
|
|
|
635
669
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
636
670
|
return;
|
|
637
671
|
}
|
|
638
|
-
globals.invariant(pollInterval,
|
|
672
|
+
globals.invariant(pollInterval, 32);
|
|
639
673
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
640
674
|
info.interval = pollInterval;
|
|
641
675
|
var maybeFetch = function () {
|
|
@@ -664,8 +698,11 @@ var ObservableQuery = (function (_super) {
|
|
|
664
698
|
poll();
|
|
665
699
|
};
|
|
666
700
|
ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
|
|
701
|
+
var _this = this;
|
|
667
702
|
if (variables === void 0) { variables = this.variables; }
|
|
668
|
-
var error =
|
|
703
|
+
var error = muteDeprecations("getLastError", function () {
|
|
704
|
+
return _this.getLastError();
|
|
705
|
+
});
|
|
669
706
|
if (error && this.last && !equal.equal(variables, this.last.variables)) {
|
|
670
707
|
error = void 0;
|
|
671
708
|
}
|
|
@@ -741,12 +778,13 @@ var ObservableQuery = (function (_super) {
|
|
|
741
778
|
return utilities.preventUnhandledRejection(this.reobserveAsConcast(newOptions, newNetworkStatus).promise.then(this.maskResult));
|
|
742
779
|
};
|
|
743
780
|
ObservableQuery.prototype.resubscribeAfterError = function () {
|
|
781
|
+
var _this = this;
|
|
744
782
|
var args = [];
|
|
745
783
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
746
784
|
args[_i] = arguments[_i];
|
|
747
785
|
}
|
|
748
786
|
var last = this.last;
|
|
749
|
-
|
|
787
|
+
muteDeprecations("resetLastResults", function () { return _this.resetLastResults(); });
|
|
750
788
|
var subscription = this.subscribe.apply(this, args);
|
|
751
789
|
this.last = last;
|
|
752
790
|
return subscription;
|
|
@@ -756,7 +794,10 @@ var ObservableQuery = (function (_super) {
|
|
|
756
794
|
this.getCurrentFullResult(false), this.variables);
|
|
757
795
|
};
|
|
758
796
|
ObservableQuery.prototype.reportResult = function (result, variables) {
|
|
759
|
-
var
|
|
797
|
+
var _this = this;
|
|
798
|
+
var lastError = muteDeprecations("getLastError", function () {
|
|
799
|
+
return _this.getLastError();
|
|
800
|
+
});
|
|
760
801
|
var isDifferent = this.isDifferentFromLastResult(result, variables);
|
|
761
802
|
if (lastError || !result.partial || this.options.returnPartialData) {
|
|
762
803
|
this.updateLastResult(result, variables);
|
|
@@ -766,7 +807,8 @@ var ObservableQuery = (function (_super) {
|
|
|
766
807
|
}
|
|
767
808
|
};
|
|
768
809
|
ObservableQuery.prototype.reportError = function (error, variables) {
|
|
769
|
-
var
|
|
810
|
+
var _this = this;
|
|
811
|
+
var errorResult = tslib.__assign(tslib.__assign({}, muteDeprecations("getLastResult", function () { return _this.getLastResult(); })), { error: error, errors: error.graphQLErrors, networkStatus: exports.NetworkStatus.error, loading: false });
|
|
770
812
|
this.updateLastResult(errorResult, variables);
|
|
771
813
|
utilities.iterateObserversSafely(this.observers, "error", (this.last.error = error));
|
|
772
814
|
};
|
|
@@ -856,11 +898,11 @@ var ObservableQuery = (function (_super) {
|
|
|
856
898
|
}(utilities.Observable));
|
|
857
899
|
utilities.fixObservableSubclass(ObservableQuery);
|
|
858
900
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
859
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
901
|
+
globalThis.__DEV__ !== false && globals.invariant.error(33, error.message, error.stack);
|
|
860
902
|
}
|
|
861
903
|
function logMissingFieldErrors(missing) {
|
|
862
904
|
if (globalThis.__DEV__ !== false && missing) {
|
|
863
|
-
globalThis.__DEV__ !== false && globals.invariant.debug(
|
|
905
|
+
globalThis.__DEV__ !== false && globals.invariant.debug(34, missing);
|
|
864
906
|
}
|
|
865
907
|
}
|
|
866
908
|
function skipCacheDataFor(fetchPolicy ) {
|
|
@@ -963,14 +1005,17 @@ var QueryInfo = (function () {
|
|
|
963
1005
|
};
|
|
964
1006
|
};
|
|
965
1007
|
QueryInfo.prototype.setDiff = function (diff) {
|
|
966
|
-
var
|
|
1008
|
+
var _this = this;
|
|
1009
|
+
var _a;
|
|
967
1010
|
var oldDiff = this.lastDiff && this.lastDiff.diff;
|
|
968
|
-
if (diff &&
|
|
1011
|
+
if (diff &&
|
|
1012
|
+
!diff.complete &&
|
|
1013
|
+
muteDeprecations("getLastError", function () { var _a; return (_a = _this.observableQuery) === null || _a === void 0 ? void 0 : _a.getLastError(); })) {
|
|
969
1014
|
return;
|
|
970
1015
|
}
|
|
971
1016
|
this.updateLastDiff(diff);
|
|
972
1017
|
if (!equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
|
|
973
|
-
(
|
|
1018
|
+
(_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a["scheduleNotify"]();
|
|
974
1019
|
}
|
|
975
1020
|
};
|
|
976
1021
|
QueryInfo.prototype.setObservableQuery = function (oq) {
|
|
@@ -1150,7 +1195,7 @@ var QueryManager = (function () {
|
|
|
1150
1195
|
this.queries.forEach(function (_info, queryId) {
|
|
1151
1196
|
_this.stopQueryNoBroadcast(queryId);
|
|
1152
1197
|
});
|
|
1153
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1198
|
+
this.cancelPendingFetches(globals.newInvariantError(35));
|
|
1154
1199
|
};
|
|
1155
1200
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
1156
1201
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -1164,8 +1209,8 @@ var QueryManager = (function () {
|
|
|
1164
1209
|
return tslib.__generator(this, function (_j) {
|
|
1165
1210
|
switch (_j.label) {
|
|
1166
1211
|
case 0:
|
|
1167
|
-
globals.invariant(mutation,
|
|
1168
|
-
globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache",
|
|
1212
|
+
globals.invariant(mutation, 36);
|
|
1213
|
+
globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 37);
|
|
1169
1214
|
mutationId = this.generateMutationId();
|
|
1170
1215
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
1171
1216
|
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
@@ -1495,10 +1540,10 @@ var QueryManager = (function () {
|
|
|
1495
1540
|
QueryManager.prototype.query = function (options, queryId) {
|
|
1496
1541
|
var _this = this;
|
|
1497
1542
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
1498
|
-
globals.invariant(options.query,
|
|
1499
|
-
globals.invariant(options.query.kind === "Document",
|
|
1500
|
-
globals.invariant(!options.returnPartialData,
|
|
1501
|
-
globals.invariant(!options.pollInterval,
|
|
1543
|
+
globals.invariant(options.query, 38);
|
|
1544
|
+
globals.invariant(options.query.kind === "Document", 39);
|
|
1545
|
+
globals.invariant(!options.returnPartialData, 40);
|
|
1546
|
+
globals.invariant(!options.pollInterval, 41);
|
|
1502
1547
|
var query = this.transform(options.query);
|
|
1503
1548
|
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: query }))
|
|
1504
1549
|
.then(function (result) {
|
|
@@ -1533,7 +1578,7 @@ var QueryManager = (function () {
|
|
|
1533
1578
|
if (options === void 0) { options = {
|
|
1534
1579
|
discardWatches: true,
|
|
1535
1580
|
}; }
|
|
1536
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1581
|
+
this.cancelPendingFetches(globals.newInvariantError(42));
|
|
1537
1582
|
this.queries.forEach(function (queryInfo) {
|
|
1538
1583
|
if (queryInfo.observableQuery) {
|
|
1539
1584
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -1615,10 +1660,10 @@ var QueryManager = (function () {
|
|
|
1615
1660
|
if (!included) {
|
|
1616
1661
|
var queryName = queryNames.get(nameOrQueryString);
|
|
1617
1662
|
if (queryName) {
|
|
1618
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
1663
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(43, queryName);
|
|
1619
1664
|
}
|
|
1620
1665
|
else {
|
|
1621
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
1666
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(44);
|
|
1622
1667
|
}
|
|
1623
1668
|
}
|
|
1624
1669
|
});
|
|
@@ -1631,7 +1676,9 @@ var QueryManager = (function () {
|
|
|
1631
1676
|
var observableQueryPromises = [];
|
|
1632
1677
|
this.getObservableQueries(includeStandby ? "all" : "active").forEach(function (observableQuery, queryId) {
|
|
1633
1678
|
var fetchPolicy = observableQuery.options.fetchPolicy;
|
|
1634
|
-
|
|
1679
|
+
muteDeprecations("resetLastResults", function () {
|
|
1680
|
+
return observableQuery.resetLastResults();
|
|
1681
|
+
});
|
|
1635
1682
|
if (includeStandby ||
|
|
1636
1683
|
(fetchPolicy !== "standby" && fetchPolicy !== "cache-only")) {
|
|
1637
1684
|
observableQueryPromises.push(observableQuery.refetch());
|
|
@@ -1944,7 +1991,7 @@ var QueryManager = (function () {
|
|
|
1944
1991
|
!this.noCacheWarningsByQueryId.has(operationId)) {
|
|
1945
1992
|
this.noCacheWarningsByQueryId.add(operationId);
|
|
1946
1993
|
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
1947
|
-
|
|
1994
|
+
45,
|
|
1948
1995
|
(_c = utilities.getOperationName(document)) !== null && _c !== void 0 ? _c : "Unnamed ".concat(operationType !== null && operationType !== void 0 ? operationType : "operation")
|
|
1949
1996
|
);
|
|
1950
1997
|
}
|
|
@@ -2259,7 +2306,7 @@ var LocalState = (function () {
|
|
|
2259
2306
|
}
|
|
2260
2307
|
else {
|
|
2261
2308
|
fragment = fragmentMap[selection.name.value];
|
|
2262
|
-
globals.invariant(fragment,
|
|
2309
|
+
globals.invariant(fragment, 21, selection.name.value);
|
|
2263
2310
|
}
|
|
2264
2311
|
if (fragment && fragment.typeCondition) {
|
|
2265
2312
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -2373,7 +2420,7 @@ var LocalState = (function () {
|
|
|
2373
2420
|
},
|
|
2374
2421
|
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
2375
2422
|
var fragment = fragmentMap[spread.name.value];
|
|
2376
|
-
globals.invariant(fragment,
|
|
2423
|
+
globals.invariant(fragment, 22, spread.name.value);
|
|
2377
2424
|
var fragmentSelections = collectByDefinition(fragment);
|
|
2378
2425
|
if (fragmentSelections.size > 0) {
|
|
2379
2426
|
ancestors.forEach(function (node) {
|
|
@@ -2626,6 +2673,7 @@ var ApolloClient = (function () {
|
|
|
2626
2673
|
}
|
|
2627
2674
|
if (globalThis.__DEV__ !== false) {
|
|
2628
2675
|
warnRemovedOption(options, "canonizeResults", "client.watchQuery");
|
|
2676
|
+
warnRemovedOption(options, "partialRefetch", "client.watchQuery");
|
|
2629
2677
|
}
|
|
2630
2678
|
return this.queryManager.watchQuery(options);
|
|
2631
2679
|
};
|
|
@@ -2639,6 +2687,10 @@ var ApolloClient = (function () {
|
|
|
2639
2687
|
}
|
|
2640
2688
|
if (globalThis.__DEV__ !== false) {
|
|
2641
2689
|
warnRemovedOption(options, "canonizeResults", "client.query");
|
|
2690
|
+
warnRemovedOption(options, "notifyOnNetworkStatusChange", "client.query", "This option does not affect `client.query` and can be safely removed.");
|
|
2691
|
+
if (options.fetchPolicy === "standby") {
|
|
2692
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(19);
|
|
2693
|
+
}
|
|
2642
2694
|
}
|
|
2643
2695
|
return this.queryManager.query(options);
|
|
2644
2696
|
};
|
|
@@ -2742,7 +2794,7 @@ var ApolloClient = (function () {
|
|
|
2742
2794
|
result.queries = queries;
|
|
2743
2795
|
result.results = results;
|
|
2744
2796
|
result.catch(function (error) {
|
|
2745
|
-
globalThis.__DEV__ !== false && globals.invariant.debug(
|
|
2797
|
+
globalThis.__DEV__ !== false && globals.invariant.debug(20, error);
|
|
2746
2798
|
});
|
|
2747
2799
|
return result;
|
|
2748
2800
|
};
|
package/core/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DocumentNode, GraphQLFormattedError } from "graphql";
|
|
2
2
|
import type { ApolloCache } from "../cache/index.js";
|
|
3
|
-
import type { FetchResult } from "../link/core/index.js";
|
|
3
|
+
import type { FetchResult, IncrementalPayload } from "../link/core/index.js";
|
|
4
4
|
import type { ApolloError } from "../errors/index.js";
|
|
5
5
|
import type { NetworkStatus } from "./networkStatus.js";
|
|
6
6
|
import type { Resolver } from "./LocalState.js";
|
|
@@ -27,7 +27,7 @@ export interface RefetchQueriesOptions<TCache extends ApolloCache<any>, TResult>
|
|
|
27
27
|
optimistic?: boolean;
|
|
28
28
|
onQueryUpdated?: OnQueryUpdated<TResult> | null;
|
|
29
29
|
}
|
|
30
|
-
export type RefetchQueriesPromiseResults<TResult> = IsStrictlyAny<TResult> extends true ? any[] : TResult extends boolean ?
|
|
30
|
+
export type RefetchQueriesPromiseResults<TResult> = IsStrictlyAny<TResult> extends true ? any[] : TResult extends boolean ? InteropApolloQueryResult<any>[] : TResult extends PromiseLike<infer U> ? U[] : TResult[];
|
|
31
31
|
export interface RefetchQueriesResult<TResult> extends Promise<RefetchQueriesPromiseResults<TResult>> {
|
|
32
32
|
queries: ObservableQuery<any>[];
|
|
33
33
|
results: InternalRefetchQueriesResult<TResult>[];
|
|
@@ -36,11 +36,20 @@ export interface InternalRefetchQueriesOptions<TCache extends ApolloCache<any>,
|
|
|
36
36
|
include?: InternalRefetchQueriesInclude;
|
|
37
37
|
removeOptimistic?: string;
|
|
38
38
|
}
|
|
39
|
-
export type InternalRefetchQueriesResult<TResult> = TResult extends boolean ? Promise<
|
|
39
|
+
export type InternalRefetchQueriesResult<TResult> = TResult extends boolean ? Promise<InteropApolloQueryResult<any>> : TResult;
|
|
40
40
|
export type InternalRefetchQueriesMap<TResult> = Map<ObservableQuery<any>, InternalRefetchQueriesResult<TResult>>;
|
|
41
41
|
export type { QueryOptions as PureQueryOptions };
|
|
42
42
|
export type OperationVariables = Record<string, any>;
|
|
43
43
|
export interface ApolloQueryResult<T> {
|
|
44
|
+
/**
|
|
45
|
+
* An object containing the result of your GraphQL query after it completes.
|
|
46
|
+
*
|
|
47
|
+
* This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
|
|
48
|
+
*
|
|
49
|
+
* @docGroup
|
|
50
|
+
*
|
|
51
|
+
* 1. Operation data
|
|
52
|
+
*/
|
|
44
53
|
data: T;
|
|
45
54
|
/**
|
|
46
55
|
* A list of any errors that occurred during server-side execution of a GraphQL operation.
|
|
@@ -57,6 +66,171 @@ export interface ApolloQueryResult<T> {
|
|
|
57
66
|
networkStatus: NetworkStatus;
|
|
58
67
|
partial?: boolean;
|
|
59
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated This type does not exist in Apollo Client 4.0 and is meant as a
|
|
71
|
+
* bridge between versions for deprecations.
|
|
72
|
+
*/
|
|
73
|
+
export interface InteropApolloQueryResult<T> {
|
|
74
|
+
/**
|
|
75
|
+
* An object containing the result of your GraphQL query after it completes.
|
|
76
|
+
*
|
|
77
|
+
* This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
|
|
78
|
+
*
|
|
79
|
+
* @docGroup
|
|
80
|
+
*
|
|
81
|
+
* 1. Operation data
|
|
82
|
+
*/
|
|
83
|
+
data: T;
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated `errors` will no longer available on the result in Apollo Client 4.0.
|
|
86
|
+
* This value is safe to use in Apollo Client 3.x.
|
|
87
|
+
*
|
|
88
|
+
* **Recommended now**
|
|
89
|
+
*
|
|
90
|
+
* No action needed
|
|
91
|
+
*
|
|
92
|
+
* **When upgrading**
|
|
93
|
+
*
|
|
94
|
+
* `errors` has been consolidated to the `error` property. You will need to
|
|
95
|
+
* read any errors on the `error` property on the resolved value instead.
|
|
96
|
+
*/
|
|
97
|
+
errors?: ReadonlyArray<GraphQLFormattedError>;
|
|
98
|
+
/**
|
|
99
|
+
* The single Error object that is passed to onError and useQuery hooks, and is often thrown during manual `client.query` calls.
|
|
100
|
+
* This will contain both a NetworkError field and any GraphQLErrors.
|
|
101
|
+
* See https://www.apollographql.com/docs/react/data/error-handling/ for more information.
|
|
102
|
+
*/
|
|
103
|
+
error?: ApolloError;
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated `loading` will no longer available on the result in Apollo Client 4.0.
|
|
106
|
+
* This value is always true when the resolved and can safely ignored.
|
|
107
|
+
*/
|
|
108
|
+
loading: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* @deprecated `loading` will no longer available on the result in Apollo Client 4.0.
|
|
111
|
+
* This value is always `NetworkStatus.ready` or `NetworkStatus.error`. To
|
|
112
|
+
* determine if the result contains an error, read from the `error` or `errors`
|
|
113
|
+
* property instead.
|
|
114
|
+
*/
|
|
115
|
+
networkStatus: NetworkStatus;
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated `partial` will no longer available on the result in Apollo Client 4.0.
|
|
118
|
+
* This value is always `false` if there is a data value since the result
|
|
119
|
+
* never contains partial cache data.
|
|
120
|
+
*/
|
|
121
|
+
partial?: boolean;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated This type does not exist in Apollo Client 4.0 and is meant as a
|
|
125
|
+
* bridge between versions for deprecations.
|
|
126
|
+
*/
|
|
127
|
+
interface InteropSingleExecutionResult<TData = Record<string, any>, TContext = DefaultContext, TExtensions = Record<string, any>> {
|
|
128
|
+
data?: TData | null;
|
|
129
|
+
/**
|
|
130
|
+
* @deprecated `context` will no longer available on the result in Apollo Client 4.0.
|
|
131
|
+
*/
|
|
132
|
+
context?: TContext;
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated `errors` is no longer available on the result in Apollo Client 4.0.
|
|
135
|
+
* This value is safe to use in Apollo Client 3.x.
|
|
136
|
+
*
|
|
137
|
+
* **Recommended now**
|
|
138
|
+
*
|
|
139
|
+
* No action needed
|
|
140
|
+
*
|
|
141
|
+
* **When upgrading**
|
|
142
|
+
*
|
|
143
|
+
* `errors` has been consolidated to the `error` property. You will need to
|
|
144
|
+
* read any errors on the `error` property on the resolved value instead.
|
|
145
|
+
*/
|
|
146
|
+
errors?: ReadonlyArray<GraphQLFormattedError>;
|
|
147
|
+
extensions?: TExtensions;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @deprecated This type does not exist in Apollo Client 4.0 and is meant as a
|
|
151
|
+
* bridge between versions for deprecations.
|
|
152
|
+
*/
|
|
153
|
+
export interface InteropMutationExecutionPatchInitialResult<TData = Record<string, any>, TExtensions = Record<string, any>> {
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated `hasNext` will no longer available on the result in Apollo Client 4.0.
|
|
156
|
+
*/
|
|
157
|
+
hasNext?: boolean;
|
|
158
|
+
data: TData | null | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* @deprecated `incremental` will no longer available on the result in Apollo Client 4.0.
|
|
161
|
+
*/
|
|
162
|
+
incremental?: never;
|
|
163
|
+
/**
|
|
164
|
+
* @deprecated `errors` is no longer available on the result in Apollo Client 4.0.
|
|
165
|
+
* This value is safe to use in Apollo Client 3.x.
|
|
166
|
+
*
|
|
167
|
+
* **Recommended now**
|
|
168
|
+
*
|
|
169
|
+
* No action needed
|
|
170
|
+
*
|
|
171
|
+
* **When upgrading**
|
|
172
|
+
*
|
|
173
|
+
* `errors` has been consolidated to the `error` property. You will need to
|
|
174
|
+
* read any errors on the `error` property on the resolved value instead.
|
|
175
|
+
*/
|
|
176
|
+
errors?: ReadonlyArray<GraphQLFormattedError>;
|
|
177
|
+
extensions?: TExtensions;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* @deprecated This type does not exist in Apollo Client 4.0 and is meant as a
|
|
181
|
+
* bridge between versions for deprecations.
|
|
182
|
+
*/
|
|
183
|
+
export interface InteropMutationExecutionPatchIncrementalResult<TData = Record<string, any>, TExtensions = Record<string, any>> {
|
|
184
|
+
/**
|
|
185
|
+
* @deprecated `hasNext` will no longer available on the result in Apollo Client 4.0.
|
|
186
|
+
* This value is safe to use in Apollo Client 3.x.
|
|
187
|
+
*
|
|
188
|
+
* **Recommended now**
|
|
189
|
+
*
|
|
190
|
+
* No action needed
|
|
191
|
+
*
|
|
192
|
+
* **When upgrading**
|
|
193
|
+
*
|
|
194
|
+
* `errors` has been consolidated to the `error` property. You will need to
|
|
195
|
+
* read any errors on the `error` property on the resolved value instead.
|
|
196
|
+
*/
|
|
197
|
+
hasNext?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated `incremental` will no longer available on the result in Apollo Client 4.0.
|
|
200
|
+
*/
|
|
201
|
+
incremental?: IncrementalPayload<TData, TExtensions>[];
|
|
202
|
+
data?: never;
|
|
203
|
+
/**
|
|
204
|
+
* @deprecated `errors` is no longer available on the result in Apollo Client 4.0.
|
|
205
|
+
* This value is safe to use in Apollo Client 3.x.
|
|
206
|
+
*
|
|
207
|
+
* **Recommended now**
|
|
208
|
+
*
|
|
209
|
+
* No action needed
|
|
210
|
+
*
|
|
211
|
+
* **When upgrading**
|
|
212
|
+
*
|
|
213
|
+
* `errors` has been consolidated to the `error` property. You will need to
|
|
214
|
+
* read any errors on the `error` property on the resolved value instead.
|
|
215
|
+
*/
|
|
216
|
+
errors?: never;
|
|
217
|
+
extensions?: never;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* @deprecated This type does not exist in Apollo Client 4.0 and is meant as a
|
|
221
|
+
* bridge between versions for deprecations.
|
|
222
|
+
*/
|
|
223
|
+
export type InteropExecutionPatchResult<TData = Record<string, any>, TExtensions = Record<string, any>> = InteropMutationExecutionPatchInitialResult<TData, TExtensions> | InteropMutationExecutionPatchIncrementalResult<TData, TExtensions>;
|
|
224
|
+
/**
|
|
225
|
+
* @deprecated This type does not exist in Apollo Client 4.0 and is meant as a
|
|
226
|
+
* bridge between versions for deprecations.
|
|
227
|
+
*/
|
|
228
|
+
export type InteropMutateResult<TData = Record<string, any>, TContext = DefaultContext, TExtensions = Record<string, any>> = InteropSingleExecutionResult<TData, TContext, TExtensions> | InteropExecutionPatchResult<TData, TExtensions>;
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated This type does not exist in Apollo Client 4.0 and is meant as a
|
|
231
|
+
* bridge between versions for deprecations.
|
|
232
|
+
*/
|
|
233
|
+
export type InteropSubscribeResult<TData = Record<string, any>, TContext = DefaultContext, TExtensions = Record<string, any>> = InteropSingleExecutionResult<TData, TContext, TExtensions> | InteropExecutionPatchResult<TData, TExtensions>;
|
|
60
234
|
export type MutationQueryReducer<T> = (previousResult: Record<string, any>, options: {
|
|
61
235
|
mutationResult: FetchResult<Unmasked<T>>;
|
|
62
236
|
queryName: string | undefined;
|
package/core/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode, GraphQLFormattedError } from \"graphql\";\n\nimport type { ApolloCache } from \"../cache/index.js\";\nimport type { FetchResult } from \"../link/core/index.js\";\nimport type { ApolloError } from \"../errors/index.js\";\nimport type { NetworkStatus } from \"./networkStatus.js\";\nimport type { Resolver } from \"./LocalState.js\";\nimport type { ObservableQuery } from \"./ObservableQuery.js\";\nimport type { QueryOptions } from \"./watchQueryOptions.js\";\nimport type { Cache } from \"../cache/index.js\";\nimport type { IsStrictlyAny } from \"../utilities/index.js\";\nimport type { Unmasked } from \"../masking/index.js\";\n\nexport type { TypedDocumentNode } from \"@graphql-typed-document-node/core\";\n\nexport type MethodKeys<T> = {\n [P in keyof T]: T[P] extends Function ? P : never;\n}[keyof T];\n\nexport interface DefaultContext extends Record<string, any> {}\n\nexport type OnQueryUpdated<TResult> = (\n observableQuery: ObservableQuery<any>,\n diff: Cache.DiffResult<any>,\n lastDiff: Cache.DiffResult<any> | undefined\n) => boolean | TResult;\n\nexport type RefetchQueryDescriptor = string | DocumentNode;\nexport type InternalRefetchQueryDescriptor =\n | RefetchQueryDescriptor\n | QueryOptions;\n\ntype RefetchQueriesIncludeShorthand = \"all\" | \"active\";\n\nexport type RefetchQueriesInclude =\n | RefetchQueryDescriptor[]\n | RefetchQueriesIncludeShorthand;\n\nexport type InternalRefetchQueriesInclude =\n | InternalRefetchQueryDescriptor[]\n | RefetchQueriesIncludeShorthand;\n\n// Used by ApolloClient[\"refetchQueries\"]\n// TODO Improve documentation comments for this public type.\nexport interface RefetchQueriesOptions<\n TCache extends ApolloCache<any>,\n TResult,\n> {\n updateCache?: (cache: TCache) => void;\n // The client.refetchQueries method discourages passing QueryOptions, by\n // restricting the public type of options.include to exclude QueryOptions as\n // an available array element type (see InternalRefetchQueriesInclude for a\n // version of RefetchQueriesInclude that allows legacy QueryOptions objects).\n include?: RefetchQueriesInclude;\n optimistic?: boolean;\n // If no onQueryUpdated function is provided, any queries affected by the\n // updateCache function or included in the options.include array will be\n // refetched by default. Passing null instead of undefined disables this\n // default refetching behavior for affected queries, though included queries\n // will still be refetched.\n onQueryUpdated?: OnQueryUpdated<TResult> | null;\n}\n\n// The client.refetchQueries method returns a thenable (PromiseLike) object\n// whose result is an array of Promise.resolve'd TResult values, where TResult\n// is whatever type the (optional) onQueryUpdated function returns. When no\n// onQueryUpdated function is given, TResult defaults to ApolloQueryResult<any>\n// (thanks to default type parameters for client.refetchQueries).\nexport type RefetchQueriesPromiseResults<TResult> =\n // If onQueryUpdated returns any, all bets are off, so the results array must\n // be a generic any[] array, which is much less confusing than the union type\n // we get if we don't check for any. I hoped `any extends TResult` would do\n // the trick here, instead of IsStrictlyAny, but you can see for yourself what\n // fails in the refetchQueries tests if you try making that simplification.\n IsStrictlyAny<TResult> extends true ? any[]\n : // If the onQueryUpdated function passed to client.refetchQueries returns true\n // or false, that means either to refetch the query (true) or to skip the\n // query (false). Since refetching produces an ApolloQueryResult<any>, and\n // skipping produces nothing, the fully-resolved array of all results produced\n // will be an ApolloQueryResult<any>[], when TResult extends boolean.\n TResult extends boolean ? ApolloQueryResult<any>[]\n : // If onQueryUpdated returns a PromiseLike<U>, that thenable will be passed as\n // an array element to Promise.all, so we infer/unwrap the array type U here.\n TResult extends PromiseLike<infer U> ? U[]\n : // All other onQueryUpdated results end up in the final Promise.all array as\n // themselves, with their original TResult type. Note that TResult will\n // default to ApolloQueryResult<any> if no onQueryUpdated function is passed\n // to client.refetchQueries.\n TResult[];\n\n// The result of client.refetchQueries is thenable/awaitable, if you just want\n// an array of fully resolved results, but you can also access the raw results\n// immediately by examining the additional { queries, results } properties of\n// the RefetchQueriesResult<TResult> object.\nexport interface RefetchQueriesResult<TResult>\n extends Promise<RefetchQueriesPromiseResults<TResult>> {\n // An array of ObservableQuery objects corresponding 1:1 to TResult values\n // in the results arrays (both the TResult[] array below, and the results\n // array resolved by the Promise above).\n queries: ObservableQuery<any>[];\n // These are the raw TResult values returned by any onQueryUpdated functions\n // that were invoked by client.refetchQueries.\n results: InternalRefetchQueriesResult<TResult>[];\n}\n\n// Used by QueryManager[\"refetchQueries\"]\nexport interface InternalRefetchQueriesOptions<\n TCache extends ApolloCache<any>,\n TResult,\n> extends Omit<RefetchQueriesOptions<TCache, TResult>, \"include\"> {\n // Just like the refetchQueries option for a mutation, an array of strings,\n // DocumentNode objects, and/or QueryOptions objects, or one of the shorthand\n // strings \"all\" or \"active\", to select every (active) query.\n include?: InternalRefetchQueriesInclude;\n // This part of the API is a (useful) implementation detail, but need not be\n // exposed in the public client.refetchQueries API (above).\n removeOptimistic?: string;\n}\n\nexport type InternalRefetchQueriesResult<TResult> =\n // If onQueryUpdated returns a boolean, that's equivalent to refetching the\n // query when the boolean is true and skipping the query when false, so the\n // internal type of refetched results is Promise<ApolloQueryResult<any>>.\n TResult extends boolean ? Promise<ApolloQueryResult<any>>\n : // Otherwise, onQueryUpdated returns whatever it returns. If onQueryUpdated is\n // not provided, TResult defaults to Promise<ApolloQueryResult<any>> (see the\n // generic type parameters of client.refetchQueries).\n TResult;\n\nexport type InternalRefetchQueriesMap<TResult> = Map<\n ObservableQuery<any>,\n InternalRefetchQueriesResult<TResult>\n>;\n\n// TODO Remove this unnecessary type in Apollo Client 4.\nexport type { QueryOptions as PureQueryOptions };\n\nexport type OperationVariables = Record<string, any>;\n\nexport interface ApolloQueryResult<T> {\n data: T;\n /**\n * A list of any errors that occurred during server-side execution of a GraphQL operation.\n * See https://www.apollographql.com/docs/react/data/error-handling/ for more information.\n */\n errors?: ReadonlyArray<GraphQLFormattedError>;\n /**\n * The single Error object that is passed to onError and useQuery hooks, and is often thrown during manual `client.query` calls.\n * This will contain both a NetworkError field and any GraphQLErrors.\n * See https://www.apollographql.com/docs/react/data/error-handling/ for more information.\n */\n error?: ApolloError;\n loading: boolean;\n networkStatus: NetworkStatus;\n // If result.data was read from the cache with missing fields,\n // result.partial will be true. Otherwise, result.partial will be falsy\n // (usually because the property is absent from the result object).\n partial?: boolean;\n}\n\n// This is part of the public API, people write these functions in `updateQueries`.\nexport type MutationQueryReducer<T> = (\n previousResult: Record<string, any>,\n options: {\n mutationResult: FetchResult<Unmasked<T>>;\n queryName: string | undefined;\n queryVariables: Record<string, any>;\n }\n) => Record<string, any>;\n\nexport type MutationQueryReducersMap<T = { [key: string]: any }> = {\n [queryName: string]: MutationQueryReducer<T>;\n};\n\n/**\n * @deprecated Use `MutationUpdaterFunction` instead.\n */\nexport type MutationUpdaterFn<T = { [key: string]: any }> = (\n // The MutationUpdaterFn type is broken because it mistakenly uses the same\n // type parameter T for both the cache and the mutationResult. Do not use this\n // type unless you absolutely need it for backwards compatibility.\n cache: ApolloCache<T>,\n mutationResult: FetchResult<T>\n) => void;\n\nexport type MutationUpdaterFunction<\n TData,\n TVariables,\n TContext,\n TCache extends ApolloCache<any>,\n> = (\n cache: TCache,\n result: Omit<FetchResult<Unmasked<TData>>, \"context\">,\n options: {\n context?: TContext;\n variables?: TVariables;\n }\n) => void;\nexport interface Resolvers {\n [key: string]: {\n [field: string]: Resolver;\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode, GraphQLFormattedError } from \"graphql\";\n\nimport type { ApolloCache } from \"../cache/index.js\";\nimport type { FetchResult, IncrementalPayload } from \"../link/core/index.js\";\nimport type { ApolloError } from \"../errors/index.js\";\nimport type { NetworkStatus } from \"./networkStatus.js\";\nimport type { Resolver } from \"./LocalState.js\";\nimport type { ObservableQuery } from \"./ObservableQuery.js\";\nimport type { QueryOptions } from \"./watchQueryOptions.js\";\nimport type { Cache } from \"../cache/index.js\";\nimport type { IsStrictlyAny } from \"../utilities/index.js\";\nimport type { Unmasked } from \"../masking/index.js\";\n\nexport type { TypedDocumentNode } from \"@graphql-typed-document-node/core\";\n\nexport type MethodKeys<T> = {\n [P in keyof T]: T[P] extends Function ? P : never;\n}[keyof T];\n\nexport interface DefaultContext extends Record<string, any> {}\n\nexport type OnQueryUpdated<TResult> = (\n observableQuery: ObservableQuery<any>,\n diff: Cache.DiffResult<any>,\n lastDiff: Cache.DiffResult<any> | undefined\n) => boolean | TResult;\n\nexport type RefetchQueryDescriptor = string | DocumentNode;\nexport type InternalRefetchQueryDescriptor =\n | RefetchQueryDescriptor\n | QueryOptions;\n\ntype RefetchQueriesIncludeShorthand = \"all\" | \"active\";\n\nexport type RefetchQueriesInclude =\n | RefetchQueryDescriptor[]\n | RefetchQueriesIncludeShorthand;\n\nexport type InternalRefetchQueriesInclude =\n | InternalRefetchQueryDescriptor[]\n | RefetchQueriesIncludeShorthand;\n\n// Used by ApolloClient[\"refetchQueries\"]\n// TODO Improve documentation comments for this public type.\nexport interface RefetchQueriesOptions<\n TCache extends ApolloCache<any>,\n TResult,\n> {\n updateCache?: (cache: TCache) => void;\n // The client.refetchQueries method discourages passing QueryOptions, by\n // restricting the public type of options.include to exclude QueryOptions as\n // an available array element type (see InternalRefetchQueriesInclude for a\n // version of RefetchQueriesInclude that allows legacy QueryOptions objects).\n include?: RefetchQueriesInclude;\n optimistic?: boolean;\n // If no onQueryUpdated function is provided, any queries affected by the\n // updateCache function or included in the options.include array will be\n // refetched by default. Passing null instead of undefined disables this\n // default refetching behavior for affected queries, though included queries\n // will still be refetched.\n onQueryUpdated?: OnQueryUpdated<TResult> | null;\n}\n\n// The client.refetchQueries method returns a thenable (PromiseLike) object\n// whose result is an array of Promise.resolve'd TResult values, where TResult\n// is whatever type the (optional) onQueryUpdated function returns. When no\n// onQueryUpdated function is given, TResult defaults to ApolloQueryResult<any>\n// (thanks to default type parameters for client.refetchQueries).\nexport type RefetchQueriesPromiseResults<TResult> =\n // If onQueryUpdated returns any, all bets are off, so the results array must\n // be a generic any[] array, which is much less confusing than the union type\n // we get if we don't check for any. I hoped `any extends TResult` would do\n // the trick here, instead of IsStrictlyAny, but you can see for yourself what\n // fails in the refetchQueries tests if you try making that simplification.\n IsStrictlyAny<TResult> extends true ? any[]\n : // If the onQueryUpdated function passed to client.refetchQueries returns true\n // or false, that means either to refetch the query (true) or to skip the\n // query (false). Since refetching produces an ApolloQueryResult<any>, and\n // skipping produces nothing, the fully-resolved array of all results produced\n // will be an ApolloQueryResult<any>[], when TResult extends boolean.\n TResult extends boolean ? InteropApolloQueryResult<any>[]\n : // If onQueryUpdated returns a PromiseLike<U>, that thenable will be passed as\n // an array element to Promise.all, so we infer/unwrap the array type U here.\n TResult extends PromiseLike<infer U> ? U[]\n : // All other onQueryUpdated results end up in the final Promise.all array as\n // themselves, with their original TResult type. Note that TResult will\n // default to ApolloQueryResult<any> if no onQueryUpdated function is passed\n // to client.refetchQueries.\n TResult[];\n\n// The result of client.refetchQueries is thenable/awaitable, if you just want\n// an array of fully resolved results, but you can also access the raw results\n// immediately by examining the additional { queries, results } properties of\n// the RefetchQueriesResult<TResult> object.\nexport interface RefetchQueriesResult<TResult>\n extends Promise<RefetchQueriesPromiseResults<TResult>> {\n // An array of ObservableQuery objects corresponding 1:1 to TResult values\n // in the results arrays (both the TResult[] array below, and the results\n // array resolved by the Promise above).\n queries: ObservableQuery<any>[];\n // These are the raw TResult values returned by any onQueryUpdated functions\n // that were invoked by client.refetchQueries.\n results: InternalRefetchQueriesResult<TResult>[];\n}\n\n// Used by QueryManager[\"refetchQueries\"]\nexport interface InternalRefetchQueriesOptions<\n TCache extends ApolloCache<any>,\n TResult,\n> extends Omit<RefetchQueriesOptions<TCache, TResult>, \"include\"> {\n // Just like the refetchQueries option for a mutation, an array of strings,\n // DocumentNode objects, and/or QueryOptions objects, or one of the shorthand\n // strings \"all\" or \"active\", to select every (active) query.\n include?: InternalRefetchQueriesInclude;\n // This part of the API is a (useful) implementation detail, but need not be\n // exposed in the public client.refetchQueries API (above).\n removeOptimistic?: string;\n}\n\nexport type InternalRefetchQueriesResult<TResult> =\n // If onQueryUpdated returns a boolean, that's equivalent to refetching the\n // query when the boolean is true and skipping the query when false, so the\n // internal type of refetched results is Promise<ApolloQueryResult<any>>.\n TResult extends boolean ? Promise<InteropApolloQueryResult<any>>\n : // Otherwise, onQueryUpdated returns whatever it returns. If onQueryUpdated is\n // not provided, TResult defaults to Promise<ApolloQueryResult<any>> (see the\n // generic type parameters of client.refetchQueries).\n TResult;\n\nexport type InternalRefetchQueriesMap<TResult> = Map<\n ObservableQuery<any>,\n InternalRefetchQueriesResult<TResult>\n>;\n\n// TODO Remove this unnecessary type in Apollo Client 4.\nexport type { QueryOptions as PureQueryOptions };\n\nexport type OperationVariables = Record<string, any>;\n\nexport interface ApolloQueryResult<T> {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: T;\n /**\n * A list of any errors that occurred during server-side execution of a GraphQL operation.\n * See https://www.apollographql.com/docs/react/data/error-handling/ for more information.\n */\n errors?: ReadonlyArray<GraphQLFormattedError>;\n /**\n * The single Error object that is passed to onError and useQuery hooks, and is often thrown during manual `client.query` calls.\n * This will contain both a NetworkError field and any GraphQLErrors.\n * See https://www.apollographql.com/docs/react/data/error-handling/ for more information.\n */\n error?: ApolloError;\n loading: boolean;\n networkStatus: NetworkStatus;\n // If result.data was read from the cache with missing fields,\n // result.partial will be true. Otherwise, result.partial will be falsy\n // (usually because the property is absent from the result object).\n partial?: boolean;\n}\n\n/**\n * @deprecated This type does not exist in Apollo Client 4.0 and is meant as a\n * bridge between versions for deprecations.\n */\nexport interface InteropApolloQueryResult<T> {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: T;\n /**\n * @deprecated `errors` will no longer available on the result in Apollo Client 4.0.\n * This value is safe to use in Apollo Client 3.x.\n *\n * **Recommended now**\n *\n * No action needed\n *\n * **When upgrading**\n *\n * `errors` has been consolidated to the `error` property. You will need to\n * read any errors on the `error` property on the resolved value instead.\n */\n errors?: ReadonlyArray<GraphQLFormattedError>;\n /**\n * The single Error object that is passed to onError and useQuery hooks, and is often thrown during manual `client.query` calls.\n * This will contain both a NetworkError field and any GraphQLErrors.\n * See https://www.apollographql.com/docs/react/data/error-handling/ for more information.\n */\n error?: ApolloError;\n /**\n * @deprecated `loading` will no longer available on the result in Apollo Client 4.0.\n * This value is always true when the resolved and can safely ignored.\n */\n loading: boolean;\n /**\n * @deprecated `loading` will no longer available on the result in Apollo Client 4.0.\n * This value is always `NetworkStatus.ready` or `NetworkStatus.error`. To\n * determine if the result contains an error, read from the `error` or `errors`\n * property instead.\n */\n networkStatus: NetworkStatus;\n /**\n * @deprecated `partial` will no longer available on the result in Apollo Client 4.0.\n * This value is always `false` if there is a data value since the result\n * never contains partial cache data.\n */\n partial?: boolean;\n}\n\n/**\n * @deprecated This type does not exist in Apollo Client 4.0 and is meant as a\n * bridge between versions for deprecations.\n */\ninterface InteropSingleExecutionResult<\n TData = Record<string, any>,\n TContext = DefaultContext,\n TExtensions = Record<string, any>,\n> {\n data?: TData | null;\n /**\n * @deprecated `context` will no longer available on the result in Apollo Client 4.0.\n */\n context?: TContext;\n /**\n * @deprecated `errors` is no longer available on the result in Apollo Client 4.0.\n * This value is safe to use in Apollo Client 3.x.\n *\n * **Recommended now**\n *\n * No action needed\n *\n * **When upgrading**\n *\n * `errors` has been consolidated to the `error` property. You will need to\n * read any errors on the `error` property on the resolved value instead.\n */\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: TExtensions;\n}\n\n/**\n * @deprecated This type does not exist in Apollo Client 4.0 and is meant as a\n * bridge between versions for deprecations.\n */\nexport interface InteropMutationExecutionPatchInitialResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> {\n /**\n * @deprecated `hasNext` will no longer available on the result in Apollo Client 4.0.\n */\n hasNext?: boolean;\n // if data is present, incremental is not\n data: TData | null | undefined;\n /**\n * @deprecated `incremental` will no longer available on the result in Apollo Client 4.0.\n */\n incremental?: never;\n /**\n * @deprecated `errors` is no longer available on the result in Apollo Client 4.0.\n * This value is safe to use in Apollo Client 3.x.\n *\n * **Recommended now**\n *\n * No action needed\n *\n * **When upgrading**\n *\n * `errors` has been consolidated to the `error` property. You will need to\n * read any errors on the `error` property on the resolved value instead.\n */\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: TExtensions;\n}\n\n/**\n * @deprecated This type does not exist in Apollo Client 4.0 and is meant as a\n * bridge between versions for deprecations.\n */\nexport interface InteropMutationExecutionPatchIncrementalResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> {\n /**\n * @deprecated `hasNext` will no longer available on the result in Apollo Client 4.0.\n * This value is safe to use in Apollo Client 3.x.\n *\n * **Recommended now**\n *\n * No action needed\n *\n * **When upgrading**\n *\n * `errors` has been consolidated to the `error` property. You will need to\n * read any errors on the `error` property on the resolved value instead.\n */\n hasNext?: boolean;\n /**\n * @deprecated `incremental` will no longer available on the result in Apollo Client 4.0.\n */\n incremental?: IncrementalPayload<TData, TExtensions>[];\n data?: never;\n /**\n * @deprecated `errors` is no longer available on the result in Apollo Client 4.0.\n * This value is safe to use in Apollo Client 3.x.\n *\n * **Recommended now**\n *\n * No action needed\n *\n * **When upgrading**\n *\n * `errors` has been consolidated to the `error` property. You will need to\n * read any errors on the `error` property on the resolved value instead.\n */\n errors?: never;\n extensions?: never;\n}\n\n/**\n * @deprecated This type does not exist in Apollo Client 4.0 and is meant as a\n * bridge between versions for deprecations.\n */\nexport type InteropExecutionPatchResult<\n TData = Record<string, any>,\n TExtensions = Record<string, any>,\n> =\n | InteropMutationExecutionPatchInitialResult<TData, TExtensions>\n | InteropMutationExecutionPatchIncrementalResult<TData, TExtensions>;\n\n/**\n * @deprecated This type does not exist in Apollo Client 4.0 and is meant as a\n * bridge between versions for deprecations.\n */\nexport type InteropMutateResult<\n TData = Record<string, any>,\n TContext = DefaultContext,\n TExtensions = Record<string, any>,\n> =\n | InteropSingleExecutionResult<TData, TContext, TExtensions>\n | InteropExecutionPatchResult<TData, TExtensions>;\n\n/**\n * @deprecated This type does not exist in Apollo Client 4.0 and is meant as a\n * bridge between versions for deprecations.\n */\nexport type InteropSubscribeResult<\n TData = Record<string, any>,\n TContext = DefaultContext,\n TExtensions = Record<string, any>,\n> =\n | InteropSingleExecutionResult<TData, TContext, TExtensions>\n | InteropExecutionPatchResult<TData, TExtensions>;\n\n// This is part of the public API, people write these functions in `updateQueries`.\nexport type MutationQueryReducer<T> = (\n previousResult: Record<string, any>,\n options: {\n mutationResult: FetchResult<Unmasked<T>>;\n queryName: string | undefined;\n queryVariables: Record<string, any>;\n }\n) => Record<string, any>;\n\nexport type MutationQueryReducersMap<T = { [key: string]: any }> = {\n [queryName: string]: MutationQueryReducer<T>;\n};\n\n/**\n * @deprecated Use `MutationUpdaterFunction` instead.\n */\nexport type MutationUpdaterFn<T = { [key: string]: any }> = (\n // The MutationUpdaterFn type is broken because it mistakenly uses the same\n // type parameter T for both the cache and the mutationResult. Do not use this\n // type unless you absolutely need it for backwards compatibility.\n cache: ApolloCache<T>,\n mutationResult: FetchResult<T>\n) => void;\n\nexport type MutationUpdaterFunction<\n TData,\n TVariables,\n TContext,\n TCache extends ApolloCache<any>,\n> = (\n cache: TCache,\n result: Omit<FetchResult<Unmasked<TData>>, \"context\">,\n options: {\n context?: TContext;\n variables?: TVariables;\n }\n) => void;\nexport interface Resolvers {\n [key: string]: {\n [field: string]: Resolver;\n };\n}\n"]}
|
|
@@ -118,7 +118,7 @@ export interface QueryOptions<TVariables = OperationVariables, TData = any> {
|
|
|
118
118
|
*
|
|
119
119
|
* @deprecated
|
|
120
120
|
*
|
|
121
|
-
* Setting this option is unnecessary in Apollo Client 3, thanks to a more consistent application of fetch policies. It
|
|
121
|
+
* Setting this option is unnecessary in Apollo Client 3, thanks to a more consistent application of fetch policies. It will be removed in Apollo Client 4.0.
|
|
122
122
|
*/
|
|
123
123
|
partialRefetch?: boolean;
|
|
124
124
|
/**
|
|
@@ -247,7 +247,7 @@ export interface SharedWatchQueryOptions<TVariables extends OperationVariables,
|
|
|
247
247
|
*
|
|
248
248
|
* @deprecated
|
|
249
249
|
*
|
|
250
|
-
* Setting this option is unnecessary in Apollo Client 3, thanks to a more consistent application of fetch policies. It
|
|
250
|
+
* Setting this option is unnecessary in Apollo Client 3, thanks to a more consistent application of fetch policies. It will be removed in Apollo Client 4.0.
|
|
251
251
|
*/
|
|
252
252
|
partialRefetch?: boolean;
|
|
253
253
|
/**
|
|
@@ -481,6 +481,14 @@ export interface MutationOptions<TData = any, TVariables = OperationVariables, T
|
|
|
481
481
|
*/
|
|
482
482
|
mutation: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
|
483
483
|
}
|
|
484
|
+
/**
|
|
485
|
+
* @deprecated `MutationSharedOptions` will be removed in Apollo Client 4.0. Types
|
|
486
|
+
* have been flattened in 4.0 and no longer extend this base type.
|
|
487
|
+
*
|
|
488
|
+
* **Recommended now**
|
|
489
|
+
*
|
|
490
|
+
* Copy all properties from this type into your type.
|
|
491
|
+
*/
|
|
484
492
|
export interface MutationSharedOptions<TData = any, TVariables = OperationVariables, TContext = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>> extends MutationBaseOptions<TData, TVariables, TContext, TCache> {
|
|
485
493
|
/**
|
|
486
494
|
* Provide `no-cache` if the mutation's result should _not_ be written to the Apollo Client cache.
|