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

apollo-link-batch-http

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-link-batch-http - npm Package Compare versions

Comparing version 1.2.8 to 1.2.9

.rpt2_cache/rpt2_03d2936e5d96b6af272f133f8a0167eecea2f2b2/code/cache_/0c60c1207c9a18d75562ab75945079c3ce5d8755

42

lib/batchHttpLink.js
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
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 extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var apollo_link_1 = require("apollo-link");

@@ -29,7 +8,6 @@ var apollo_link_http_common_1 = require("apollo-link-http-common");

var BatchHttpLink = (function (_super) {
__extends(BatchHttpLink, _super);
tslib_1.__extends(BatchHttpLink, _super);
function BatchHttpLink(fetchParams) {
if (fetchParams === void 0) { fetchParams = {}; }
var _this = _super.call(this) || this;
var _a = fetchParams.uri, uri = _a === void 0 ? '/graphql' : _a, fetcher = fetchParams.fetch, includeExtensions = fetchParams.includeExtensions, batchInterval = fetchParams.batchInterval, batchMax = fetchParams.batchMax, batchKey = fetchParams.batchKey, requestOptions = __rest(fetchParams, ["uri", "fetch", "includeExtensions", "batchInterval", "batchMax", "batchKey"]);
var _a = fetchParams || {}, _b = _a.uri, uri = _b === void 0 ? '/graphql' : _b, fetcher = _a.fetch, includeExtensions = _a.includeExtensions, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchKey = _a.batchKey, requestOptions = tslib_1.__rest(_a, ["uri", "fetch", "includeExtensions", "batchInterval", "batchMax", "batchKey"]);
apollo_link_http_common_1.checkFetcher(fetcher);

@@ -50,2 +28,12 @@ if (!fetcher) {

var context = operations[0].getContext();
var clientAwarenessHeaders = {};
if (context.clientAwareness) {
var _a = context.clientAwareness, name_1 = _a.name, version = _a.version;
if (name_1) {
clientAwarenessHeaders['apollographql-client-name'] = name_1;
}
if (version) {
clientAwarenessHeaders['apollographql-client-version'] = version;
}
}
var contextConfig = {

@@ -55,3 +43,3 @@ http: context.http,

credentials: context.credentials,
headers: context.headers,
headers: tslib_1.__assign({}, clientAwarenessHeaders, context.headers),
};

@@ -77,3 +65,3 @@ var optsAndBody = operations.map(function (operation) {

if (!options.signal) {
var _a = apollo_link_http_common_1.createSignalIfSupported(), _controller = _a.controller, signal = _a.signal;
var _b = apollo_link_http_common_1.createSignalIfSupported(), _controller = _b.controller, signal = _b.signal;
controller = _controller;

@@ -80,0 +68,0 @@ if (controller)

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

import { __extends, __rest, __assign } from 'tslib';
import { ApolloLink, fromError, Observable } from 'apollo-link';

@@ -5,47 +6,7 @@ import { checkFetcher, selectURI, selectHttpOptionsAndBody, fallbackHttpConfig, serializeFetchParameter, createSignalIfSupported, parseAndCheckHttpResponse } from 'apollo-link-http-common';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
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 extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
}
var BatchHttpLink = (function (_super) {
__extends(BatchHttpLink, _super);
function BatchHttpLink(fetchParams) {
if (fetchParams === void 0) { fetchParams = {}; }
var _this = _super.call(this) || this;
var _a = fetchParams.uri, uri = _a === void 0 ? '/graphql' : _a, fetcher = fetchParams.fetch, includeExtensions = fetchParams.includeExtensions, batchInterval = fetchParams.batchInterval, batchMax = fetchParams.batchMax, batchKey = fetchParams.batchKey, requestOptions = __rest(fetchParams, ["uri", "fetch", "includeExtensions", "batchInterval", "batchMax", "batchKey"]);
var _a = fetchParams || {}, _b = _a.uri, uri = _b === void 0 ? '/graphql' : _b, fetcher = _a.fetch, includeExtensions = _a.includeExtensions, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchKey = _a.batchKey, requestOptions = __rest(_a, ["uri", "fetch", "includeExtensions", "batchInterval", "batchMax", "batchKey"]);
checkFetcher(fetcher);

@@ -66,2 +27,12 @@ if (!fetcher) {

var context = operations[0].getContext();
var clientAwarenessHeaders = {};
if (context.clientAwareness) {
var _a = context.clientAwareness, name_1 = _a.name, version = _a.version;
if (name_1) {
clientAwarenessHeaders['apollographql-client-name'] = name_1;
}
if (version) {
clientAwarenessHeaders['apollographql-client-version'] = version;
}
}
var contextConfig = {

@@ -71,3 +42,3 @@ http: context.http,

credentials: context.credentials,
headers: context.headers,
headers: __assign({}, clientAwarenessHeaders, context.headers),
};

@@ -93,3 +64,3 @@ var optsAndBody = operations.map(function (operation) {

if (!options.signal) {
var _a = createSignalIfSupported(), _controller = _a.controller, signal = _a.signal;
var _b = createSignalIfSupported(), _controller = _b.controller, signal = _b.signal;
controller = _controller;

@@ -96,0 +67,0 @@ if (controller)

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-link'), require('apollo-link-http-common'), require('apollo-link-batch')) :
typeof define === 'function' && define.amd ? define(['exports', 'apollo-link', 'apollo-link-http-common', 'apollo-link-batch'], factory) :
(global = global || self, factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.batchHttp = {}), global.apolloLink.core, global.apolloLink.httpCommon, global.apolloLink.batch));
}(this, function (exports, apolloLink, apolloLinkHttpCommon, apolloLinkBatch) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib'), require('apollo-link'), require('apollo-link-http-common'), require('apollo-link-batch')) :
typeof define === 'function' && define.amd ? define(['exports', 'tslib', 'apollo-link', 'apollo-link-http-common', 'apollo-link-batch'], factory) :
(global = global || self, factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.batchHttp = {}), global.tslib, global.apolloLink.core, global.apolloLink.httpCommon, global.apolloLink.batch));
}(this, function (exports, tslib_1, apolloLink, apolloLinkHttpCommon, apolloLinkBatch) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
var BatchHttpLink = (function (_super) {
tslib_1.__extends(BatchHttpLink, _super);
function BatchHttpLink(fetchParams) {
var _this = _super.call(this) || this;
var _a = fetchParams || {}, _b = _a.uri, uri = _b === void 0 ? '/graphql' : _b, fetcher = _a.fetch, includeExtensions = _a.includeExtensions, batchInterval = _a.batchInterval, batchMax = _a.batchMax, batchKey = _a.batchKey, requestOptions = tslib_1.__rest(_a, ["uri", "fetch", "includeExtensions", "batchInterval", "batchMax", "batchKey"]);
apolloLinkHttpCommon.checkFetcher(fetcher);
if (!fetcher) {
fetcher = fetch;
}
var linkConfig = {
http: { includeExtensions: includeExtensions },
options: requestOptions.fetchOptions,
credentials: requestOptions.credentials,
headers: requestOptions.headers,
};
_this.batchInterval = batchInterval || 10;
_this.batchMax = batchMax || 10;
var batchHandler = function (operations) {
var chosenURI = apolloLinkHttpCommon.selectURI(operations[0], uri);
var context = operations[0].getContext();
var clientAwarenessHeaders = {};
if (context.clientAwareness) {
var _a = context.clientAwareness, name_1 = _a.name, version = _a.version;
if (name_1) {
clientAwarenessHeaders['apollographql-client-name'] = name_1;
}
if (version) {
clientAwarenessHeaders['apollographql-client-version'] = version;
}
}
var contextConfig = {
http: context.http,
options: context.fetchOptions,
credentials: context.credentials,
headers: tslib_1.__assign({}, clientAwarenessHeaders, context.headers),
};
var optsAndBody = operations.map(function (operation) {
return apolloLinkHttpCommon.selectHttpOptionsAndBody(operation, apolloLinkHttpCommon.fallbackHttpConfig, linkConfig, contextConfig);
});
var loadedBody = optsAndBody.map(function (_a) {
var body = _a.body;
return body;
});
var options = optsAndBody[0].options;
if (options.method === 'GET') {
return apolloLink.fromError(new Error('apollo-link-batch-http does not support GET requests'));
}
try {
options.body = apolloLinkHttpCommon.serializeFetchParameter(loadedBody, 'Payload');
}
catch (parseError) {
return apolloLink.fromError(parseError);
}
var controller;
if (!options.signal) {
var _b = apolloLinkHttpCommon.createSignalIfSupported(), _controller = _b.controller, signal = _b.signal;
controller = _controller;
if (controller)
options.signal = signal;
}
return new apolloLink.Observable(function (observer) {
fetcher(chosenURI, options)
.then(function (response) {
operations.forEach(function (operation) { return operation.setContext({ response: response }); });
return response;
})
.then(apolloLinkHttpCommon.parseAndCheckHttpResponse(operations))
.then(function (result) {
observer.next(result);
observer.complete();
return result;
})
.catch(function (err) {
if (err.name === 'AbortError')
return;
if (err.result && err.result.errors && err.result.data) {
observer.next(err.result);
}
observer.error(err);
});
return function () {
if (controller)
controller.abort();
};
});
};
batchKey =
batchKey ||
(function (operation) {
var context = operation.getContext();
var contextConfig = {
http: context.http,
options: context.fetchOptions,
credentials: context.credentials,
headers: context.headers,
};
return apolloLinkHttpCommon.selectURI(operation, uri) + JSON.stringify(contextConfig);
});
_this.batcher = new apolloLinkBatch.BatchLink({
batchInterval: _this.batchInterval,
batchMax: _this.batchMax,
batchKey: batchKey,
batchHandler: batchHandler,
});
return _this;
}
BatchHttpLink.prototype.request = function (operation) {
return this.batcher.request(operation);
};
return BatchHttpLink;
}(apolloLink.ApolloLink));
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
exports.BatchHttpLink = BatchHttpLink;
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
Object.defineProperty(exports, '__esModule', { value: true });
var extendStatics = function(d, b) {
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 extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
}
var BatchHttpLink = (function (_super) {
__extends(BatchHttpLink, _super);
function BatchHttpLink(fetchParams) {
if (fetchParams === void 0) { fetchParams = {}; }
var _this = _super.call(this) || this;
var _a = fetchParams.uri, uri = _a === void 0 ? '/graphql' : _a, fetcher = fetchParams.fetch, includeExtensions = fetchParams.includeExtensions, batchInterval = fetchParams.batchInterval, batchMax = fetchParams.batchMax, batchKey = fetchParams.batchKey, requestOptions = __rest(fetchParams, ["uri", "fetch", "includeExtensions", "batchInterval", "batchMax", "batchKey"]);
apolloLinkHttpCommon.checkFetcher(fetcher);
if (!fetcher) {
fetcher = fetch;
}
var linkConfig = {
http: { includeExtensions: includeExtensions },
options: requestOptions.fetchOptions,
credentials: requestOptions.credentials,
headers: requestOptions.headers,
};
_this.batchInterval = batchInterval || 10;
_this.batchMax = batchMax || 10;
var batchHandler = function (operations) {
var chosenURI = apolloLinkHttpCommon.selectURI(operations[0], uri);
var context = operations[0].getContext();
var contextConfig = {
http: context.http,
options: context.fetchOptions,
credentials: context.credentials,
headers: context.headers,
};
var optsAndBody = operations.map(function (operation) {
return apolloLinkHttpCommon.selectHttpOptionsAndBody(operation, apolloLinkHttpCommon.fallbackHttpConfig, linkConfig, contextConfig);
});
var loadedBody = optsAndBody.map(function (_a) {
var body = _a.body;
return body;
});
var options = optsAndBody[0].options;
if (options.method === 'GET') {
return apolloLink.fromError(new Error('apollo-link-batch-http does not support GET requests'));
}
try {
options.body = apolloLinkHttpCommon.serializeFetchParameter(loadedBody, 'Payload');
}
catch (parseError) {
return apolloLink.fromError(parseError);
}
var controller;
if (!options.signal) {
var _a = apolloLinkHttpCommon.createSignalIfSupported(), _controller = _a.controller, signal = _a.signal;
controller = _controller;
if (controller)
options.signal = signal;
}
return new apolloLink.Observable(function (observer) {
fetcher(chosenURI, options)
.then(function (response) {
operations.forEach(function (operation) { return operation.setContext({ response: response }); });
return response;
})
.then(apolloLinkHttpCommon.parseAndCheckHttpResponse(operations))
.then(function (result) {
observer.next(result);
observer.complete();
return result;
})
.catch(function (err) {
if (err.name === 'AbortError')
return;
if (err.result && err.result.errors && err.result.data) {
observer.next(err.result);
}
observer.error(err);
});
return function () {
if (controller)
controller.abort();
};
});
};
batchKey =
batchKey ||
(function (operation) {
var context = operation.getContext();
var contextConfig = {
http: context.http,
options: context.fetchOptions,
credentials: context.credentials,
headers: context.headers,
};
return apolloLinkHttpCommon.selectURI(operation, uri) + JSON.stringify(contextConfig);
});
_this.batcher = new apolloLinkBatch.BatchLink({
batchInterval: _this.batchInterval,
batchMax: _this.batchMax,
batchKey: batchKey,
batchHandler: batchHandler,
});
return _this;
}
BatchHttpLink.prototype.request = function (operation) {
return this.batcher.request(operation);
};
return BatchHttpLink;
}(apolloLink.ApolloLink));
exports.BatchHttpLink = BatchHttpLink;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=bundle.umd.js.map
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./batchHttpLink"));
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./batchHttpLink"), exports);
//# sourceMappingURL=index.js.map
{
"name": "apollo-link-batch-http",
"version": "1.2.8",
"version": "1.2.9",
"description": "Batch HTTP transport layer for GraphQL",

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

"typings": "./lib/index.d.ts",
"sideEffects": false,
"repository": {

@@ -26,21 +27,17 @@ "type": "git",

"scripts": {
"build:browser": "browserify ./lib/bundle.umd.js -o=./lib/bundle.js --i apollo-link && npm run minify:browser",
"build": "tsc -p ./tsconfig.cjs.json",
"bundle": "rollup -c",
"build": "tsc && rollup -c",
"coverage": "jest --coverage",
"clean": "rimraf lib/* && rimraf coverage/*",
"filesize": "npm run build && npm run build:browser",
"filesize": "../../scripts/minify",
"lint": "tslint -c \"../../tslint.json\" -p tsconfig.json -c ../../tslint.json src/*.ts",
"minify:browser": "uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js",
"postbuild": "npm run bundle",
"prebuild": "npm run clean",
"prepare": "npm run lint && npm run build",
"prepublishOnly": "npm run clean && npm run build",
"test": "jest",
"prepare": "npm run build",
"test": "npm run lint && jest",
"watch": "tsc -w -p . & rollup -c -w"
},
"dependencies": {
"apollo-link": "^1.2.8",
"apollo-link-batch": "^1.1.9",
"apollo-link-http-common": "^0.2.10"
"apollo-link": "^1.2.9",
"apollo-link-batch": "^1.1.10",
"apollo-link-http-common": "^0.2.11",
"tslib": "^1.9.3"
},

@@ -51,5 +48,4 @@ "peerDependencies": {

"devDependencies": {
"@types/graphql": "14.0.5",
"@types/graphql": "14.0.7",
"@types/jest": "22.2.3",
"browserify": "16.2.3",
"fetch-mock": "6.5.2",

@@ -62,7 +58,6 @@ "graphql": "14.1.1",

"rimraf": "2.6.3",
"rollup": "0.68.2",
"rollup": "1.4.1",
"ts-jest": "22.4.6",
"tslint": "5.12.1",
"typescript": "3.0.3",
"uglify-js": "3.4.9"
"tslint": "5.13.1",
"typescript": "3.0.3"
},

@@ -86,3 +81,3 @@ "jest": {

},
"gitHead": "6f5d0cfb73e61c6f83caed9e37d37c4451a64c7b"
"gitHead": "2c960e057de9d664855bb18df4a4bd25c88bb6ef"
}

@@ -53,3 +53,3 @@ ---

operation in the batch. They are applied to the fetch options in a similar
manner as [apollo-link-http](http.html#context).
manner as [apollo-link-http](https://www.apollographql.com/docs/link/links/http.html#context).

@@ -56,0 +56,0 @@ * `headers`: an object representing values to be sent as headers on the request

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