New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apollo-link

Package Overview
Dependencies
Maintainers
4
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-link - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

43

lib/bundle.umd.js

@@ -137,4 +137,4 @@ (function (global, factory) {

return test(operation)
? leftLink.request(operation) || Observable.of()
: rightLink.request(operation) || Observable.of();
? leftLink.execute(operation) || Observable.of()
: rightLink.execute(operation) || Observable.of();
});

@@ -145,4 +145,4 @@ }

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

@@ -154,3 +154,3 @@ }

if (isTerminating(firstLink)) {
console.warn(new LinkError("You are calling concat on a terminating link, which will have no effect", firstLink));
console.warn(new LinkError("You are calling concat on a terminating link, which will have no effect.\n Learn more about terminating links in the Apollo Link docs:\n https://www.apollographql.com/docs/link/overview.html#terminating", firstLink));
return firstLink;

@@ -161,3 +161,3 @@ }

return new ApolloLink(function (operation) {
return firstLink.request(operation, function (op) { return nextLink.request(op) || Observable.of(); }) || Observable.of();
return firstLink.execute(operation, function (op) { return nextLink.execute(op) || Observable.of(); }) || Observable.of();
});

@@ -167,4 +167,4 @@ }

return new ApolloLink(function (operation, forward) {
return (firstLink.request(operation, function (op) {
return nextLink.request(op, forward) || Observable.of();
return (firstLink.execute(operation, function (op) {
return nextLink.execute(op, forward) || Observable.of();
}) || Observable.of());

@@ -176,4 +176,5 @@ });

function ApolloLink(request) {
if (request)
if (request) {
this.request = request;
}
}

@@ -190,2 +191,26 @@ ApolloLink.prototype.split = function (test, left, right) {

};
ApolloLink.prototype.notifyDevTools = function (operation, result) {
if (this.devToolsHook) {
this.devToolsHook({
network: {
operation: operation,
result: result,
},
});
}
};
ApolloLink.prototype.connectToDevTools = function (hook) {
if (!this.devToolsHook) {
this.devToolsHook = hook;
}
};
ApolloLink.prototype.execute = function (operation, forward) {
var _this = this;
return this.request(operation, forward).map(function (result) {
setTimeout(function () {
_this.notifyDevTools(operation, result);
}, 0);
return result;
});
};
ApolloLink.empty = empty;

@@ -192,0 +217,0 @@ ApolloLink.from = from;

/// <reference types="zen-observable" />
import * as Observable from 'zen-observable';
import { GraphQLRequest, NextLink, Operation, RequestHandler, FetchResult } from './types';
import { GraphQLRequest, NextLink, Operation, RequestHandler, FetchResult, DevToolsHook } from './types';
export declare const empty: () => ApolloLink;

@@ -9,2 +9,3 @@ export declare const from: (links: ApolloLink[]) => ApolloLink;

export declare class ApolloLink {
private devToolsHook;
constructor(request?: RequestHandler);

@@ -16,4 +17,7 @@ static empty: () => ApolloLink;

concat(next: ApolloLink | RequestHandler): ApolloLink;
request(operation: Operation, forward?: NextLink): Observable<FetchResult> | null;
request(operation: Operation, forward?: NextLink): Observable<FetchResult>;
private notifyDevTools(operation, result);
connectToDevTools(hook: DevToolsHook): void;
execute(operation: Operation, forward?: NextLink): Observable<FetchResult>;
}
export declare function execute(link: ApolloLink, operation: GraphQLRequest): Observable<FetchResult>;

@@ -22,4 +22,4 @@ import * as Observable from 'zen-observable';

return test(operation)
? leftLink.request(operation) || Observable.of()
: rightLink.request(operation) || Observable.of();
? leftLink.execute(operation) || Observable.of()
: rightLink.execute(operation) || Observable.of();
});

@@ -30,4 +30,4 @@ }

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

@@ -39,3 +39,3 @@ }

if (isTerminating(firstLink)) {
console.warn(new LinkError("You are calling concat on a terminating link, which will have no effect", firstLink));
console.warn(new LinkError("You are calling concat on a terminating link, which will have no effect.\n Learn more about terminating links in the Apollo Link docs:\n https://www.apollographql.com/docs/link/overview.html#terminating", firstLink));
return firstLink;

@@ -46,3 +46,3 @@ }

return new ApolloLink(function (operation) {
return firstLink.request(operation, function (op) { return nextLink.request(op) || Observable.of(); }) || Observable.of();
return firstLink.execute(operation, function (op) { return nextLink.execute(op) || Observable.of(); }) || Observable.of();
});

