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

apollo-link-http

Package Overview
Dependencies
Maintainers
3
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-link-http - npm Package Compare versions

Comparing version 1.5.5 to 1.5.6

9

CHANGELOG.md
# Change log
### 1.5.6
- If `name` or `version` client awareness settings are found in the
incoming `operation` `context`, they'll be extracted and added as headers
to all outgoing requests. The header names used (`apollographql-client-name`
and `apollographql-client-version`) line up with the associated Apollo Server
changes made in https://github.com/apollographql/apollo-server/pull/1960. <br/>
[@hwillson](http://github.com/hwillson) in [#872](https://github.com/apollographql/apollo-link/pull/872)
### 1.5.5

@@ -4,0 +13,0 @@ - Added `graphql` 14 to peer and dev deps; Updated `@types/graphql` to 14 <br/>

32

lib/bundle.umd.js

@@ -21,2 +21,13 @@ (function (global, factory) {

})();
var __assign = (undefined && undefined.__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);
};
var __rest = (undefined && undefined.__rest) || function (s, e) {

@@ -53,2 +64,15 @@ var t = {};

var context = operation.getContext();
// `apollographql-client-*` headers are automatically set if a
// `clientAwareness` object is found in the context. These headers are
// set first, followed by the rest of the headers pulled from
// `context.headers`. If desired, `apollographql-client-*` headers set by
// the `clientAwareness` object can be overridden by
// `apollographql-client-*` headers set in `context.headers`.
var clientAwarenessHeaders = {};
if (context.clientAwareness) {
var _a = context.clientAwareness, name_1 = _a.name, version = _a.version;
clientAwarenessHeaders['apollographql-client-name'] = name_1;
clientAwarenessHeaders['apollographql-client-version'] = version;
}
var contextHeaders = __assign({}, clientAwarenessHeaders, context.headers);
var contextConfig = {

@@ -58,9 +82,9 @@ http: context.http,

credentials: context.credentials,
headers: context.headers,
headers: contextHeaders,
};
//uses fallback, link, and then context to build options
var _a = apolloLinkHttpCommon.selectHttpOptionsAndBody(operation, apolloLinkHttpCommon.fallbackHttpConfig, linkConfig, contextConfig), options = _a.options, body = _a.body;
var _b = apolloLinkHttpCommon.selectHttpOptionsAndBody(operation, apolloLinkHttpCommon.fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
var controller;
if (!options.signal) {
var _b = apolloLinkHttpCommon.createSignalIfSupported(), _controller = _b.controller, signal = _b.signal;
var _c = apolloLinkHttpCommon.createSignalIfSupported(), _controller = _c.controller, signal = _c.signal;
controller = _controller;

@@ -79,3 +103,3 @@ if (controller)

if (options.method === 'GET') {
var _c = rewriteURIForGET(chosenURI, body), newURI = _c.newURI, parseError = _c.parseError;
var _d = rewriteURIForGET(chosenURI, body), newURI = _d.newURI, parseError = _d.parseError;
if (parseError) {

@@ -82,0 +106,0 @@ return apolloLink.fromError(parseError);

@@ -15,2 +15,13 @@ /* tslint:disable */

})();
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);
};
var __rest = (this && this.__rest) || function (s, e) {

@@ -49,2 +60,15 @@ var t = {};

var context = operation.getContext();
// `apollographql-client-*` headers are automatically set if a
// `clientAwareness` object is found in the context. These headers are
// set first, followed by the rest of the headers pulled from
// `context.headers`. If desired, `apollographql-client-*` headers set by
// the `clientAwareness` object can be overridden by
// `apollographql-client-*` headers set in `context.headers`.
var clientAwarenessHeaders = {};
if (context.clientAwareness) {
var _a = context.clientAwareness, name_1 = _a.name, version = _a.version;
clientAwarenessHeaders['apollographql-client-name'] = name_1;
clientAwarenessHeaders['apollographql-client-version'] = version;
}
var contextHeaders = __assign({}, clientAwarenessHeaders, context.headers);
var contextConfig = {

@@ -54,9 +78,9 @@ http: context.http,

credentials: context.credentials,
headers: context.headers,
headers: contextHeaders,
};
//uses fallback, link, and then context to build options
var _a = selectHttpOptionsAndBody(operation, fallbackHttpConfig, linkConfig, contextConfig), options = _a.options, body = _a.body;
var _b = selectHttpOptionsAndBody(operation, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
var controller;
if (!options.signal) {
var _b = createSignalIfSupported(), _controller = _b.controller, signal = _b.signal;
var _c = createSignalIfSupported(), _controller = _c.controller, signal = _c.signal;
controller = _controller;

@@ -75,3 +99,3 @@ if (controller)

if (options.method === 'GET') {
var _c = rewriteURIForGET(chosenURI, body), newURI = _c.newURI, parseError = _c.parseError;
var _d = rewriteURIForGET(chosenURI, body), newURI = _d.newURI, parseError = _d.parseError;
if (parseError) {

@@ -78,0 +102,0 @@ return fromError(parseError);

14

package.json
{
"name": "apollo-link-http",
"version": "1.5.5",
"version": "1.5.6",
"description": "HTTP transport layer for GraphQL",

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

"dependencies": {
"apollo-link": "^1.2.3",
"apollo-link-http-common": "^0.2.5"
"apollo-link": "^1.2.4",
"apollo-link-http-common": "^0.2.6"
},

@@ -50,13 +50,13 @@ "peerDependencies": {

"devDependencies": {
"@types/graphql": "14.0.0",
"@types/graphql": "14.0.3",
"@types/jest": "22.2.3",
"apollo-fetch": "0.7.0",
"browserify": "16.2.2",
"browserify": "16.2.3",
"fetch-mock": "6.5.2",
"graphql": "14.0.2",
"graphql-tag": "2.9.2",
"graphql-tag": "2.10.0",
"jest": "22.4.4",
"object-to-querystring": "1.0.8",
"rimraf": "2.6.1",
"rollup": "0.65.2",
"rollup": "0.67.3",
"ts-jest": "22.4.6",

@@ -63,0 +63,0 @@ "tslint": "5.11.0",

@@ -186,2 +186,35 @@ import { Observable, ApolloLink, execute } from 'apollo-link';

});
it('should add client awareness settings to request headers', done => {
const variables = { params: 'stub' };
const link = createHttpLink({
uri: 'http://data/',
});
const clientAwareness = {
name: 'Some Client Name',
version: '1.0.1',
};
execute(link, {
query: sampleQuery,
variables,
context: {
clientAwareness,
},
}).subscribe(
makeCallback(done, result => {
const [uri, options] = fetchMock.lastCall();
const { headers } = options;
expect(headers['apollographql-client-name']).toBeDefined();
expect(headers['apollographql-client-name']).toEqual(
clientAwareness.name,
);
expect(headers['apollographql-client-version']).toBeDefined();
expect(headers['apollographql-client-version']).toEqual(
clientAwareness.version,
);
}),
);
});
});

@@ -188,0 +221,0 @@

@@ -67,2 +67,17 @@ /* tslint:disable */

// `apollographql-client-*` headers are automatically set if a
// `clientAwareness` object is found in the context. These headers are
// set first, followed by the rest of the headers pulled from
// `context.headers`. If desired, `apollographql-client-*` headers set by
// the `clientAwareness` object can be overridden by
// `apollographql-client-*` headers set in `context.headers`.
const clientAwarenessHeaders = {};
if (context.clientAwareness) {
const { name, version } = context.clientAwareness;
clientAwarenessHeaders['apollographql-client-name'] = name;
clientAwarenessHeaders['apollographql-client-version'] = version;
}
const contextHeaders = { ...clientAwarenessHeaders, ...context.headers };
const contextConfig = {

@@ -72,3 +87,3 @@ http: context.http,

credentials: context.credentials,
headers: context.headers,
headers: contextHeaders,
};

@@ -75,0 +90,0 @@

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