Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-link-core

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-link-core - npm Package Compare versions

Comparing version 0.5.2 to 0.5.4

dist/tests/link.d.ts

20

dist/src/index.js

@@ -1,7 +0,15 @@

import { execute, ApolloLink } from './link';
export { makePromise } from './linkUtils';
import Observable from 'zen-observable-ts';
export * from 'zen-observable-ts';
export default ApolloLink;
export { Observable, ApolloLink, execute };
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
var link_1 = require("./link");
exports.execute = link_1.execute;
exports.ApolloLink = link_1.ApolloLink;
var linkUtils_1 = require("./linkUtils");
exports.makePromise = linkUtils_1.makePromise;
var zen_observable_ts_1 = require("zen-observable-ts");
exports.Observable = zen_observable_ts_1.default;
__export(require("zen-observable-ts"));
exports.default = link_1.ApolloLink;
//# sourceMappingURL=index.js.map

@@ -0,1 +1,2 @@

"use strict";
var __extends = (this && this.__extends) || (function () {

@@ -19,5 +20,6 @@ var extendStatics = Object.setPrototypeOf ||

};
import { validateOperation, toLink, isTerminating, LinkError, validateLink, } from './linkUtils';
import gql from 'graphql-tag';
import Observable from 'zen-observable-ts';
Object.defineProperty(exports, "__esModule", { value: true });
var linkUtils_1 = require("./linkUtils");
var graphql_tag_1 = require("graphql-tag");
var zen_observable_ts_1 = require("zen-observable-ts");
var ApolloLink = (function () {

@@ -30,19 +32,19 @@ function ApolloLink() {

}
return links.map(toLink).reduce(function (x, y) { return x.concat(y); });
return links.map(linkUtils_1.toLink).reduce(function (x, y) { return x.concat(y); });
};
ApolloLink.empty = function () {
return new FunctionLink(function (op, forward) { return Observable.of(); });
return new FunctionLink(function (op, forward) { return zen_observable_ts_1.default.of(); });
};
ApolloLink.passthrough = function () {
return new FunctionLink(function (op, forward) { return (forward ? forward(op) : Observable.of()); });
return new FunctionLink(function (op, forward) { return (forward ? forward(op) : zen_observable_ts_1.default.of()); });
};
ApolloLink.split = function (test, left, right) {
if (right === void 0) { right = ApolloLink.passthrough(); }
var leftLink = validateLink(toLink(left));
var rightLink = validateLink(toLink(right));
if (isTerminating(leftLink) && isTerminating(rightLink)) {
var leftLink = linkUtils_1.validateLink(linkUtils_1.toLink(left));
var rightLink = linkUtils_1.validateLink(linkUtils_1.toLink(right));
if (linkUtils_1.isTerminating(leftLink) && linkUtils_1.isTerminating(rightLink)) {
return new FunctionLink(function (operation) {
return test(operation)
? leftLink.request(operation) || Observable.of()
: rightLink.request(operation) || Observable.of();
? leftLink.request(operation) || zen_observable_ts_1.default.of()
: rightLink.request(operation) || zen_observable_ts_1.default.of();
});

@@ -53,4 +55,4 @@ }

return test(operation)
? leftLink.request(operation, forward) || Observable.of()
: rightLink.request(operation, forward) || Observable.of();
? leftLink.request(operation, forward) || zen_observable_ts_1.default.of()
: rightLink.request(operation, forward) || zen_observable_ts_1.default.of();
});

@@ -65,11 +67,11 @@ }

var _this = this;
validateLink(this);
if (isTerminating(this)) {
console.warn(new LinkError("You are calling concat on a terminating link, which will have no effect", this));
linkUtils_1.validateLink(this);
if (linkUtils_1.isTerminating(this)) {
console.warn(new linkUtils_1.LinkError("You are calling concat on a terminating link, which will have no effect", this));
return this;
}
var nextLink = validateLink(toLink(next));
if (isTerminating(nextLink)) {
var nextLink = linkUtils_1.validateLink(linkUtils_1.toLink(next));
if (linkUtils_1.isTerminating(nextLink)) {
return new FunctionLink(function (operation) {
return _this.request(operation, function (op) { return nextLink.request(op) || Observable.of(); }) || Observable.of();
return _this.request(operation, function (op) { return nextLink.request(op) || zen_observable_ts_1.default.of(); }) || zen_observable_ts_1.default.of();
});

@@ -80,4 +82,4 @@ }

return (_this.request(operation, function (op) {
return nextLink.request(op, forward) || Observable.of();
}) || Observable.of());
return nextLink.request(op, forward) || zen_observable_ts_1.default.of();
}) || zen_observable_ts_1.default.of());
});

@@ -88,6 +90,6 @@ }

}());
export { ApolloLink };
export function execute(link, operation) {
exports.ApolloLink = ApolloLink;
function execute(link, operation) {
var copy = __assign({}, operation);
validateOperation(copy);
linkUtils_1.validateOperation(copy);
if (!copy.context) {

@@ -103,4 +105,5 @@ copy.context = {};

}
return link.request(transformOperation(copy)) || Observable.of();
return link.request(transformOperation(copy)) || zen_observable_ts_1.default.of();
}
exports.execute = execute;
function getName(node) {

@@ -112,3 +115,3 @@ return node && node.name && node.name.kind === 'Name' && node.name.value;

if (typeof operation.query === 'string') {
transformedOperation = __assign({}, operation, { query: gql(operation.query) });
transformedOperation = __assign({}, operation, { query: graphql_tag_1.default(operation.query) });
}

@@ -146,3 +149,3 @@ else {

}(ApolloLink));
export { FunctionLink };
exports.FunctionLink = FunctionLink;
//# sourceMappingURL=link.js.map

@@ -0,1 +1,2 @@

"use strict";
var __extends = (this && this.__extends) || (function () {

@@ -11,5 +12,6 @@ var extendStatics = Object.setPrototypeOf ||

})();
import { ApolloLink, FunctionLink } from './link';
export function validateLink(link) {
if (link instanceof ApolloLink && typeof link.request === 'function') {
Object.defineProperty(exports, "__esModule", { value: true });
var link_1 = require("./link");
function validateLink(link) {
if (link instanceof link_1.ApolloLink && typeof link.request === 'function') {
return link;

@@ -21,3 +23,4 @@ }

}
export function validateOperation(operation) {
exports.validateLink = validateLink;
function validateOperation(operation) {
var OPERATION_FIELDS = ['query', 'operationName', 'variables', 'context'];

@@ -32,2 +35,3 @@ for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {

}
exports.validateOperation = validateOperation;
var LinkError = (function (_super) {

@@ -42,6 +46,6 @@ __extends(LinkError, _super);

}(Error));
export { LinkError };
export function toLink(link) {
exports.LinkError = LinkError;
function toLink(link) {
if (typeof link === 'function') {
return new FunctionLink(link);
return new link_1.FunctionLink(link);
}

@@ -52,6 +56,8 @@ else {

}
export function isTerminating(link) {
exports.toLink = toLink;
function isTerminating(link) {
return link.request.length <= 1;
}
export function makePromise(observable) {
exports.isTerminating = isTerminating;
function makePromise(observable) {
var completed = false;

@@ -73,2 +79,3 @@ return new Promise(function (resolve, reject) {

}
exports.makePromise = makePromise;
//# sourceMappingURL=linkUtils.js.map

@@ -1,5 +0,11 @@

import MockLink from './test-utils/mockLink';
import SetContextLink from './test-utils/setContext';
export * from './test-utils/testingUtils';
export { MockLink, SetContextLink };
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
var mockLink_1 = require("./test-utils/mockLink");
exports.MockLink = mockLink_1.default;
var setContext_1 = require("./test-utils/setContext");
exports.SetContextLink = setContext_1.default;
__export(require("./test-utils/testingUtils"));
//# sourceMappingURL=test-utils.js.map

@@ -0,1 +1,2 @@

"use strict";
var __extends = (this && this.__extends) || (function () {

@@ -11,3 +12,4 @@ var extendStatics = Object.setPrototypeOf ||

})();
import { ApolloLink } from '../link';
Object.defineProperty(exports, "__esModule", { value: true });
var link_1 = require("../link");
var MockLink = (function (_super) {

@@ -25,4 +27,4 @@ __extends(MockLink, _super);

return MockLink;
}(ApolloLink));
export default MockLink;
}(link_1.ApolloLink));
exports.default = MockLink;
//# sourceMappingURL=mockLink.js.map

@@ -0,1 +1,2 @@

"use strict";
var __extends = (this && this.__extends) || (function () {

@@ -11,3 +12,4 @@ var extendStatics = Object.setPrototypeOf ||

})();
import { ApolloLink } from '../link';
Object.defineProperty(exports, "__esModule", { value: true });
var link_1 = require("../link");
var SetContextLink = (function (_super) {

@@ -29,4 +31,4 @@ __extends(SetContextLink, _super);

return SetContextLink;
}(ApolloLink));
export default SetContextLink;
}(link_1.ApolloLink));
exports.default = SetContextLink;
//# sourceMappingURL=setContext.js.map

@@ -1,10 +0,13 @@

import { assert } from 'chai';
import * as sinon from 'sinon';
import * as Links from '../link';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var chai_1 = require("chai");
var sinon = require("sinon");
var Links = require("../link");
var sampleQuery = "\nquery SampleQuery {\n stub{\n id\n }\n}\n";
export function checkCalls(calls, results) {
assert.deepEqual(calls.length, results.length);
calls.map(function (call, i) { return assert.deepEqual(call.args[0].data, results[i]); });
function checkCalls(calls, results) {
chai_1.assert.deepEqual(calls.length, results.length);
calls.map(function (call, i) { return chai_1.assert.deepEqual(call.args[0].data, results[i]); });
}
export function testLinkResults(params) {
exports.checkCalls = checkCalls;
function testLinkResults(params) {
var link = params.link, context = params.context, variables = params.variables;

@@ -18,3 +21,3 @@ var results = params.results || [];

error: function (error) {
assert(error, results.pop());
chai_1.assert(error, results.pop());
checkCalls(spy.getCalls(), results);

@@ -33,2 +36,3 @@ if (done) {

}
exports.testLinkResults = testLinkResults;
//# sourceMappingURL=testingUtils.js.map

@@ -0,1 +1,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
{
"name": "apollo-link-core",
"version": "0.5.2",
"version": "0.5.4",
"description": "Flexible, lightweight transport layer for GraphQL",

@@ -13,6 +13,4 @@ "author": "Evans Hauser <evanshauser@gmail.com>",

"license": "MIT",
"main": "./dist/src/bundle.umd.js",
"module": "./dist/src/index.js",
"jsnext:main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts",
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
"repository": {

@@ -27,3 +25,3 @@ "type": "git",

"scripts": {
"pretest": "npm run build-test",
"pretest": "npm run build",
"test": "npm run test-only --",

@@ -35,16 +33,13 @@ "posttest": "npm run lint",

"coverage":
"istanbul cover ./node_modules/mocha/bin/_mocha -- --reporter dot --full-trace dist/tests/tests.js",
"istanbul cover ./node_modules/.bin/_mocha -- --reporter dot --full-trace dist/tests/tests.js",
"postcoverage":
"remap-istanbul --input coverage/coverage.json --type lcovonly --output coverage/lcov.info",
"lint":
"tslint --type-check -p tsconfig.test.json src/*.ts && tslint --type-check -p tsconfig.test.json tests/*.ts",
"tslint --type-check -p tsconfig.json src/*.ts && tslint --type-check -p tsconfig.json tests/*.ts",
"prebuild": "npm run clean:dist",
"build": "tsc -p .",
"build-test": "tsc -p tsconfig.test.json",
"postbuild": "npm run bundle",
"postbuild-test": "npm run bundle",
"bundle": "rollup -c",
"postbuild": "cp -R ./dist/src/. ./lib",
"watch": "tsc -w -p .",
"clean": "npm run clean:dist && npm run clean:coverage",
"clean:dist": "rimraf dist/*",
"clean:dist": "rimraf dist/* && rimraf lib/*",
"clean:coverage": "rimraf coverage/*",

@@ -56,3 +51,3 @@ "prepublishOnly": "npm run clean && npm run build"

"graphql-tag": "^2.4.2",
"zen-observable-ts": "^0.4.2"
"zen-observable-ts": "^0.4.4"
},

@@ -73,3 +68,2 @@ "devDependencies": {

"rimraf": "2.6.1",
"rollup": "^0.45.2",
"sinon": "3.2.0",

@@ -76,0 +70,0 @@ "source-map-support": "0.4.16",

{
"extends": "../../tsconfig",
"compilerOptions": {
"target": "es5",
"lib": ["es6", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,
"declaration": true,
"rootDir": ".",
"outDir": "dist",
"rootDir": "."
"noImplicitAny": true,
"noUnusedParameters": false,
"noUnusedLocals": true,
"skipLibCheck": true
},
"include": ["src/**/*.ts"]
"include": ["src/**/*.ts", "tests/**/*.ts"]
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc