Huge News!Announcing our $40M Series B led by Abstract Ventures.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.4 to 1.6.0-alpha.0

60

lib/bundle.umd.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-link'), require('apollo-link-http-common')) :
typeof define === 'function' && define.amd ? define(['exports', 'apollo-link', 'apollo-link-http-common'], factory) :
(factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.http = {}),global.apolloLink.core,global.apolloLink.httpCommon));
}(this, (function (exports,apolloLink,apolloLinkHttpCommon) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-link'), require('apollo-link-http-common'), require('text-encoding')) :
typeof define === 'function' && define.amd ? define(['exports', 'apollo-link', 'apollo-link-http-common', 'text-encoding'], factory) :
(factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.http = {}),global.apolloLink.core,global.apolloLink.httpCommon,null));
}(this, (function (exports,apolloLink,apolloLinkHttpCommon,textEncoding) { 'use strict';

@@ -92,8 +92,48 @@ var __extends = (undefined && undefined.__extends) || (function () {

})
.then(apolloLinkHttpCommon.parseAndCheckHttpResponse(operation))
.then(function (result) {
// we have data and can send it to back up the link chain
observer.next(result);
observer.complete();
return result;
.then(function (response) {
// @defer uses multipart responses to stream patches over HTTP
if (response.status < 300 &&
response.headers &&
response.headers.get('Content-Type') &&
response.headers.get('Content-Type').indexOf('multipart/mixed') >= 0) {
var reader_1 = response.body.getReader();
var textDecoder_1 = new textEncoding.TextDecoder();
reader_1.read().then(function sendNext(_a) {
var value = _a.value, done = _a.done;
if (!done) {
var plaintext = void 0;
try {
plaintext = textDecoder_1.decode(value);
// Split plaintext using encapsulation boundary
// See: https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
var payloads = plaintext.split('\r\n---\r\n');
for (var _i = 0, payloads_1 = payloads; _i < payloads_1.length; _i++) {
var payload = payloads_1[_i];
if (payload.length && payload !== '\r\n---') {
// Terminator
observer.next(JSON.parse(payload));
}
}
}
catch (err) {
var parseError = err;
parseError.response = response;
parseError.statusCode = response.status;
parseError.bodyText = plaintext;
throw parseError;
}
reader_1.read().then(sendNext);
}
else {
observer.complete();
}
});
}
else {
return apolloLinkHttpCommon.parseAndCheckHttpResponse(operation)(response).then(function (result) {
// we have data and can send it to back up the link chain
observer.next(result);
observer.complete();
});
}
})

@@ -100,0 +140,0 @@ .catch(function (err) {

@@ -20,4 +20,5 @@ var __extends = (this && this.__extends) || (function () {

};
import { ApolloLink, Observable, fromError } from 'apollo-link';
import { ApolloLink, Observable, fromError, } from 'apollo-link';
import { serializeFetchParameter, selectURI, parseAndCheckHttpResponse, checkFetcher, selectHttpOptionsAndBody, createSignalIfSupported, fallbackHttpConfig, } from 'apollo-link-http-common';
import { TextDecoder } from 'text-encoding';
export var createHttpLink = function (linkOptions) {

@@ -89,8 +90,48 @@ if (linkOptions === void 0) { linkOptions = {}; }

})
.then(parseAndCheckHttpResponse(operation))
.then(function (result) {
// we have data and can send it to back up the link chain
observer.next(result);
observer.complete();
return result;
.then(function (response) {
// @defer uses multipart responses to stream patches over HTTP
if (response.status < 300 &&
response.headers &&
response.headers.get('Content-Type') &&
response.headers.get('Content-Type').indexOf('multipart/mixed') >= 0) {
var reader_1 = response.body.getReader();
var textDecoder_1 = new TextDecoder();
reader_1.read().then(function sendNext(_a) {
var value = _a.value, done = _a.done;
if (!done) {
var plaintext = void 0;
try {
plaintext = textDecoder_1.decode(value);
// Split plaintext using encapsulation boundary
// See: https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
var payloads = plaintext.split('\r\n---\r\n');
for (var _i = 0, payloads_1 = payloads; _i < payloads_1.length; _i++) {
var payload = payloads_1[_i];
if (payload.length && payload !== '\r\n---') {
// Terminator
observer.next(JSON.parse(payload));
}
}
}
catch (err) {
var parseError = err;
parseError.response = response;
parseError.statusCode = response.status;
parseError.bodyText = plaintext;
throw parseError;
}
reader_1.read().then(sendNext);
}
else {
observer.complete();
}
});
}
else {
return parseAndCheckHttpResponse(operation)(response).then(function (result) {
// we have data and can send it to back up the link chain
observer.next(result);
observer.complete();
});
}
})

@@ -97,0 +138,0 @@ .catch(function (err) {

26

package.json
{
"name": "apollo-link-http",
"version": "1.5.4",
"version": "1.6.0-alpha.0",
"description": "HTTP transport layer for GraphQL",

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

"apollo-link": "^1.2.2",
"apollo-link-http-common": "^0.2.4"
"apollo-link-http-common": "^0.2.4",
"text-encoding": "^0.6.4"
},

@@ -51,16 +52,17 @@ "peerDependencies": {

"@types/graphql": "0.12.6",
"@types/jest": "22.2.2",
"@types/jest": "22.2.3",
"@types/text-encoding": "0.0.33",
"apollo-fetch": "0.7.0",
"browserify": "16.1.1",
"fetch-mock": "6.0.0",
"browserify": "16.2.2",
"fetch-mock": "6.5.1",
"graphql": "0.13.2",
"graphql-tag": "2.8.0",
"jest": "22.4.3",
"graphql-tag": "2.9.2",
"jest": "22.4.4",
"object-to-querystring": "1.0.8",
"rimraf": "2.6.1",
"rollup": "0.57.1",
"ts-jest": "21.2.4",
"tslint": "5.9.1",
"typescript": "2.7.2",
"uglify-js": "3.3.16"
"rollup": "0.62.0",
"ts-jest": "22.4.6",
"tslint": "5.11.0",
"typescript": "2.9.2",
"uglify-js": "3.4.5"
},

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

@@ -1,3 +0,9 @@

import { ApolloLink, Observable, RequestHandler, fromError } from 'apollo-link';
import {
ApolloLink,
Observable,
RequestHandler,
fromError,
FetchResult,
} from 'apollo-link';
import {
serializeFetchParameter,

@@ -15,2 +21,3 @@ selectURI,

import { DefinitionNode } from 'graphql';
import { TextDecoder } from 'text-encoding';

@@ -33,2 +40,3 @@ export namespace HttpLink {

export import UriFunction = HttpLink.UriFunction;
import { ServerParseError } from 'apollo-link-http-common';

@@ -120,8 +128,47 @@ export const createHttpLink = (linkOptions: HttpLink.Options = {}) => {

})
.then(parseAndCheckHttpResponse(operation))
.then(result => {
// we have data and can send it to back up the link chain
observer.next(result);
observer.complete();
return result;
.then(response => {
// @defer uses multipart responses to stream patches over HTTP
if (
response.status < 300 &&
response.headers &&
response.headers.get('Content-Type') &&
response.headers.get('Content-Type').indexOf('multipart/mixed') >= 0
) {
const reader = response.body.getReader();
const textDecoder = new TextDecoder();
reader.read().then(function sendNext({ value, done }) {
if (!done) {
let plaintext;
try {
plaintext = textDecoder.decode(value);
// Split plaintext using encapsulation boundary
// See: https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
const payloads = plaintext.split('\r\n---\r\n');
for (const payload of payloads) {
if (payload.length && payload !== '\r\n---') {
// Terminator
observer.next(JSON.parse(payload) as FetchResult);
}
}
} catch (err) {
const parseError = err as ServerParseError;
parseError.response = response;
parseError.statusCode = response.status;
parseError.bodyText = plaintext;
throw parseError;
}
reader.read().then(sendNext);
} else {
observer.complete();
}
});
} else {
return parseAndCheckHttpResponse(operation)(response).then(
result => {
// we have data and can send it to back up the link chain
observer.next(result);
observer.complete();
},
);
}
})

@@ -128,0 +175,0 @@ .catch(err => {

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