UNPKG

1.44 kBJavaScriptView Raw
1import { __extends } from "tslib";
2import { ApolloLink } from "../core/index.js";
3import { OperationBatcher } from "./batching.js";
4export { OperationBatcher } from "./batching.js";
5var BatchLink = (function (_super) {
6 __extends(BatchLink, _super);
7 function BatchLink(fetchParams) {
8 var _this = _super.call(this) || this;
9 var _a = fetchParams || {}, batchDebounce = _a.batchDebounce, _b = _a.batchInterval, batchInterval = _b === void 0 ? 10 : _b, _c = _a.batchMax, batchMax = _c === void 0 ? 0 : _c, _d = _a.batchHandler, batchHandler = _d === void 0 ? function () { return null; } : _d, _e = _a.batchKey, batchKey = _e === void 0 ? function () { return ''; } : _e;
10 _this.batcher = new OperationBatcher({
11 batchDebounce: batchDebounce,
12 batchInterval: batchInterval,
13 batchMax: batchMax,
14 batchHandler: batchHandler,
15 batchKey: batchKey,
16 });
17 if (fetchParams.batchHandler.length <= 1) {
18 _this.request = function (operation) { return _this.batcher.enqueueRequest({ operation: operation }); };
19 }
20 return _this;
21 }
22 BatchLink.prototype.request = function (operation, forward) {
23 return this.batcher.enqueueRequest({
24 operation: operation,
25 forward: forward,
26 });
27 };
28 return BatchLink;
29}(ApolloLink));
30export { BatchLink };
31//# sourceMappingURL=batchLink.js.map
\No newline at end of file