all files / src/ linkUtils.js

88.1% Statements 37/42
61.9% Branches 13/21
81.82% Functions 9/11
92.31% Lines 36/39
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57          149× 149×           64× 64× 162× 162×     63×   11× 11× 11×     131× 62×     69×     139×    
"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var link_1 = require("./link");
function validateLink(link) {
    Eif (link instanceof link_1.ApolloLink && typeof link.request === 'function') {
        return link;
    }
    else {
        throw new LinkError('Link does not extend ApolloLink and implement request', link);
    }
}
exports.validateLink = validateLink;
function validateOperation(operation) {
    var OPERATION_FIELDS = ['query', 'operationName', 'variables', 'context'];
    for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
        var key = _a[_i];
        if (OPERATION_FIELDS.indexOf(key) < 0) {
            throw new Error("illegal argument: " + key);
        }
    }
    return operation;
}
exports.validateOperation = validateOperation;
var LinkError = (function (_super) {
    __extends(LinkError, _super);
    function LinkError(message, link) {
        var _this = _super.call(this, message) || this;
        _this.link = link;
        return _this;
    }
    return LinkError;
}(Error));
exports.LinkError = LinkError;
function toLink(link) {
    if (typeof link === 'function') {
        return new link_1.FunctionLink(link);
    }
    else {
        return link;
    }
}
exports.toLink = toLink;
function isTerminating(link) {
    return link.request.length <= 1;
}
exports.isTerminating = isTerminating;
//# sourceMappingURL=linkUtils.js.map