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
1
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 0.0.0 to 0.0.1

coverage/coverage.json

17

.vscode/tasks.json

@@ -28,21 +28,4 @@ {

"problemMatcher": "$tsc-watch"
// "problemMatcher": {
// "owner": "typescript",
// "fileLocation": "relative",
// "pattern": {
// "regexp": "^([^\\s].*)\\((\\d+|\\,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$",
// "file": 1,
// "location": 2,
// "severity": 3,
// "code": 4,
// "message": 5
// },
// "background": {
// "activeOnStart": true,
// "beginsPattern": "^\\s*\\d{1,2}:\\d{1,2}:\\d{1,2}(?: AM| PM)? - File change detected\\. Starting incremental compilation\\.\\.\\.",
// "endsPattern": "^\\s*\\d{1,2}:\\d{1,2}:\\d{1,2}(?: AM| PM)? - Compilation complete\\. Watching for file changes\\."
// }
// }
}
]
}

16

dist/src/httpLink.d.ts

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

import { ApolloLink } from './types';
export declare function createHttpLink(uri?: string): ApolloLink;
/// <reference types="zen-observable" />
import { ApolloLink } from './link';
import { Operation, FetchResult } from './types';
import { ApolloFetch } from 'apollo-fetch';
import * as Observable from 'zen-observable';
export default class HttpLink extends ApolloLink {
private headers;
private _fetch;
constructor(fetchParams?: {
uri?: string;
fetch?: ApolloFetch;
});
request(operation: Operation): Observable<FetchResult> | null;
}
"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 __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var singleRequestLink_1 = require("./singleRequestLink");
var link_1 = require("./link");
var apollo_fetch_1 = require("apollo-fetch");
function createHttpLink(uri) {
if (uri === void 0) { uri = '/graphql'; }
var fetch = apollo_fetch_1.createApolloFetch({ uri: uri });
var link = new singleRequestLink_1.default({ fetch: fetch });
link.use = function (middlewares) {
fetch.use(middlewares);
return link;
var Observable = require("zen-observable");
var printer_1 = require("graphql/language/printer");
var HttpLink = (function (_super) {
__extends(HttpLink, _super);
function HttpLink(fetchParams) {
var _this = _super.call(this) || this;
_this.headers = {};
_this._fetch = fetchParams && fetchParams.fetch || apollo_fetch_1.createApolloFetch({ uri: fetchParams && fetchParams.uri });
_this._fetch.use(function (request, next) {
request.options.headers = __assign({}, request.options.headers, _this.headers);
next();
});
return _this;
}
HttpLink.prototype.request = function (operation) {
var _this = this;
this.headers = operation.context && operation.context.headers || {};
var request = __assign({}, operation, { query: printer_1.print(operation.query) });
return new Observable(function (observer) {
_this._fetch(request)
.then(function (data) {
if (!observer.closed) {
observer.next(data);
observer.complete();
}
})
.catch(function (error) {
if (!observer.closed) {
observer.error(error);
}
});
});
};
link.useAfter = function (afterwares) {
fetch.useAfter(afterwares);
return link;
};
return link;
}
exports.createHttpLink = createHttpLink;
return HttpLink;
}(link_1.ApolloLink));
exports.default = HttpLink;
//# sourceMappingURL=httpLink.js.map

@@ -1,7 +0,6 @@

import * as ApolloLink from './types';
import SingleRequestLink from './singleRequestLink';
import { createHttpLink } from './httpLink';
import BatchHttpLink from './batch/batchHttpLink';
import { linkPromiseWrapper, linkToNetworkInterface } from './link-as-promise';
export { linkPromiseWrapper, linkToNetworkInterface, SingleRequestLink, createHttpLink, BatchHttpLink };
export default ApolloLink;
import HttpLink from './httpLink';
import RetryLink from './retryLink';
import PollingLink from './pollingLink';
import { execute, ApolloLink } from './link';
import * as Observable from 'zen-observable';
export { ApolloLink, execute, Observable, HttpLink, RetryLink, PollingLink };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ApolloLink = require("./types");
var singleRequestLink_1 = require("./singleRequestLink");
exports.SingleRequestLink = singleRequestLink_1.default;
var httpLink_1 = require("./httpLink");
exports.createHttpLink = httpLink_1.createHttpLink;
var batchHttpLink_1 = require("./batch/batchHttpLink");
exports.BatchHttpLink = batchHttpLink_1.default;
var link_as_promise_1 = require("./link-as-promise");
exports.linkPromiseWrapper = link_as_promise_1.linkPromiseWrapper;
exports.linkToNetworkInterface = link_as_promise_1.linkToNetworkInterface;
exports.default = ApolloLink;
exports.HttpLink = httpLink_1.default;
var retryLink_1 = require("./retryLink");
exports.RetryLink = retryLink_1.default;
var pollingLink_1 = require("./pollingLink");
exports.PollingLink = pollingLink_1.default;
var link_1 = require("./link");
exports.execute = link_1.execute;
exports.ApolloLink = link_1.ApolloLink;
var Observable = require("zen-observable");
exports.Observable = Observable;
//# sourceMappingURL=index.js.map

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

import { Operation, Subscriber } from './types';
export declare function toSubscriber<T>(nextOrSubscriber: Subscriber<T> | ((result: T) => void), error?: (error: any) => void, complete?: () => void): Subscriber<T>;
export declare function validateOperation(operation: Operation): void;
import { GraphQLRequest, RequestHandler } from './types';
import { ApolloLink } from './link';
export declare function validateLink(link: ApolloLink): ApolloLink;
export declare function validateOperation(operation: GraphQLRequest): GraphQLRequest;
export declare class LinkError extends Error {
link: ApolloLink;
constructor(message?: string, link?: ApolloLink);
}
export declare function toLink(link: ApolloLink | RequestHandler): ApolloLink;
export declare function isTerminating(link: ApolloLink): boolean;
"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 });
function isSubscriber(object) {
return typeof object !== 'function';
}
function toSubscriber(nextOrSubscriber, error, complete) {
if (isSubscriber(nextOrSubscriber)) {
return nextOrSubscriber;
var link_1 = require("./link");
function validateLink(link) {
if (link instanceof link_1.ApolloLink && typeof link.request === 'function') {
return link;
}
else {
return {
next: nextOrSubscriber,
error: error,
complete: complete,
};
throw new LinkError('Link does not extend ApolloLink and implement request', link);
}
}
exports.toSubscriber = toSubscriber;
exports.validateLink = validateLink;
function validateOperation(operation) {

@@ -27,4 +31,28 @@ var OPERATION_FIELDS = ['query', 'operationName', 'variables', 'context'];

}
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

@@ -1,7 +0,11 @@

import { ApolloLink, Operation, Observable } from './types';
export default class PollingLink implements ApolloLink {
private link;
/// <reference types="zen-observable" />
import { Operation, NextLink, FetchResult } from './types';
import * as Observable from 'zen-observable';
import { ApolloLink } from './link';
export default class PollingLink extends ApolloLink {
private pollInterval;
constructor(link: ApolloLink, pollInterval: number);
request(operation: Operation): Observable;
private timer;
private subscription;
constructor(pollInterval: (opearation: Operation) => number | null);
request(operation: Operation, forward: NextLink): Observable<FetchResult>;
}
"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 PollingLink = (function () {
function PollingLink(link, pollInterval) {
this.link = link;
this.pollInterval = pollInterval || 0;
var Observable = require("zen-observable");
var link_1 = require("./link");
var PollingLink = (function (_super) {
__extends(PollingLink, _super);
function PollingLink(pollInterval) {
var _this = _super.call(this) || this;
_this.pollInterval = pollInterval;
return _this;
}
PollingLink.prototype.request = function (operation) {
PollingLink.prototype.request = function (operation, forward) {
var _this = this;
setTimeout(function () { return _this.link.request(operation); }, this.pollInterval);
return this.link.request(operation);
return new Observable(function (observer) {
var subscriber = {
next: function (data) {
observer.next(data);
},
error: function (error) { return observer.error(error); },
};
var poll = (function () {
_this.subscription.unsubscribe();
_this.subscription = forward(operation).subscribe(subscriber);
});
var interval = _this.pollInterval(operation);
if (interval !== null) {
_this.timer = setInterval(poll, interval);
}
_this.subscription = forward(operation).subscribe(subscriber);
return function () {
if (_this.timer) {
clearInterval(_this.timer);
}
_this.subscription.unsubscribe();
};
});
};
return PollingLink;
}());
}(link_1.ApolloLink));
exports.default = PollingLink;
//# sourceMappingURL=pollingLink.js.map

@@ -0,1 +1,60 @@

"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 Observable = require("zen-observable");
var link_1 = require("./link");
var RetryLink = (function (_super) {
__extends(RetryLink, _super);
function RetryLink(params) {
var _this = _super.call(this) || this;
_this.count = 0;
_this.defaultInterval = function (delay) { return delay; };
_this.max = params && params.max || 10;
_this.delay = params && params.delay || 300;
_this.interval = params && params.interval || _this.defaultInterval;
return _this;
}
RetryLink.prototype.request = function (operation, forward) {
var _this = this;
return new Observable(function (observer) {
var subscriber = {
next: function (data) {
_this.count = 0;
observer.next(data);
},
error: function (error) {
_this.count++;
if (_this.count < _this.max) {
_this.timer = setTimeout(function () {
var observable = forward(operation);
_this.subscription = observable.subscribe(subscriber);
}, _this.interval(_this.delay, _this.count));
}
else {
observer.error(error);
}
},
complete: observer.complete.bind(observer),
};
_this.subscription = forward(operation).subscribe(subscriber);
return function () {
_this.subscription.unsubscribe();
if (_this.timer) {
clearTimeout(_this.timer);
}
};
});
};
return RetryLink;
}(link_1.ApolloLink));
exports.default = RetryLink;
//# sourceMappingURL=retryLink.js.map

@@ -0,23 +1,15 @@

/// <reference types="zen-observable" />
import { DocumentNode } from 'graphql/language/ast';
export interface ApolloLink {
request(operation: Operation): Observable;
import * as Observable from 'zen-observable';
export interface GraphQLRequest {
query?: string | DocumentNode;
variables?: object;
context?: object;
}
export interface PromiseLink {
request(operation: Operation): Promise<FetchResult>;
}
export interface Operation {
query?: DocumentNode;
variables?: object;
query: DocumentNode;
variables?: Record<string, any>;
operationName?: string;
context?: object;
context?: Record<string, any>;
}
export interface Observable {
subscribe(subscriber: Subscriber<FetchResult>): Subscription;
subscribe(next: (result: FetchResult) => void, error?: (error: any) => void, complete?: () => void): Subscription;
}
export interface Subscriber<T> {
next: (result: T) => void;
error?: (error: any) => void;
complete?: () => void;
}
export interface FetchResult {

@@ -27,7 +19,5 @@ data: any;

extensions?: any;
context?: object;
context?: Record<string, any>;
}
export interface Subscription {
unsubscribe: () => void;
closed: boolean;
}
export declare type NextLink = (operation: Operation) => Observable<FetchResult>;
export declare type RequestHandler = (operation: Operation, forward?: NextLink) => Observable<FetchResult> | null;
{
"name": "apollo-link",
"version": "0.0.0",
"version": "0.0.1",
"description": "Flexible, lightweight transport layer for GraphQL",
"author": "Evans Hauser <evanshauser@gmail.com>",
"contributors": [
"Jonas Helfer <jonas@helfer.email>"
"James Baxley <james@meteor.com>",
"Jonas Helfer <jonas@helfer.email>",
"jon wong <j@jnwng.com>",
"Sashko Stubailo <sashko@stubailo.com>"
],

@@ -37,5 +40,6 @@ "license": "MIT",

},
"devDependencies": {
"graphql": "^0.10.1",
"apollo-fetch": "^0.0.0"
"dependencies": {
"apollo-fetch": "^0.3.0",
"graphql": "^0.10.3",
"zen-observable": "^0.5.2"
},

@@ -46,2 +50,3 @@ "devDependencies": {

"@types/mocha": "^2.2.31",
"@types/sinon": "^2.3.2",
"chai": "^4.0.2",

@@ -60,3 +65,7 @@ "chai-as-promised": "^7.0.0",

"typescript": "^2.2.1"
},
"optionalDependencies": {
"@types/graphql": "^0.9.4",
"@types/zen-observable": "^0.5.1"
}
}

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