@apollo/client 3.7.2 → 3.7.3
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/apollo-client.cjs +103 -48
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +8 -17
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +52 -27
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +147 -44
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +147 -44
- package/invariantErrorCodes.js +1 -1
- package/package.json +8 -6
- package/utilities/common/errorHandling.d.ts +3 -2
- package/utilities/common/errorHandling.d.ts.map +1 -1
- package/utilities/common/errorHandling.js +18 -1
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/incrementalResult.d.ts +5 -2
- package/utilities/common/incrementalResult.d.ts.map +1 -1
- package/utilities/common/incrementalResult.js +29 -1
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/utilities.cjs +21 -1
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +21 -1
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -1053,8 +1053,53 @@ function isNonEmptyArray(value) {
|
|
|
1053
1053
|
return Array.isArray(value) && value.length > 0;
|
|
1054
1054
|
}
|
|
1055
1055
|
|
|
1056
|
+
function isExecutionPatchIncrementalResult(value) {
|
|
1057
|
+
return "incremental" in value;
|
|
1058
|
+
}
|
|
1059
|
+
function isExecutionPatchInitialResult(value) {
|
|
1060
|
+
return "hasNext" in value && "data" in value;
|
|
1061
|
+
}
|
|
1062
|
+
function isExecutionPatchResult(value) {
|
|
1063
|
+
return (isExecutionPatchIncrementalResult(value) ||
|
|
1064
|
+
isExecutionPatchInitialResult(value));
|
|
1065
|
+
}
|
|
1066
|
+
function mergeIncrementalData(prevResult, result) {
|
|
1067
|
+
var mergedData = prevResult;
|
|
1068
|
+
var merger = new DeepMerger();
|
|
1069
|
+
if (isExecutionPatchIncrementalResult(result) &&
|
|
1070
|
+
isNonEmptyArray(result.incremental)) {
|
|
1071
|
+
result.incremental.forEach(function (_a) {
|
|
1072
|
+
var data = _a.data, path = _a.path;
|
|
1073
|
+
for (var i = path.length - 1; i >= 0; --i) {
|
|
1074
|
+
var key = path[i];
|
|
1075
|
+
var isNumericKey = !isNaN(+key);
|
|
1076
|
+
var parent_1 = isNumericKey ? [] : {};
|
|
1077
|
+
parent_1[key] = data;
|
|
1078
|
+
data = parent_1;
|
|
1079
|
+
}
|
|
1080
|
+
mergedData = merger.merge(mergedData, data);
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
return mergedData;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1056
1086
|
function graphQLResultHasError(result) {
|
|
1057
|
-
|
|
1087
|
+
var errors = getGraphQLErrorsFromResult(result);
|
|
1088
|
+
return isNonEmptyArray(errors);
|
|
1089
|
+
}
|
|
1090
|
+
function getGraphQLErrorsFromResult(result) {
|
|
1091
|
+
var graphQLErrors = isNonEmptyArray(result.errors)
|
|
1092
|
+
? result.errors.slice(0)
|
|
1093
|
+
: [];
|
|
1094
|
+
if (isExecutionPatchIncrementalResult(result) &&
|
|
1095
|
+
isNonEmptyArray(result.incremental)) {
|
|
1096
|
+
result.incremental.forEach(function (incrementalResult) {
|
|
1097
|
+
if (incrementalResult.errors) {
|
|
1098
|
+
graphQLErrors.push.apply(graphQLErrors, incrementalResult.errors);
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
return graphQLErrors;
|
|
1058
1103
|
}
|
|
1059
1104
|
|
|
1060
1105
|
function compact() {
|
|
@@ -1300,7 +1345,7 @@ var concat = ApolloLink.concat;
|
|
|
1300
1345
|
|
|
1301
1346
|
var execute = ApolloLink.execute;
|
|
1302
1347
|
|
|
1303
|
-
var version = '3.7.
|
|
1348
|
+
var version = '3.7.3';
|
|
1304
1349
|
|
|
1305
1350
|
function isNodeResponse(value) {
|
|
1306
1351
|
return !!value.body;
|
|
@@ -1881,10 +1926,6 @@ var HttpLink = (function (_super) {
|
|
|
1881
1926
|
return HttpLink;
|
|
1882
1927
|
}(ApolloLink));
|
|
1883
1928
|
|
|
1884
|
-
function isExecutionPatchIncrementalResult(value) {
|
|
1885
|
-
return !!value.incremental;
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
1929
|
var ApolloCache = (function () {
|
|
1889
1930
|
function ApolloCache() {
|
|
1890
1931
|
this.getFragmentDoc = optimism.wrap(getFragmentQueryDocument);
|
|
@@ -5175,28 +5216,18 @@ var QueryInfo = (function () {
|
|
|
5175
5216
|
};
|
|
5176
5217
|
QueryInfo.prototype.markResult = function (result, document, options, cacheWriteBehavior) {
|
|
5177
5218
|
var _this = this;
|
|
5219
|
+
var merger = new DeepMerger();
|
|
5178
5220
|
var graphQLErrors = isNonEmptyArray(result.errors)
|
|
5179
5221
|
? result.errors.slice(0)
|
|
5180
5222
|
: [];
|
|
5181
5223
|
this.reset();
|
|
5182
5224
|
if ('incremental' in result && isNonEmptyArray(result.incremental)) {
|
|
5183
|
-
var
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
var isNumericKey = !isNaN(+key);
|
|
5190
|
-
var parent_1 = isNumericKey ? [] : {};
|
|
5191
|
-
parent_1[key] = data;
|
|
5192
|
-
data = parent_1;
|
|
5193
|
-
}
|
|
5194
|
-
if (errors) {
|
|
5195
|
-
graphQLErrors.push.apply(graphQLErrors, errors);
|
|
5196
|
-
}
|
|
5197
|
-
mergedData_1 = merger_1.merge(mergedData_1, data);
|
|
5198
|
-
});
|
|
5199
|
-
result.data = mergedData_1;
|
|
5225
|
+
var mergedData = mergeIncrementalData(this.getDiff().result, result);
|
|
5226
|
+
result.data = mergedData;
|
|
5227
|
+
}
|
|
5228
|
+
else if ('hasNext' in result && result.hasNext) {
|
|
5229
|
+
var diff = this.getDiff();
|
|
5230
|
+
result.data = merger.merge(diff.result, result.data);
|
|
5200
5231
|
}
|
|
5201
5232
|
this.graphQLErrors = graphQLErrors;
|
|
5202
5233
|
if (options.fetchPolicy === 'no-cache') {
|
|
@@ -5353,7 +5384,7 @@ var QueryManager = (function () {
|
|
|
5353
5384
|
return asyncMap(self.getObservableFromLink(mutation, tslib.__assign(tslib.__assign({}, context), { optimisticResponse: optimisticResponse }), variables, false), function (result) {
|
|
5354
5385
|
if (graphQLResultHasError(result) && errorPolicy === 'none') {
|
|
5355
5386
|
throw new ApolloError({
|
|
5356
|
-
graphQLErrors: result
|
|
5387
|
+
graphQLErrors: getGraphQLErrorsFromResult(result),
|
|
5357
5388
|
});
|
|
5358
5389
|
}
|
|
5359
5390
|
if (mutationStoreValue) {
|
|
@@ -5387,7 +5418,9 @@ var QueryManager = (function () {
|
|
|
5387
5418
|
}).subscribe({
|
|
5388
5419
|
next: function (storeResult) {
|
|
5389
5420
|
self.broadcastQueries();
|
|
5390
|
-
|
|
5421
|
+
if (!('hasNext' in storeResult) || storeResult.hasNext === false) {
|
|
5422
|
+
resolve(storeResult);
|
|
5423
|
+
}
|
|
5391
5424
|
},
|
|
5392
5425
|
error: function (err) {
|
|
5393
5426
|
if (mutationStoreValue) {
|
|
@@ -5415,12 +5448,33 @@ var QueryManager = (function () {
|
|
|
5415
5448
|
var cacheWrites = [];
|
|
5416
5449
|
var skipCache = mutation.fetchPolicy === "no-cache";
|
|
5417
5450
|
if (!skipCache && shouldWriteResult(result, mutation.errorPolicy)) {
|
|
5418
|
-
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5451
|
+
if (!isExecutionPatchIncrementalResult(result)) {
|
|
5452
|
+
cacheWrites.push({
|
|
5453
|
+
result: result.data,
|
|
5454
|
+
dataId: 'ROOT_MUTATION',
|
|
5455
|
+
query: mutation.document,
|
|
5456
|
+
variables: mutation.variables,
|
|
5457
|
+
});
|
|
5458
|
+
}
|
|
5459
|
+
if (isExecutionPatchIncrementalResult(result) && isNonEmptyArray(result.incremental)) {
|
|
5460
|
+
var diff = cache.diff({
|
|
5461
|
+
id: "ROOT_MUTATION",
|
|
5462
|
+
query: this.transform(mutation.document).asQuery,
|
|
5463
|
+
variables: mutation.variables,
|
|
5464
|
+
optimistic: false,
|
|
5465
|
+
returnPartialData: true,
|
|
5466
|
+
});
|
|
5467
|
+
var mergedData = mergeIncrementalData(diff.result, result);
|
|
5468
|
+
if (typeof mergedData !== 'undefined') {
|
|
5469
|
+
result.data = mergedData;
|
|
5470
|
+
cacheWrites.push({
|
|
5471
|
+
result: mergedData,
|
|
5472
|
+
dataId: 'ROOT_MUTATION',
|
|
5473
|
+
query: mutation.document,
|
|
5474
|
+
variables: mutation.variables,
|
|
5475
|
+
});
|
|
5476
|
+
}
|
|
5477
|
+
}
|
|
5424
5478
|
var updateQueries_1 = mutation.updateQueries;
|
|
5425
5479
|
if (updateQueries_1) {
|
|
5426
5480
|
this.queries.forEach(function (_a, queryId) {
|
|
@@ -5467,6 +5521,8 @@ var QueryManager = (function () {
|
|
|
5467
5521
|
cacheWrites.forEach(function (write) { return cache.write(write); });
|
|
5468
5522
|
}
|
|
5469
5523
|
var update = mutation.update;
|
|
5524
|
+
var isFinalResult = !isExecutionPatchResult(result) ||
|
|
5525
|
+
(isExecutionPatchIncrementalResult(result) && !result.hasNext);
|
|
5470
5526
|
if (update) {
|
|
5471
5527
|
if (!skipCache) {
|
|
5472
5528
|
var diff = cache.diff({
|
|
@@ -5476,16 +5532,24 @@ var QueryManager = (function () {
|
|
|
5476
5532
|
optimistic: false,
|
|
5477
5533
|
returnPartialData: true,
|
|
5478
5534
|
});
|
|
5479
|
-
if (diff.complete
|
|
5535
|
+
if (diff.complete) {
|
|
5480
5536
|
result = tslib.__assign(tslib.__assign({}, result), { data: diff.result });
|
|
5537
|
+
if ('incremental' in result) {
|
|
5538
|
+
delete result.incremental;
|
|
5539
|
+
}
|
|
5540
|
+
if ('hasNext' in result) {
|
|
5541
|
+
delete result.hasNext;
|
|
5542
|
+
}
|
|
5481
5543
|
}
|
|
5482
5544
|
}
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5545
|
+
if (isFinalResult) {
|
|
5546
|
+
update(cache, result, {
|
|
5547
|
+
context: mutation.context,
|
|
5548
|
+
variables: mutation.variables,
|
|
5549
|
+
});
|
|
5550
|
+
}
|
|
5487
5551
|
}
|
|
5488
|
-
if (!skipCache && !mutation.keepRootFields) {
|
|
5552
|
+
if (!skipCache && !mutation.keepRootFields && isFinalResult) {
|
|
5489
5553
|
cache.modify({
|
|
5490
5554
|
id: 'ROOT_MUTATION',
|
|
5491
5555
|
fields: function (value, _a) {
|
|
@@ -5853,17 +5917,8 @@ var QueryManager = (function () {
|
|
|
5853
5917
|
var requestId = queryInfo.lastRequestId = this.generateRequestId();
|
|
5854
5918
|
var linkDocument = this.cache.transformForLink(this.transform(queryInfo.document).document);
|
|
5855
5919
|
return asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
|
|
5856
|
-
var graphQLErrors =
|
|
5857
|
-
|
|
5858
|
-
: [];
|
|
5859
|
-
if ('incremental' in result && isNonEmptyArray(result.incremental)) {
|
|
5860
|
-
result.incremental.forEach(function (incrementalResult) {
|
|
5861
|
-
if (incrementalResult.errors) {
|
|
5862
|
-
graphQLErrors.push.apply(graphQLErrors, incrementalResult.errors);
|
|
5863
|
-
}
|
|
5864
|
-
});
|
|
5865
|
-
}
|
|
5866
|
-
var hasErrors = isNonEmptyArray(graphQLErrors);
|
|
5920
|
+
var graphQLErrors = getGraphQLErrorsFromResult(result);
|
|
5921
|
+
var hasErrors = graphQLErrors.length > 0;
|
|
5867
5922
|
if (requestId >= queryInfo.lastRequestId) {
|
|
5868
5923
|
if (hasErrors && options.errorPolicy === "none") {
|
|
5869
5924
|
throw queryInfo.markError(new ApolloError({
|