@@ -52,4 +52,4 @@ }

return new ApolloLink(function (operation, forward) {
return (firstLink.request(operation, function (op) {
return nextLink.request(op, forward) || Observable.of();
return (firstLink.execute(operation, function (op) {
return nextLink.execute(op, forward) || Observable.of();
}) || Observable.of());

@@ -61,4 +61,5 @@ });

function ApolloLink(request) {
if (request)
if (request) {
this.request = request;
}
}

@@ -75,2 +76,26 @@ ApolloLink.prototype.split = function (test, left, right) {

};
ApolloLink.prototype.notifyDevTools = function (operation, result) {
if (this.devToolsHook) {
this.devToolsHook({
network: {
operation: operation,
result: result,
},
});
}
};
ApolloLink.prototype.connectToDevTools = function (hook) {
if (!this.devToolsHook) {
this.devToolsHook = hook;
}
};
ApolloLink.prototype.execute = function (operation, forward) {
var _this = this;
return this.request(operation, forward).map(function (result) {
setTimeout(function () {
_this.notifyDevTools(operation, result);
}, 0);
return result;
});
};
ApolloLink.empty = empty;

@@ -77,0 +102,0 @@ ApolloLink.from = from;

@@ -7,3 +7,3 @@ /// <reference types="zen-observable" />

constructor(handleRequest?: RequestHandler);
request(operation: Operation, forward?: NextLink): Observable<FetchResult> | null;
request(operation: Operation, forward?: NextLink): Observable<FetchResult>;
}

@@ -11,2 +11,3 @@ var __extends = (this && this.__extends) || (function () {

})();
import * as Observable from 'zen-observable';
import { ApolloLink } from '../link';

@@ -16,3 +17,3 @@ var MockLink = (function (_super) {

function MockLink(handleRequest) {
if (handleRequest === void 0) { handleRequest = function () { return null; }; }
if (handleRequest === void 0) { handleRequest = function () { return Observable.of(); }; }
var _this = _super.call(this) || this;

@@ -19,0 +20,0 @@ _this.request = handleRequest;

@@ -0,4 +1,8 @@

var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
import gql from 'graphql-tag';
import { execute } from '../link';
var sampleQuery = (_a = ["\n query SampleQuery {\n stub {\n id\n }\n }\n"], _a.raw = ["\n query SampleQuery {\n stub {\n id\n }\n }\n"], gql(_a));
var sampleQuery = gql(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query SampleQuery {\n stub {\n id\n }\n }\n"], ["\n query SampleQuery {\n stub {\n id\n }\n }\n"])));
export function checkCalls(calls, results) {

@@ -32,3 +36,3 @@ if (calls === void 0) { calls = []; }

}
var _a;
var templateObject_1;
//# sourceMappingURL=testingUtils.js.map

@@ -25,2 +25,9 @@ /// <reference types="zen-observable" />

export declare type NextLink = (operation: Operation) => Observable<FetchResult>;
export declare type RequestHandler = (operation: Operation, forward?: NextLink) => Observable<FetchResult> | null;
export declare type RequestHandler = (operation: Operation, forward?: NextLink) => Observable<FetchResult>;
export declare type DevToolsMessage = {
network: {
operation: Operation;
result: FetchResult;
};
};
export declare type DevToolsHook = (message: DevToolsMessage) => void;
{
"name": "apollo-link",
"version": "1.0.0",
"version": "1.0.1",
"description": "Flexible, lightweight transport layer for GraphQL",

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

"dependencies": {
"apollo-utilities": "^0.2.0-beta.0",
"@types/zen-observable": "0.5.3",
"apollo-utilities": "^1.0.1",
"zen-observable": "^0.6.0"

@@ -52,4 +53,3 @@ },

"@types/graphql": "0.11.5",
"@types/jest": "21.1.4",
"@types/zen-observable": "0.5.3",
"@types/jest": "21.1.5",
"browserify": "14.5.0",

@@ -61,6 +61,6 @@ "graphql": "0.11.7",

"rollup": "0.45.2",
"ts-jest": "21.1.3",
"ts-jest": "21.2.1",
"tslint": "5.8.0",
"typescript": "2.5.1",
"uglify-js": "3.1.5"
"typescript": "2.6.1",
"uglify-js": "3.1.8"
},

@@ -67,0 +67,0 @@ "jest": {

@@ -431,3 +431,4 @@ import * as Observable from 'zen-observable';

}).toEqual(op);
return done();
done();
return Observable.of();
}),

@@ -727,32 +728,2 @@ ]);

it("should return an empty observable when a concat'd link returns null", done => {
const link = new MockLink((operation, forward) => {
return forward(operation);
}).concat(() => null);
testLinkResults({
link,
results: [],
done,
});
});
it('should return an empty observable when a split link returns null', done => {
let context = { test: true };
const link = new SetContextLink(() => context).split(
op => op.getContext().test,
() => Observable.of(),
() => null,
);
testLinkResults({
link,
results: [],
});
context.test = false;
testLinkResults({
link,
results: [],
done,
});
});
it('should set a default context, variable, query and operationName on a copy of operation', done => {

@@ -759,0 +730,0 @@ const operation = {

@@ -9,2 +9,3 @@ import * as Observable from 'zen-observable';

FetchResult,
DevToolsHook,
} from './types';

@@ -45,4 +46,4 @@

return test(operation)
? leftLink.request(operation) || Observable.of()
: rightLink.request(operation) || Observable.of();
? leftLink.execute(operation) || Observable.of()
: rightLink.execute(operation) || Observable.of();
});

@@ -52,4 +53,4 @@ } else {

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

@@ -68,3 +69,5 @@ }

