@apollo/client 3.11.2 → 3.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/apollo-client.cjs +109 -87
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/core/types/common.d.ts +5 -3
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.js.map +1 -1
- package/core/ObservableQuery.d.ts +1 -1
- package/core/ObservableQuery.js +79 -43
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.js +19 -11
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +65 -43
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +65 -43
- package/dev/dev.cjs +72 -67
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +72 -67
- package/invariantErrorCodes.js +72 -66
- 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/package.json +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +3 -3
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +3 -3
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +2 -2
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +2 -2
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +9 -9
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +9 -9
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useLoadableQuery.js +2 -2
- 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.js +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.js +5 -5
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- 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/internal/scenarios/index.d.ts +5 -0
- package/testing/internal/scenarios/index.js +1 -1
- package/testing/internal/scenarios/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 +4 -4
- 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/Concast.js +1 -1
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/utilities.cjs +20 -20
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +20 -20
- package/version.js +1 -1
package/core/core.cjs
CHANGED
|
@@ -20,7 +20,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
20
20
|
|
|
21
21
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
22
22
|
|
|
23
|
-
var version = "3.11.
|
|
23
|
+
var version = "3.11.4";
|
|
24
24
|
|
|
25
25
|
function isNonNullObject(obj) {
|
|
26
26
|
return obj !== null && typeof obj === "object";
|
|
@@ -406,6 +406,11 @@ var ObservableQuery = (function (_super) {
|
|
|
406
406
|
this.observe();
|
|
407
407
|
}
|
|
408
408
|
var updatedQuerySet = new Set();
|
|
409
|
+
var updateQuery = fetchMoreOptions === null || fetchMoreOptions === void 0 ? void 0 : fetchMoreOptions.updateQuery;
|
|
410
|
+
var isCached = this.options.fetchPolicy !== "no-cache";
|
|
411
|
+
if (!isCached) {
|
|
412
|
+
globals.invariant(updateQuery, 21);
|
|
413
|
+
}
|
|
409
414
|
return this.queryManager
|
|
410
415
|
.fetchQuery(qid, combinedOptions, exports.NetworkStatus.fetchMore)
|
|
411
416
|
.then(function (fetchMoreResult) {
|
|
@@ -413,38 +418,48 @@ var ObservableQuery = (function (_super) {
|
|
|
413
418
|
if (queryInfo.networkStatus === exports.NetworkStatus.fetchMore) {
|
|
414
419
|
queryInfo.networkStatus = originalNetworkStatus;
|
|
415
420
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
421
|
+
if (isCached) {
|
|
422
|
+
_this.queryManager.cache.batch({
|
|
423
|
+
update: function (cache) {
|
|
424
|
+
var updateQuery = fetchMoreOptions.updateQuery;
|
|
425
|
+
if (updateQuery) {
|
|
426
|
+
cache.updateQuery({
|
|
427
|
+
query: _this.query,
|
|
428
|
+
variables: _this.variables,
|
|
429
|
+
returnPartialData: true,
|
|
430
|
+
optimistic: false,
|
|
431
|
+
}, function (previous) {
|
|
432
|
+
return updateQuery(previous, {
|
|
433
|
+
fetchMoreResult: fetchMoreResult.data,
|
|
434
|
+
variables: combinedOptions.variables,
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
cache.writeQuery({
|
|
440
|
+
query: combinedOptions.query,
|
|
428
441
|
variables: combinedOptions.variables,
|
|
442
|
+
data: fetchMoreResult.data,
|
|
429
443
|
});
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
onWatchUpdated: function (watch) {
|
|
447
|
+
updatedQuerySet.add(watch.query);
|
|
448
|
+
},
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
var lastResult = _this.getLast("result");
|
|
453
|
+
var data = updateQuery(lastResult.data, {
|
|
454
|
+
fetchMoreResult: fetchMoreResult.data,
|
|
455
|
+
variables: combinedOptions.variables,
|
|
456
|
+
});
|
|
457
|
+
_this.reportResult(tslib.__assign(tslib.__assign({}, lastResult), { data: data }), _this.variables);
|
|
458
|
+
}
|
|
444
459
|
return fetchMoreResult;
|
|
445
460
|
})
|
|
446
461
|
.finally(function () {
|
|
447
|
-
if (!updatedQuerySet.has(_this.query)) {
|
|
462
|
+
if (isCached && !updatedQuerySet.has(_this.query)) {
|
|
448
463
|
reobserveCacheFirst(_this);
|
|
449
464
|
}
|
|
450
465
|
});
|
|
@@ -475,7 +490,7 @@ var ObservableQuery = (function (_super) {
|
|
|
475
490
|
options.onError(err);
|
|
476
491
|
return;
|
|
477
492
|
}
|
|
478
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
493
|
+
globalThis.__DEV__ !== false && globals.invariant.error(22, err);
|
|
479
494
|
},
|
|
480
495
|
});
|
|
481
496
|
this.subscriptions.add(subscription);
|
|
@@ -575,7 +590,7 @@ var ObservableQuery = (function (_super) {
|
|
|
575
590
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
576
591
|
return;
|
|
577
592
|
}
|
|
578
|
-
globals.invariant(pollInterval,
|
|
593
|
+
globals.invariant(pollInterval, 23);
|
|
579
594
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
580
595
|
info.interval = pollInterval;
|
|
581
596
|
var maybeFetch = function () {
|
|
@@ -659,6 +674,9 @@ var ObservableQuery = (function (_super) {
|
|
|
659
674
|
},
|
|
660
675
|
error: function (error) {
|
|
661
676
|
if (equal.equal(_this.variables, variables)) {
|
|
677
|
+
if (!errors.isApolloError(error)) {
|
|
678
|
+
error = new errors.ApolloError({ networkError: error });
|
|
679
|
+
}
|
|
662
680
|
finishWaitingForOwnResult();
|
|
663
681
|
_this.reportError(error, variables);
|
|
664
682
|
}
|
|
@@ -749,11 +767,11 @@ function reobserveCacheFirst(obsQuery) {
|
|
|
749
767
|
return obsQuery.reobserve();
|
|
750
768
|
}
|
|
751
769
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
752
|
-
globalThis.__DEV__ !== false && globals.invariant.error(
|
|
770
|
+
globalThis.__DEV__ !== false && globals.invariant.error(24, error.message, error.stack);
|
|
753
771
|
}
|
|
754
772
|
function logMissingFieldErrors(missing) {
|
|
755
773
|
if (globalThis.__DEV__ !== false && missing) {
|
|
756
|
-
globalThis.__DEV__ !== false && globals.invariant.debug(
|
|
774
|
+
globalThis.__DEV__ !== false && globals.invariant.debug(25, missing);
|
|
757
775
|
}
|
|
758
776
|
}
|
|
759
777
|
function skipCacheDataFor(fetchPolicy ) {
|
|
@@ -1081,7 +1099,7 @@ var QueryManager = (function () {
|
|
|
1081
1099
|
this.queries.forEach(function (_info, queryId) {
|
|
1082
1100
|
_this.stopQueryNoBroadcast(queryId);
|
|
1083
1101
|
});
|
|
1084
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1102
|
+
this.cancelPendingFetches(globals.newInvariantError(26));
|
|
1085
1103
|
};
|
|
1086
1104
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
1087
1105
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -1095,8 +1113,8 @@ var QueryManager = (function () {
|
|
|
1095
1113
|
return tslib.__generator(this, function (_j) {
|
|
1096
1114
|
switch (_j.label) {
|
|
1097
1115
|
case 0:
|
|
1098
|
-
globals.invariant(mutation,
|
|
1099
|
-
globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache",
|
|
1116
|
+
globals.invariant(mutation, 27);
|
|
1117
|
+
globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 28);
|
|
1100
1118
|
mutationId = this.generateMutationId();
|
|
1101
1119
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
1102
1120
|
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
@@ -1418,10 +1436,10 @@ var QueryManager = (function () {
|
|
|
1418
1436
|
QueryManager.prototype.query = function (options, queryId) {
|
|
1419
1437
|
var _this = this;
|
|
1420
1438
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
1421
|
-
globals.invariant(options.query,
|
|
1422
|
-
globals.invariant(options.query.kind === "Document",
|
|
1423
|
-
globals.invariant(!options.returnPartialData,
|
|
1424
|
-
globals.invariant(!options.pollInterval,
|
|
1439
|
+
globals.invariant(options.query, 29);
|
|
1440
|
+
globals.invariant(options.query.kind === "Document", 30);
|
|
1441
|
+
globals.invariant(!options.returnPartialData, 31);
|
|
1442
|
+
globals.invariant(!options.pollInterval, 32);
|
|
1425
1443
|
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
|
|
1426
1444
|
};
|
|
1427
1445
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -1446,7 +1464,7 @@ var QueryManager = (function () {
|
|
|
1446
1464
|
if (options === void 0) { options = {
|
|
1447
1465
|
discardWatches: true,
|
|
1448
1466
|
}; }
|
|
1449
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1467
|
+
this.cancelPendingFetches(globals.newInvariantError(33));
|
|
1450
1468
|
this.queries.forEach(function (queryInfo) {
|
|
1451
1469
|
if (queryInfo.observableQuery) {
|
|
1452
1470
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -1522,7 +1540,7 @@ var QueryManager = (function () {
|
|
|
1522
1540
|
if (globalThis.__DEV__ !== false && queryNamesAndDocs.size) {
|
|
1523
1541
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
1524
1542
|
if (!included) {
|
|
1525
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(typeof nameOrDoc === "string" ?
|
|
1543
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(typeof nameOrDoc === "string" ? 34 : 35, nameOrDoc);
|
|
1526
1544
|
}
|
|
1527
1545
|
});
|
|
1528
1546
|
}
|
|
@@ -1680,8 +1698,9 @@ var QueryManager = (function () {
|
|
|
1680
1698
|
return utilities.asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
|
|
1681
1699
|
var graphQLErrors = utilities.getGraphQLErrorsFromResult(result);
|
|
1682
1700
|
var hasErrors = graphQLErrors.length > 0;
|
|
1701
|
+
var errorPolicy = options.errorPolicy;
|
|
1683
1702
|
if (requestId >= queryInfo.lastRequestId) {
|
|
1684
|
-
if (hasErrors &&
|
|
1703
|
+
if (hasErrors && errorPolicy === "none") {
|
|
1685
1704
|
throw queryInfo.markError(new errors.ApolloError({
|
|
1686
1705
|
graphQLErrors: graphQLErrors,
|
|
1687
1706
|
}));
|
|
@@ -1694,7 +1713,10 @@ var QueryManager = (function () {
|
|
|
1694
1713
|
loading: false,
|
|
1695
1714
|
networkStatus: exports.NetworkStatus.ready,
|
|
1696
1715
|
};
|
|
1697
|
-
if (hasErrors &&
|
|
1716
|
+
if (hasErrors && errorPolicy === "none") {
|
|
1717
|
+
aqr.data = void 0;
|
|
1718
|
+
}
|
|
1719
|
+
if (hasErrors && errorPolicy !== "ignore") {
|
|
1698
1720
|
aqr.errors = graphQLErrors;
|
|
1699
1721
|
aqr.networkStatus = exports.NetworkStatus.error;
|
|
1700
1722
|
}
|