@apollo/client 3.7.0-beta.6 → 3.7.0-beta.7
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/README.md +2 -0
- package/apollo-client.cjs +385 -78
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +15 -11
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +15 -11
- package/cache/core/types/common.d.ts +1 -1
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js +16 -11
- package/cache/core/types/common.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +24 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +15 -4
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +43 -8
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +43 -8
- package/core/types.d.ts.map +1 -1
- package/core/types.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/link/core/types.d.ts +30 -5
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js +0 -1
- package/link/core/types.js.map +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +14 -17
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +314 -44
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +314 -44
- package/link/http/iterators/async.d.ts +2 -0
- package/link/http/iterators/async.d.ts.map +1 -0
- package/link/http/iterators/async.js +14 -0
- package/link/http/iterators/async.js.map +1 -0
- package/link/http/iterators/nodeStream.d.ts +4 -0
- package/link/http/iterators/nodeStream.d.ts.map +1 -0
- package/link/http/iterators/nodeStream.js +71 -0
- package/link/http/iterators/nodeStream.js.map +1 -0
- package/link/http/iterators/promise.d.ts +2 -0
- package/link/http/iterators/promise.d.ts.map +1 -0
- package/link/http/iterators/promise.js +28 -0
- package/link/http/iterators/promise.js.map +1 -0
- package/link/http/iterators/reader.d.ts +2 -0
- package/link/http/iterators/reader.d.ts.map +1 -0
- package/link/http/iterators/reader.js +15 -0
- package/link/http/iterators/reader.js.map +1 -0
- package/link/http/parseAndCheckHttpResponse.d.ts +7 -1
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +131 -27
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.d.ts +3 -0
- package/link/http/responseIterator.d.ts.map +1 -0
- package/link/http/responseIterator.js +23 -0
- package/link/http/responseIterator.js.map +1 -0
- package/package.json +38 -27
- package/react/hooks/hooks.cjs +15 -10
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +15 -10
- package/react/hooks/useFragment.d.ts +1 -1
- package/react/hooks/useFragment.d.ts.map +1 -1
- package/react/hooks/useFragment.js +6 -3
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +8 -6
- package/react/hooks/useMutation.js.map +1 -1
- package/react/types/types.d.ts +2 -2
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/itAsync.d.ts +3 -3
- package/testing/core/itAsync.d.ts.map +1 -1
- package/testing/core/subscribeAndCount.d.ts +2 -3
- package/testing/core/subscribeAndCount.d.ts.map +1 -1
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/utilities/common/canUse.d.ts +1 -0
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +1 -0
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/incrementalResult.d.ts +3 -0
- package/utilities/common/incrementalResult.d.ts.map +1 -0
- package/utilities/common/incrementalResult.js +4 -0
- package/utilities/common/incrementalResult.js.map +1 -0
- package/utilities/common/responseIterator.d.ts +10 -0
- package/utilities/common/responseIterator.d.ts.map +1 -0
- package/utilities/common/responseIterator.js +21 -0
- package/utilities/common/responseIterator.js.map +1 -0
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +11 -2
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +1 -1
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/utilities.cjs +12 -1
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +12 -1
- package/version.js +1 -1
package/README.md
CHANGED
|
@@ -23,8 +23,10 @@ Learn how to use Apollo Client with self-paced hands-on training on Odyssey, Apo
|
|
|
23
23
|
|
|
24
24
|
- [@benjamn](https://github.com/benjamn)
|
|
25
25
|
- [@alessbell](https://github.com/alessbell)
|
|
26
|
+
- [@bignimbus](https://github.com/bignimbus)
|
|
26
27
|
- [@hwillson](https://github.com/hwillson)
|
|
27
28
|
- [@jpvajda](https://github.com/jpvajda)
|
|
29
|
+
- [@mrdoombringer](https://github.com/mrdoombringer)
|
|
28
30
|
|
|
29
31
|
## Who is Apollo?
|
|
30
32
|
|
package/apollo-client.cjs
CHANGED
|
@@ -53,17 +53,17 @@ function shouldInclude(_a, variables) {
|
|
|
53
53
|
return directive.name.value === 'skip' ? !evaledValue : evaledValue;
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
var
|
|
56
|
+
function hasDirectives(names, root) {
|
|
57
|
+
var nameSet = new Set(names);
|
|
58
|
+
var nameCount = nameSet.size;
|
|
58
59
|
graphql.visit(root, {
|
|
59
60
|
Directive: function (node) {
|
|
60
|
-
|
|
61
|
+
if (nameSet.delete(node.name.value)) {
|
|
62
|
+
return graphql.BREAK;
|
|
63
|
+
}
|
|
61
64
|
},
|
|
62
65
|
});
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
function hasDirectives(names, root) {
|
|
66
|
-
return getDirectiveNames(root).some(function (name) { return names.indexOf(name) > -1; });
|
|
66
|
+
return nameSet.size < nameCount;
|
|
67
67
|
}
|
|
68
68
|
function hasClientExports(document) {
|
|
69
69
|
return (document &&
|
|
@@ -900,6 +900,7 @@ var canUseWeakMap = typeof WeakMap === 'function' &&
|
|
|
900
900
|
var canUseWeakSet = typeof WeakSet === 'function';
|
|
901
901
|
var canUseSymbol = typeof Symbol === 'function' &&
|
|
902
902
|
typeof Symbol.for === 'function';
|
|
903
|
+
var canUseAsyncIteratorSymbol = canUseSymbol && Symbol.asyncIterator;
|
|
903
904
|
var canUseDOM = typeof maybe(function () { return window.document.createElement; }) === "function";
|
|
904
905
|
var usingJSDOM = maybe(function () { return navigator.userAgent.indexOf("jsdom") >= 0; }) || false;
|
|
905
906
|
var canUseLayoutEffect = canUseDOM && !usingJSDOM;
|
|
@@ -1298,38 +1299,303 @@ var concat = ApolloLink.concat;
|
|
|
1298
1299
|
|
|
1299
1300
|
var execute = ApolloLink.execute;
|
|
1300
1301
|
|
|
1301
|
-
var version = '3.7.0-beta.
|
|
1302
|
+
var version = '3.7.0-beta.7';
|
|
1302
1303
|
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1304
|
+
function isNodeResponse(value) {
|
|
1305
|
+
return !!value.body;
|
|
1306
|
+
}
|
|
1307
|
+
function isReadableStream(value) {
|
|
1308
|
+
return !!value.getReader;
|
|
1309
|
+
}
|
|
1310
|
+
function isAsyncIterableIterator(value) {
|
|
1311
|
+
return !!(canUseAsyncIteratorSymbol &&
|
|
1312
|
+
value[Symbol.asyncIterator]);
|
|
1313
|
+
}
|
|
1314
|
+
function isStreamableBlob(value) {
|
|
1315
|
+
return !!value.stream;
|
|
1316
|
+
}
|
|
1317
|
+
function isBlob(value) {
|
|
1318
|
+
return !!value.arrayBuffer;
|
|
1319
|
+
}
|
|
1320
|
+
function isNodeReadableStream(value) {
|
|
1321
|
+
return !!value.pipe;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
function asyncIterator(source) {
|
|
1325
|
+
var _a;
|
|
1326
|
+
var iterator = source[Symbol.asyncIterator]();
|
|
1327
|
+
return _a = {
|
|
1328
|
+
next: function () {
|
|
1329
|
+
return iterator.next();
|
|
1330
|
+
}
|
|
1331
|
+
},
|
|
1332
|
+
_a[Symbol.asyncIterator] = function () {
|
|
1333
|
+
return this;
|
|
1334
|
+
},
|
|
1335
|
+
_a;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
function nodeStreamIterator(stream) {
|
|
1339
|
+
var cleanup = null;
|
|
1340
|
+
var error = null;
|
|
1341
|
+
var done = false;
|
|
1342
|
+
var data = [];
|
|
1343
|
+
var waiting = [];
|
|
1344
|
+
function onData(chunk) {
|
|
1345
|
+
if (error)
|
|
1346
|
+
return;
|
|
1347
|
+
if (waiting.length) {
|
|
1348
|
+
var shiftedArr = waiting.shift();
|
|
1349
|
+
if (Array.isArray(shiftedArr) && shiftedArr[0]) {
|
|
1350
|
+
return shiftedArr[0]({ value: chunk, done: false });
|
|
1351
|
+
}
|
|
1310
1352
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1353
|
+
data.push(chunk);
|
|
1354
|
+
}
|
|
1355
|
+
function onError(err) {
|
|
1356
|
+
error = err;
|
|
1357
|
+
var all = waiting.slice();
|
|
1358
|
+
all.forEach(function (pair) {
|
|
1359
|
+
pair[1](err);
|
|
1360
|
+
});
|
|
1361
|
+
!cleanup || cleanup();
|
|
1362
|
+
}
|
|
1363
|
+
function onEnd() {
|
|
1364
|
+
done = true;
|
|
1365
|
+
var all = waiting.slice();
|
|
1366
|
+
all.forEach(function (pair) {
|
|
1367
|
+
pair[0]({ value: undefined, done: true });
|
|
1368
|
+
});
|
|
1369
|
+
!cleanup || cleanup();
|
|
1370
|
+
}
|
|
1371
|
+
cleanup = function () {
|
|
1372
|
+
cleanup = null;
|
|
1373
|
+
stream.removeListener("data", onData);
|
|
1374
|
+
stream.removeListener("error", onError);
|
|
1375
|
+
stream.removeListener("end", onEnd);
|
|
1376
|
+
stream.removeListener("finish", onEnd);
|
|
1377
|
+
stream.removeListener("close", onEnd);
|
|
1378
|
+
};
|
|
1379
|
+
stream.on("data", onData);
|
|
1380
|
+
stream.on("error", onError);
|
|
1381
|
+
stream.on("end", onEnd);
|
|
1382
|
+
stream.on("finish", onEnd);
|
|
1383
|
+
stream.on("close", onEnd);
|
|
1384
|
+
function getNext() {
|
|
1385
|
+
return new Promise(function (resolve, reject) {
|
|
1386
|
+
if (error)
|
|
1387
|
+
return reject(error);
|
|
1388
|
+
if (data.length)
|
|
1389
|
+
return resolve({ value: data.shift(), done: false });
|
|
1390
|
+
if (done)
|
|
1391
|
+
return resolve({ value: undefined, done: true });
|
|
1392
|
+
waiting.push([resolve, reject]);
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
var iterator = {
|
|
1396
|
+
next: function () {
|
|
1397
|
+
return getNext();
|
|
1398
|
+
},
|
|
1399
|
+
};
|
|
1400
|
+
if (canUseAsyncIteratorSymbol) {
|
|
1401
|
+
iterator[Symbol.asyncIterator] = function () {
|
|
1402
|
+
return this;
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
return iterator;
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
function promiseIterator(promise) {
|
|
1409
|
+
var resolved = false;
|
|
1410
|
+
var iterator = {
|
|
1411
|
+
next: function () {
|
|
1412
|
+
if (resolved)
|
|
1413
|
+
return Promise.resolve({
|
|
1414
|
+
value: undefined,
|
|
1415
|
+
done: true,
|
|
1416
|
+
});
|
|
1417
|
+
resolved = true;
|
|
1418
|
+
return new Promise(function (resolve, reject) {
|
|
1419
|
+
promise
|
|
1420
|
+
.then(function (value) {
|
|
1421
|
+
resolve({ value: value, done: false });
|
|
1422
|
+
})
|
|
1423
|
+
.catch(reject);
|
|
1424
|
+
});
|
|
1425
|
+
},
|
|
1426
|
+
};
|
|
1427
|
+
if (canUseAsyncIteratorSymbol) {
|
|
1428
|
+
iterator[Symbol.asyncIterator] = function () {
|
|
1429
|
+
return this;
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
return iterator;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
function readerIterator(reader) {
|
|
1436
|
+
var iterator = {
|
|
1437
|
+
next: function () {
|
|
1438
|
+
return reader.read();
|
|
1439
|
+
},
|
|
1440
|
+
};
|
|
1441
|
+
if (canUseAsyncIteratorSymbol) {
|
|
1442
|
+
iterator[Symbol.asyncIterator] = function () {
|
|
1443
|
+
return this;
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
return iterator;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
function responseIterator(response) {
|
|
1450
|
+
var body = response;
|
|
1451
|
+
if (isNodeResponse(response))
|
|
1452
|
+
body = response.body;
|
|
1453
|
+
if (isAsyncIterableIterator(body))
|
|
1454
|
+
return asyncIterator(body);
|
|
1455
|
+
if (isReadableStream(body))
|
|
1456
|
+
return readerIterator(body.getReader());
|
|
1457
|
+
if (isStreamableBlob(body)) {
|
|
1458
|
+
return readerIterator(body.stream().getReader());
|
|
1459
|
+
}
|
|
1460
|
+
if (isBlob(body))
|
|
1461
|
+
return promiseIterator(body.arrayBuffer());
|
|
1462
|
+
if (isNodeReadableStream(body))
|
|
1463
|
+
return nodeStreamIterator(body);
|
|
1464
|
+
throw new Error("Unknown body type for responseIterator. Please pass a streamable response.");
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1468
|
+
function readMultipartBody(response, observer) {
|
|
1469
|
+
var _a, _b, _c;
|
|
1470
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1471
|
+
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _d, value, done, chunk, bi, message, i, headers, contentType_1, body, result;
|
|
1472
|
+
var _e;
|
|
1473
|
+
return tslib.__generator(this, function (_f) {
|
|
1474
|
+
switch (_f.label) {
|
|
1475
|
+
case 0:
|
|
1476
|
+
if (TextDecoder === undefined) {
|
|
1477
|
+
throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");
|
|
1478
|
+
}
|
|
1479
|
+
decoder = new TextDecoder("utf-8");
|
|
1480
|
+
contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get('content-type');
|
|
1481
|
+
delimiter = "boundary=";
|
|
1482
|
+
boundaryVal = (contentType === null || contentType === void 0 ? void 0 : contentType.includes(delimiter))
|
|
1483
|
+
? contentType === null || contentType === void 0 ? void 0 : contentType.substring((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf(delimiter)) + delimiter.length).replace(/['"]/g, "").replace(/\;(.*)/gm, "").trim()
|
|
1484
|
+
: "-";
|
|
1485
|
+
boundary = "--".concat(boundaryVal);
|
|
1486
|
+
buffer = "";
|
|
1487
|
+
iterator = responseIterator(response);
|
|
1488
|
+
running = true;
|
|
1489
|
+
_f.label = 1;
|
|
1490
|
+
case 1:
|
|
1491
|
+
if (!running) return [3, 3];
|
|
1492
|
+
return [4, iterator.next()];
|
|
1493
|
+
case 2:
|
|
1494
|
+
_d = _f.sent(), value = _d.value, done = _d.done;
|
|
1495
|
+
chunk = typeof value === "string" ? value : decoder.decode(value);
|
|
1496
|
+
running = !done;
|
|
1497
|
+
buffer += chunk;
|
|
1498
|
+
bi = buffer.indexOf(boundary);
|
|
1499
|
+
while (bi > -1) {
|
|
1500
|
+
message = void 0;
|
|
1501
|
+
_e = [
|
|
1502
|
+
buffer.slice(0, bi),
|
|
1503
|
+
buffer.slice(bi + boundary.length),
|
|
1504
|
+
], message = _e[0], buffer = _e[1];
|
|
1505
|
+
if (message.trim()) {
|
|
1506
|
+
i = message.indexOf("\r\n\r\n");
|
|
1507
|
+
headers = parseHeaders(message.slice(0, i));
|
|
1508
|
+
contentType_1 = headers["content-type"];
|
|
1509
|
+
if (contentType_1 &&
|
|
1510
|
+
contentType_1.toLowerCase().indexOf("application/json") === -1) {
|
|
1511
|
+
throw new Error("Unsupported patch content type: application/json is required.");
|
|
1512
|
+
}
|
|
1513
|
+
body = message.slice(i);
|
|
1514
|
+
try {
|
|
1515
|
+
result = parseJsonBody(response, body.replace("\r\n", ""));
|
|
1516
|
+
if (Object.keys(result).length > 1 ||
|
|
1517
|
+
"data" in result ||
|
|
1518
|
+
"incremental" in result ||
|
|
1519
|
+
"errors" in result) {
|
|
1520
|
+
(_b = observer.next) === null || _b === void 0 ? void 0 : _b.call(observer, result);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
catch (err) {
|
|
1524
|
+
handleError(err, observer);
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
bi = buffer.indexOf(boundary);
|
|
1528
|
+
}
|
|
1529
|
+
return [3, 1];
|
|
1530
|
+
case 3:
|
|
1531
|
+
(_c = observer.complete) === null || _c === void 0 ? void 0 : _c.call(observer);
|
|
1532
|
+
return [2];
|
|
1533
|
+
}
|
|
1534
|
+
});
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
function parseHeaders(headerText) {
|
|
1538
|
+
var headersInit = {};
|
|
1539
|
+
headerText.split("\n").forEach(function (line) {
|
|
1540
|
+
var i = line.indexOf(":");
|
|
1541
|
+
if (i > -1) {
|
|
1542
|
+
var name_1 = line.slice(0, i).trim().toLowerCase();
|
|
1543
|
+
var value = line.slice(i + 1).trim();
|
|
1544
|
+
headersInit[name_1] = value;
|
|
1318
1545
|
}
|
|
1319
|
-
})
|
|
1546
|
+
});
|
|
1547
|
+
return headersInit;
|
|
1548
|
+
}
|
|
1549
|
+
function parseJsonBody(response, bodyText) {
|
|
1550
|
+
try {
|
|
1551
|
+
return JSON.parse(bodyText);
|
|
1552
|
+
}
|
|
1553
|
+
catch (err) {
|
|
1554
|
+
var parseError = err;
|
|
1555
|
+
parseError.name = "ServerParseError";
|
|
1556
|
+
parseError.response = response;
|
|
1557
|
+
parseError.statusCode = response.status;
|
|
1558
|
+
parseError.bodyText = bodyText;
|
|
1559
|
+
throw parseError;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
function handleError(err, observer) {
|
|
1563
|
+
var _a, _b;
|
|
1564
|
+
if (err.name === "AbortError")
|
|
1565
|
+
return;
|
|
1566
|
+
if (err.result && err.result.errors && err.result.data) {
|
|
1567
|
+
(_a = observer.next) === null || _a === void 0 ? void 0 : _a.call(observer, err.result);
|
|
1568
|
+
}
|
|
1569
|
+
(_b = observer.error) === null || _b === void 0 ? void 0 : _b.call(observer, err);
|
|
1570
|
+
}
|
|
1571
|
+
function readJsonBody(response, operation, observer) {
|
|
1572
|
+
parseAndCheckHttpResponse(operation)(response)
|
|
1320
1573
|
.then(function (result) {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1574
|
+
var _a, _b;
|
|
1575
|
+
(_a = observer.next) === null || _a === void 0 ? void 0 : _a.call(observer, result);
|
|
1576
|
+
(_b = observer.complete) === null || _b === void 0 ? void 0 : _b.call(observer);
|
|
1577
|
+
})
|
|
1578
|
+
.catch(function (err) { return handleError(err, observer); });
|
|
1579
|
+
}
|
|
1580
|
+
function parseAndCheckHttpResponse(operations) {
|
|
1581
|
+
return function (response) {
|
|
1582
|
+
return response
|
|
1583
|
+
.text()
|
|
1584
|
+
.then(function (bodyText) { return parseJsonBody(response, bodyText); })
|
|
1585
|
+
.then(function (result) {
|
|
1586
|
+
if (response.status >= 300) {
|
|
1587
|
+
throwServerError(response, result, "Response not successful: Received status code ".concat(response.status));
|
|
1588
|
+
}
|
|
1589
|
+
if (!Array.isArray(result) &&
|
|
1590
|
+
!hasOwnProperty$3.call(result, "data") &&
|
|
1591
|
+
!hasOwnProperty$3.call(result, "errors")) {
|
|
1592
|
+
throwServerError(response, result, "Server response was missing for query '".concat(Array.isArray(operations)
|
|
1593
|
+
? operations.map(function (op) { return op.operationName; })
|
|
1594
|
+
: operations.operationName, "'."));
|
|
1595
|
+
}
|
|
1596
|
+
return result;
|
|
1597
|
+
});
|
|
1598
|
+
};
|
|
1333
1599
|
}
|
|
1334
1600
|
|
|
1335
1601
|
var serializeFetchParameter = function (p, label) {
|
|
@@ -1541,6 +1807,9 @@ var createHttpLink = function (linkOptions) {
|
|
|
1541
1807
|
!operation.query.definitions.some(definitionIsMutation)) {
|
|
1542
1808
|
options.method = 'GET';
|
|
1543
1809
|
}
|
|
1810
|
+
if (hasDirectives(['defer'], operation.query)) {
|
|
1811
|
+
options.headers.accept = "multipart/mixed; deferSpec=20220824, application/json";
|
|
1812
|
+
}
|
|
1544
1813
|
if (options.method === 'GET') {
|
|
1545
1814
|
var _d = rewriteURIForGET(chosenURI, body), newURI = _d.newURI, parseError = _d.parseError;
|
|
1546
1815
|
if (parseError) {
|
|
@@ -1560,23 +1829,17 @@ var createHttpLink = function (linkOptions) {
|
|
|
1560
1829
|
var currentFetch = preferredFetch || maybe(function () { return fetch; }) || backupFetch;
|
|
1561
1830
|
currentFetch(chosenURI, options)
|
|
1562
1831
|
.then(function (response) {
|
|
1832
|
+
var _a;
|
|
1563
1833
|
operation.setContext({ response: response });
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
.then(function (result) {
|
|
1568
|
-
observer.next(result);
|
|
1569
|
-
observer.complete();
|
|
1570
|
-
return result;
|
|
1571
|
-
})
|
|
1572
|
-
.catch(function (err) {
|
|
1573
|
-
if (err.name === 'AbortError')
|
|
1574
|
-
return;
|
|
1575
|
-
if (err.result && err.result.errors && err.result.data) {
|
|
1576
|
-
observer.next(err.result);
|
|
1834
|
+
var ctype = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get('content-type');
|
|
1835
|
+
if (ctype !== null && /^multipart\/mixed/i.test(ctype)) {
|
|
1836
|
+
return readMultipartBody(response, observer);
|
|
1577
1837
|
}
|
|
1578
|
-
|
|
1579
|
-
|
|
1838
|
+
else {
|
|
1839
|
+
return readJsonBody(response, operation, observer);
|
|
1840
|
+
}
|
|
1841
|
+
})
|
|
1842
|
+
.catch(function (err) { return handleError(err, observer); });
|
|
1580
1843
|
return function () {
|
|
1581
1844
|
if (controller)
|
|
1582
1845
|
controller.abort();
|
|
@@ -1596,6 +1859,10 @@ var HttpLink = (function (_super) {
|
|
|
1596
1859
|
return HttpLink;
|
|
1597
1860
|
}(ApolloLink));
|
|
1598
1861
|
|
|
1862
|
+
function isExecutionPatchIncrementalResult(value) {
|
|
1863
|
+
return !!value.incremental;
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1599
1866
|
var ApolloCache = (function () {
|
|
1600
1867
|
function ApolloCache() {
|
|
1601
1868
|
this.getFragmentDoc = optimism.wrap(getFragmentQueryDocument);
|
|
@@ -1680,25 +1947,29 @@ exports.Cache = void 0;
|
|
|
1680
1947
|
(function (Cache) {
|
|
1681
1948
|
})(exports.Cache || (exports.Cache = {}));
|
|
1682
1949
|
|
|
1683
|
-
var MissingFieldError = (function () {
|
|
1950
|
+
var MissingFieldError = (function (_super) {
|
|
1951
|
+
tslib.__extends(MissingFieldError, _super);
|
|
1684
1952
|
function MissingFieldError(message, path, query, variables) {
|
|
1685
1953
|
var _a;
|
|
1686
|
-
this
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1954
|
+
var _this = _super.call(this, message) || this;
|
|
1955
|
+
_this.message = message;
|
|
1956
|
+
_this.path = path;
|
|
1957
|
+
_this.query = query;
|
|
1958
|
+
_this.variables = variables;
|
|
1959
|
+
if (Array.isArray(_this.path)) {
|
|
1960
|
+
_this.missing = _this.message;
|
|
1961
|
+
for (var i = _this.path.length - 1; i >= 0; --i) {
|
|
1962
|
+
_this.missing = (_a = {}, _a[_this.path[i]] = _this.missing, _a);
|
|
1694
1963
|
}
|
|
1695
1964
|
}
|
|
1696
1965
|
else {
|
|
1697
|
-
|
|
1966
|
+
_this.missing = _this.path;
|
|
1698
1967
|
}
|
|
1968
|
+
_this.__proto__ = MissingFieldError.prototype;
|
|
1969
|
+
return _this;
|
|
1699
1970
|
}
|
|
1700
1971
|
return MissingFieldError;
|
|
1701
|
-
}());
|
|
1972
|
+
}(Error));
|
|
1702
1973
|
|
|
1703
1974
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
1704
1975
|
function defaultDataIdFromObject(_a, context) {
|
|
@@ -4277,7 +4548,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4277
4548
|
if (_this.pollingInfo) {
|
|
4278
4549
|
if (!isNetworkRequestInFlight(_this.queryInfo.networkStatus)) {
|
|
4279
4550
|
_this.reobserve({
|
|
4280
|
-
fetchPolicy:
|
|
4551
|
+
fetchPolicy: _this.options.initialFetchPolicy === 'no-cache' ? 'no-cache' : 'network-only',
|
|
4281
4552
|
}, exports.NetworkStatus.poll).then(poll, poll);
|
|
4282
4553
|
}
|
|
4283
4554
|
else {
|
|
@@ -4736,7 +5007,6 @@ var QueryInfo = (function () {
|
|
|
4736
5007
|
};
|
|
4737
5008
|
QueryInfo.prototype.reset = function () {
|
|
4738
5009
|
cancelNotifyTimeout(this);
|
|
4739
|
-
this.lastDiff = void 0;
|
|
4740
5010
|
this.dirty = false;
|
|
4741
5011
|
};
|
|
4742
5012
|
QueryInfo.prototype.getDiff = function (variables) {
|
|
@@ -4868,8 +5138,30 @@ var QueryInfo = (function () {
|
|
|
4868
5138
|
};
|
|
4869
5139
|
QueryInfo.prototype.markResult = function (result, options, cacheWriteBehavior) {
|
|
4870
5140
|
var _this = this;
|
|
4871
|
-
|
|
5141
|
+
var graphQLErrors = isNonEmptyArray(result.errors)
|
|
5142
|
+
? result.errors.slice(0)
|
|
5143
|
+
: [];
|
|
4872
5144
|
this.reset();
|
|
5145
|
+
if ('incremental' in result && isNonEmptyArray(result.incremental)) {
|
|
5146
|
+
var mergedData_1 = this.getDiff().result;
|
|
5147
|
+
var merger_1 = new DeepMerger();
|
|
5148
|
+
result.incremental.forEach(function (_a) {
|
|
5149
|
+
var data = _a.data, path = _a.path, errors = _a.errors;
|
|
5150
|
+
for (var i = path.length - 1; i >= 0; --i) {
|
|
5151
|
+
var key = path[i];
|
|
5152
|
+
var isNumericKey = !isNaN(+key);
|
|
5153
|
+
var parent_1 = isNumericKey ? [] : {};
|
|
5154
|
+
parent_1[key] = data;
|
|
5155
|
+
data = parent_1;
|
|
5156
|
+
}
|
|
5157
|
+
if (errors) {
|
|
5158
|
+
graphQLErrors.push.apply(graphQLErrors, errors);
|
|
5159
|
+
}
|
|
5160
|
+
mergedData_1 = merger_1.merge(mergedData_1, data);
|
|
5161
|
+
});
|
|
5162
|
+
result.data = mergedData_1;
|
|
5163
|
+
}
|
|
5164
|
+
this.graphQLErrors = graphQLErrors;
|
|
4873
5165
|
if (options.fetchPolicy === 'no-cache') {
|
|
4874
5166
|
this.updateLastDiff({ result: result.data, complete: true }, this.getDiffOptions(options.variables));
|
|
4875
5167
|
}
|
|
@@ -5146,7 +5438,7 @@ var QueryManager = (function () {
|
|
|
5146
5438
|
optimistic: false,
|
|
5147
5439
|
returnPartialData: true,
|
|
5148
5440
|
});
|
|
5149
|
-
if (diff.complete) {
|
|
5441
|
+
if (diff.complete && !(isExecutionPatchIncrementalResult(result))) {
|
|
5150
5442
|
result = tslib.__assign(tslib.__assign({}, result), { data: diff.result });
|
|
5151
5443
|
}
|
|
5152
5444
|
}
|
|
@@ -5523,11 +5815,21 @@ var QueryManager = (function () {
|
|
|
5523
5815
|
var requestId = queryInfo.lastRequestId = this.generateRequestId();
|
|
5524
5816
|
options = cloneDeep(options);
|
|
5525
5817
|
return asyncMap(this.getObservableFromLink(queryInfo.document, options.context, options.variables), function (result) {
|
|
5526
|
-
var
|
|
5818
|
+
var graphQLErrors = isNonEmptyArray(result.errors)
|
|
5819
|
+
? result.errors.slice(0)
|
|
5820
|
+
: [];
|
|
5821
|
+
if ('incremental' in result && isNonEmptyArray(result.incremental)) {
|
|
5822
|
+
result.incremental.forEach(function (incrementalResult) {
|
|
5823
|
+
if (incrementalResult.errors) {
|
|
5824
|
+
graphQLErrors.push.apply(graphQLErrors, incrementalResult.errors);
|
|
5825
|
+
}
|
|
5826
|
+
});
|
|
5827
|
+
}
|
|
5828
|
+
var hasErrors = isNonEmptyArray(graphQLErrors);
|
|
5527
5829
|
if (requestId >= queryInfo.lastRequestId) {
|
|
5528
5830
|
if (hasErrors && options.errorPolicy === "none") {
|
|
5529
5831
|
throw queryInfo.markError(new ApolloError({
|
|
5530
|
-
graphQLErrors:
|
|
5832
|
+
graphQLErrors: graphQLErrors,
|
|
5531
5833
|
}));
|
|
5532
5834
|
}
|
|
5533
5835
|
queryInfo.markResult(result, options, cacheWriteBehavior);
|
|
@@ -5539,7 +5841,7 @@ var QueryManager = (function () {
|
|
|
5539
5841
|
networkStatus: exports.NetworkStatus.ready,
|
|
5540
5842
|
};
|
|
5541
5843
|
if (hasErrors && options.errorPolicy !== "ignore") {
|
|
5542
|
-
aqr.errors =
|
|
5844
|
+
aqr.errors = graphQLErrors;
|
|
5543
5845
|
aqr.networkStatus = exports.NetworkStatus.error;
|
|
5544
5846
|
}
|
|
5545
5847
|
return aqr;
|
|
@@ -6538,7 +6840,7 @@ function useMutation(mutation, options) {
|
|
|
6538
6840
|
if (executeOptions === void 0) { executeOptions = {}; }
|
|
6539
6841
|
var _a = ref.current, client = _a.client, options = _a.options, mutation = _a.mutation;
|
|
6540
6842
|
var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
|
|
6541
|
-
if (!ref.current.result.loading && !baseOptions.ignoreResults) {
|
|
6843
|
+
if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {
|
|
6542
6844
|
setResult(ref.current.result = {
|
|
6543
6845
|
loading: true,
|
|
6544
6846
|
error: void 0,
|
|
@@ -6568,8 +6870,8 @@ function useMutation(mutation, options) {
|
|
|
6568
6870
|
setResult(ref.current.result = result_1);
|
|
6569
6871
|
}
|
|
6570
6872
|
}
|
|
6571
|
-
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, response.data);
|
|
6572
|
-
(_c = executeOptions.onCompleted) === null || _c === void 0 ? void 0 : _c.call(executeOptions, response.data);
|
|
6873
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, response.data, clientOptions);
|
|
6874
|
+
(_c = executeOptions.onCompleted) === null || _c === void 0 ? void 0 : _c.call(executeOptions, response.data, clientOptions);
|
|
6573
6875
|
return response;
|
|
6574
6876
|
}).catch(function (error) {
|
|
6575
6877
|
var _a, _b, _c, _d;
|
|
@@ -6587,15 +6889,17 @@ function useMutation(mutation, options) {
|
|
|
6587
6889
|
}
|
|
6588
6890
|
}
|
|
6589
6891
|
if (((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) || clientOptions.onError) {
|
|
6590
|
-
(_c = (_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onError) === null || _c === void 0 ? void 0 : _c.call(_b, error);
|
|
6591
|
-
(_d = executeOptions.onError) === null || _d === void 0 ? void 0 : _d.call(executeOptions, error);
|
|
6892
|
+
(_c = (_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onError) === null || _c === void 0 ? void 0 : _c.call(_b, error, clientOptions);
|
|
6893
|
+
(_d = executeOptions.onError) === null || _d === void 0 ? void 0 : _d.call(executeOptions, error, clientOptions);
|
|
6592
6894
|
return { data: void 0, errors: error };
|
|
6593
6895
|
}
|
|
6594
6896
|
throw error;
|
|
6595
6897
|
});
|
|
6596
6898
|
}, []);
|
|
6597
6899
|
var reset = React.useCallback(function () {
|
|
6598
|
-
|
|
6900
|
+
if (ref.current.isMounted) {
|
|
6901
|
+
setResult({ called: false, loading: false, client: client });
|
|
6902
|
+
}
|
|
6599
6903
|
}, []);
|
|
6600
6904
|
React.useEffect(function () {
|
|
6601
6905
|
ref.current.isMounted = true;
|
|
@@ -6728,7 +7032,7 @@ function useReactiveVar(rv) {
|
|
|
6728
7032
|
return value;
|
|
6729
7033
|
}
|
|
6730
7034
|
|
|
6731
|
-
function
|
|
7035
|
+
function useFragment_experimental(options) {
|
|
6732
7036
|
var cache = useApolloClient().cache;
|
|
6733
7037
|
var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
|
|
6734
7038
|
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
@@ -6744,8 +7048,11 @@ function useFragment(options) {
|
|
|
6744
7048
|
immediate = false;
|
|
6745
7049
|
} }));
|
|
6746
7050
|
}, function () {
|
|
6747
|
-
|
|
6748
|
-
|
|
7051
|
+
var latestDiffToResult = diffToResult(latestDiff);
|
|
7052
|
+
return resultRef.current &&
|
|
7053
|
+
equality.equal(resultRef.current.data, latestDiffToResult.data)
|
|
7054
|
+
? resultRef.current
|
|
7055
|
+
: (resultRef.current = latestDiffToResult);
|
|
6749
7056
|
});
|
|
6750
7057
|
}
|
|
6751
7058
|
function diffToResult(diff) {
|
|
@@ -6807,7 +7114,7 @@ exports.split = split;
|
|
|
6807
7114
|
exports.throwServerError = throwServerError;
|
|
6808
7115
|
exports.toPromise = toPromise;
|
|
6809
7116
|
exports.useApolloClient = useApolloClient;
|
|
6810
|
-
exports.
|
|
7117
|
+
exports.useFragment_experimental = useFragment_experimental;
|
|
6811
7118
|
exports.useLazyQuery = useLazyQuery;
|
|
6812
7119
|
exports.useMutation = useMutation;
|
|
6813
7120
|
exports.useQuery = useQuery;
|