new LinkError(
`You are calling concat on a terminating link, which will have no effect`,
`You are calling concat on a terminating link, which will have no effect.
Learn more about terminating links in the Apollo Link docs:
https://www.apollographql.com/docs/link/overview.html#terminating`,
firstLink,

@@ -80,5 +83,5 @@ ),

operation =>
firstLink.request(
firstLink.execute(
operation,
op => nextLink.request(op) || Observable.of(),
op => nextLink.execute(op) || Observable.of(),
) || Observable.of(),

@@ -89,4 +92,4 @@ );

return (
firstLink.request(operation, op => {
return nextLink.request(op, forward) || Observable.of();
firstLink.execute(operation, op => {
return nextLink.execute(op, forward) || Observable.of();
}) || Observable.of()

@@ -99,4 +102,14 @@ );

export class ApolloLink {
private devToolsHook: DevToolsHook;
constructor(request?: RequestHandler) {
if (request) this.request = request;
if (request) {
this.request = request;
// if (request() === null) {
// throw new Error(`
// Your request handler must return an Observable.
// Visit the Apollo Link docs to learn more about request handlers:
// https://www.apollographql.com/docs/link/overview.html#request
// `);
// }
}
}

@@ -123,5 +136,35 @@

forward?: NextLink,
): Observable<FetchResult> | null {
): Observable<FetchResult> {
throw new Error('request is not implemented');
}
private notifyDevTools(operation: Operation, result: FetchResult): void {
if (this.devToolsHook) {
this.devToolsHook({
network: {
operation,
result,
},
});
}
}
public connectToDevTools(hook: DevToolsHook): void {
if (!this.devToolsHook) {
this.devToolsHook = hook;
}
}
public execute(
operation: Operation,
forward?: NextLink,
): Observable<FetchResult> {
return this.request(operation, forward).map(result => {
setTimeout(() => {
this.notifyDevTools(operation, result);
}, 0);
return result;
});
}
}

@@ -128,0 +171,0 @@

@@ -125,5 +125,5 @@ import { getOperationName } from 'apollo-utilities';

// that might not always be true
return `${print(operation.query)}|${JSON.stringify(
operation.variables,
)}|${operation.operationName}`;
return `${print(operation.query)}|${JSON.stringify(operation.variables)}|${
operation.operationName
}`;
}

@@ -8,3 +8,3 @@ import { Operation, RequestHandler, NextLink, FetchResult } from '../types';

export default class MockLink extends ApolloLink {
constructor(handleRequest: RequestHandler = () => null) {
constructor(handleRequest: RequestHandler = () => Observable.of()) {
super();

@@ -17,5 +17,5 @@ this.request = handleRequest;

forward?: NextLink,
): Observable<FetchResult> | null {
): Observable<FetchResult> {
throw Error('should be overridden');
}
}

@@ -34,2 +34,11 @@ import * as Observable from 'zen-observable';

forward?: NextLink,
) => Observable<FetchResult> | null;
) => Observable<FetchResult>;
export type DevToolsMessage = {
network: {
operation: Operation;
result: FetchResult;
};
};
export type DevToolsHook = (message: DevToolsMessage) => void;

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