Socket
Socket
Sign inDemoInstall

apollo-link-http-common

Package Overview
Dependencies
10
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.10 to 0.2.11

.rpt2_cache/rpt2_0f34fcfe0e17ca7dfa1bbbcaf4d78d0ce43e4d8e/code/cache_/352752c61d7568292ae433e7525813ad69be75c9

32

lib/bundle.esm.js

@@ -0,29 +1,5 @@

import { __assign } from 'tslib';
import { print } from 'graphql/language/printer';
import { InvariantError } from 'ts-invariant';
/*! *****************************************************************************
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.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(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;
};
return __assign.apply(this, arguments);
};
var defaultHttpOptions = {

@@ -88,3 +64,3 @@ includeQuery: true,

library = 'node-fetch';
throw new Error("\nfetch is not found globally and no fetcher passed, to fix pass a fetch for\nyour environment like https://www.npmjs.com/package/" + library + ".\n\nFor example:\nimport fetch from '" + library + "';\nimport { createHttpLink } from 'apollo-link-http';\n\nconst link = createHttpLink({ uri: '/graphql', fetch: fetch });");
throw process.env.NODE_ENV === "production" ? new InvariantError(1) : new InvariantError("\nfetch is not found globally and no fetcher passed, to fix pass a fetch for\nyour environment like https://www.npmjs.com/package/" + library + ".\n\nFor example:\nimport fetch from '" + library + "';\nimport { createHttpLink } from 'apollo-link-http';\n\nconst link = createHttpLink({ uri: '/graphql', fetch: fetch });");
}

@@ -129,3 +105,3 @@ };

catch (e) {
var parseError = new Error("Network request failed. " + label + " is not serializable: " + e.message);
var parseError = process.env.NODE_ENV === "production" ? new InvariantError(2) : new InvariantError("Network request failed. " + label + " is not serializable: " + e.message);
parseError.parseError = e;

@@ -132,0 +108,0 @@ throw parseError;

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('graphql/language/printer')) :
typeof define === 'function' && define.amd ? define(['exports', 'graphql/language/printer'], factory) :
(global = global || self, factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.httpCommon = {}), global.printer));
}(this, function (exports, printer) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib'), require('graphql/language/printer'), require('ts-invariant')) :
typeof define === 'function' && define.amd ? define(['exports', 'tslib', 'graphql/language/printer', 'ts-invariant'], factory) :
(global = global || self, factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.httpCommon = {}), global.tslib, global.graphql.printer, global.invariant));
}(this, function (exports, tslib_1, printer, tsInvariant) { '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 defaultHttpOptions = {
includeQuery: true,
includeExtensions: false,
};
var defaultHeaders = {
accept: '*/*',
'content-type': 'application/json',
};
var defaultOptions = {
method: 'POST',
};
var fallbackHttpConfig = {
http: defaultHttpOptions,
headers: defaultHeaders,
options: defaultOptions,
};
var throwServerError = function (response, result, message) {
var error = new Error(message);
error.name = 'ServerError';
error.response = response;
error.statusCode = response.status;
error.result = result;
throw error;
};
var parseAndCheckHttpResponse = function (operations) { return function (response) {
return (response
.text()
.then(function (bodyText) {
try {
return JSON.parse(bodyText);
}
catch (err) {
var parseError = err;
parseError.name = 'ServerParseError';
parseError.response = response;
parseError.statusCode = response.status;
parseError.bodyText = bodyText;
return Promise.reject(parseError);
}
})
.then(function (result) {
if (response.status >= 300) {
throwServerError(response, result, "Response not successful: Received status code " + response.status);
}
if (!Array.isArray(result) &&
!result.hasOwnProperty('data') &&
!result.hasOwnProperty('errors')) {
throwServerError(response, result, "Server response was missing for query '" + (Array.isArray(operations)
? operations.map(function (op) { return op.operationName; })
: operations.operationName) + "'.");
}
return result;
}));
}; };
var checkFetcher = function (fetcher) {
if (!fetcher && typeof fetch === 'undefined') {
var library = 'unfetch';
if (typeof window === 'undefined')
library = 'node-fetch';
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(1) : new tsInvariant.InvariantError("\nfetch is not found globally and no fetcher passed, to fix pass a fetch for\nyour environment like https://www.npmjs.com/package/" + library + ".\n\nFor example:\nimport fetch from '" + library + "';\nimport { createHttpLink } from 'apollo-link-http';\n\nconst link = createHttpLink({ uri: '/graphql', fetch: fetch });");
}
};
var createSignalIfSupported = function () {
if (typeof AbortController === 'undefined')
return { controller: false, signal: false };
var controller = new AbortController();
var signal = controller.signal;
return { controller: controller, signal: signal };
};
var selectHttpOptionsAndBody = function (operation, fallbackConfig) {
var configs = [];
for (var _i = 2; _i < arguments.length; _i++) {
configs[_i - 2] = arguments[_i];
}
var options = tslib_1.__assign({}, fallbackConfig.options, { headers: fallbackConfig.headers, credentials: fallbackConfig.credentials });
var http = fallbackConfig.http;
configs.forEach(function (config) {
options = tslib_1.__assign({}, options, config.options, { headers: tslib_1.__assign({}, options.headers, config.headers) });
if (config.credentials)
options.credentials = config.credentials;
http = tslib_1.__assign({}, http, config.http);
});
var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
var body = { operationName: operationName, variables: variables };
if (http.includeExtensions)
body.extensions = extensions;
if (http.includeQuery)
body.query = printer.print(query);
return {
options: options,
body: body,
};
};
var serializeFetchParameter = function (p, label) {
var serialized;
try {
serialized = JSON.stringify(p);
}
catch (e) {
var parseError = process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(2) : new tsInvariant.InvariantError("Network request failed. " + label + " is not serializable: " + e.message);
parseError.parseError = e;
throw parseError;
}
return serialized;
};
var selectURI = function (operation, fallbackURI) {
var context = operation.getContext();
var contextURI = context.uri;
if (contextURI) {
return contextURI;
}
else if (typeof fallbackURI === 'function') {
return fallbackURI(operation);
}
else {
return fallbackURI || '/graphql';
}
};
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.fallbackHttpConfig = fallbackHttpConfig;
exports.throwServerError = throwServerError;
exports.parseAndCheckHttpResponse = parseAndCheckHttpResponse;
exports.checkFetcher = checkFetcher;
exports.createSignalIfSupported = createSignalIfSupported;
exports.selectHttpOptionsAndBody = selectHttpOptionsAndBody;
exports.serializeFetchParameter = serializeFetchParameter;
exports.selectURI = selectURI;
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
Object.defineProperty(exports, '__esModule', { value: true });
var __assign = function() {
__assign = Object.assign || function __assign(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;
};
return __assign.apply(this, arguments);
};
var defaultHttpOptions = {
includeQuery: true,
includeExtensions: false,
};
var defaultHeaders = {
accept: '*/*',
'content-type': 'application/json',
};
var defaultOptions = {
method: 'POST',
};
var fallbackHttpConfig = {
http: defaultHttpOptions,
headers: defaultHeaders,
options: defaultOptions,
};
var throwServerError = function (response, result, message) {
var error = new Error(message);
error.name = 'ServerError';
error.response = response;
error.statusCode = response.status;
error.result = result;
throw error;
};
var parseAndCheckHttpResponse = function (operations) { return function (response) {
return (response
.text()
.then(function (bodyText) {
try {
return JSON.parse(bodyText);
}
catch (err) {
var parseError = err;
parseError.name = 'ServerParseError';
parseError.response = response;
parseError.statusCode = response.status;
parseError.bodyText = bodyText;
return Promise.reject(parseError);
}
})
.then(function (result) {
if (response.status >= 300) {
throwServerError(response, result, "Response not successful: Received status code " + response.status);
}
if (!Array.isArray(result) &&
!result.hasOwnProperty('data') &&
!result.hasOwnProperty('errors')) {
throwServerError(response, result, "Server response was missing for query '" + (Array.isArray(operations)
? operations.map(function (op) { return op.operationName; })
: operations.operationName) + "'.");
}
return result;
}));
}; };
var checkFetcher = function (fetcher) {
if (!fetcher && typeof fetch === 'undefined') {
var library = 'unfetch';
if (typeof window === 'undefined')
library = 'node-fetch';
throw new Error("\nfetch is not found globally and no fetcher passed, to fix pass a fetch for\nyour environment like https://www.npmjs.com/package/" + library + ".\n\nFor example:\nimport fetch from '" + library + "';\nimport { createHttpLink } from 'apollo-link-http';\n\nconst link = createHttpLink({ uri: '/graphql', fetch: fetch });");
}
};
var createSignalIfSupported = function () {
if (typeof AbortController === 'undefined')
return { controller: false, signal: false };
var controller = new AbortController();
var signal = controller.signal;
return { controller: controller, signal: signal };
};
var selectHttpOptionsAndBody = function (operation, fallbackConfig) {
var configs = [];
for (var _i = 2; _i < arguments.length; _i++) {
configs[_i - 2] = arguments[_i];
}
var options = __assign({}, fallbackConfig.options, { headers: fallbackConfig.headers, credentials: fallbackConfig.credentials });
var http = fallbackConfig.http;
configs.forEach(function (config) {
options = __assign({}, options, config.options, { headers: __assign({}, options.headers, config.headers) });
if (config.credentials)
options.credentials = config.credentials;
http = __assign({}, http, config.http);
});
var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
var body = { operationName: operationName, variables: variables };
if (http.includeExtensions)
body.extensions = extensions;
if (http.includeQuery)
body.query = printer.print(query);
return {
options: options,
body: body,
};
};
var serializeFetchParameter = function (p, label) {
var serialized;
try {
serialized = JSON.stringify(p);
}
catch (e) {
var parseError = new Error("Network request failed. " + label + " is not serializable: " + e.message);
parseError.parseError = e;
throw parseError;
}
return serialized;
};
var selectURI = function (operation, fallbackURI) {
var context = operation.getContext();
var contextURI = context.uri;
if (contextURI) {
return contextURI;
}
else if (typeof fallbackURI === 'function') {
return fallbackURI(operation);
}
else {
return fallbackURI || '/graphql';
}
};
exports.fallbackHttpConfig = fallbackHttpConfig;
exports.throwServerError = throwServerError;
exports.parseAndCheckHttpResponse = parseAndCheckHttpResponse;
exports.checkFetcher = checkFetcher;
exports.createSignalIfSupported = createSignalIfSupported;
exports.selectHttpOptionsAndBody = selectHttpOptionsAndBody;
exports.serializeFetchParameter = serializeFetchParameter;
exports.selectURI = selectURI;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=bundle.umd.js.map
import { Operation } from 'apollo-link';
import { InvariantError } from 'ts-invariant';
export declare type ServerError = Error & {

@@ -12,3 +13,3 @@ response: Response;

};
export declare type ClientParseError = Error & {
export declare type ClientParseError = InvariantError & {
parseError: Error;

@@ -15,0 +16,0 @@ };

"use strict";
var __assign = (this && this.__assign) || function () {
__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;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var printer_1 = require("graphql/language/printer");
var ts_invariant_1 = require("ts-invariant");
var defaultHttpOptions = {

@@ -74,3 +65,3 @@ includeQuery: true,

library = 'node-fetch';
throw new Error("\nfetch is not found globally and no fetcher passed, to fix pass a fetch for\nyour environment like https://www.npmjs.com/package/" + library + ".\n\nFor example:\nimport fetch from '" + library + "';\nimport { createHttpLink } from 'apollo-link-http';\n\nconst link = createHttpLink({ uri: '/graphql', fetch: fetch });");
throw new ts_invariant_1.InvariantError("\nfetch is not found globally and no fetcher passed, to fix pass a fetch for\nyour environment like https://www.npmjs.com/package/" + library + ".\n\nFor example:\nimport fetch from '" + library + "';\nimport { createHttpLink } from 'apollo-link-http';\n\nconst link = createHttpLink({ uri: '/graphql', fetch: fetch });");
}

@@ -90,9 +81,9 @@ };

}
var options = __assign({}, fallbackConfig.options, { headers: fallbackConfig.headers, credentials: fallbackConfig.credentials });
var options = tslib_1.__assign({}, fallbackConfig.options, { headers: fallbackConfig.headers, credentials: fallbackConfig.credentials });
var http = fallbackConfig.http;
configs.forEach(function (config) {
options = __assign({}, options, config.options, { headers: __assign({}, options.headers, config.headers) });
options = tslib_1.__assign({}, options, config.options, { headers: tslib_1.__assign({}, options.headers, config.headers) });
if (config.credentials)
options.credentials = config.credentials;
http = __assign({}, http, config.http);
http = tslib_1.__assign({}, http, config.http);
});

@@ -116,3 +107,3 @@ var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;

catch (e) {
var parseError = new Error("Network request failed. " + label + " is not serializable: " + e.message);
var parseError = new ts_invariant_1.InvariantError("Network request failed. " + label + " is not serializable: " + e.message);
parseError.parseError = e;

@@ -119,0 +110,0 @@ throw parseError;

{
"name": "apollo-link-http-common",
"version": "0.2.10",
"version": "0.2.11",
"description": "Http utilities for Apollo Link shared across all links using http",

@@ -8,16 +8,12 @@ "main": "./lib/index.js",

"typings": "./lib/index.d.ts",
"sideEffects": false,
"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",
"clean": "rimraf lib/* && rimraf coverage/*",
"coverage": "jest --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"

@@ -33,3 +29,5 @@ },

"dependencies": {
"apollo-link": "^1.2.8"
"apollo-link": "^1.2.9",
"ts-invariant": "^0.3.2",
"tslib": "^1.9.3"
},

@@ -40,5 +38,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",

@@ -50,7 +47,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"
},

@@ -78,3 +74,3 @@ "repository": {

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc