apollo-link
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -5,4 +5,9 @@ # Change log | ||
### 1.2.2 | ||
- Update apollo-link [#559](https://github.com/apollographql/apollo-link/pull/559) | ||
- export graphql types and add @types/graphql as a regular dependency [PR#576](https://github.com/apollographql/apollo-link/pull/576) | ||
- moved @types/node to dev dependencies in package.josn to avoid collisions with other projects. [PR#540](https://github.com/apollographql/apollo-link/pull/540) | ||
### 1.2.1 | ||
- udate apollo link with zen-observable-ts to remove import issues [PR#515](https://github.com/apollographql/apollo-link/pull/515) | ||
- update apollo link with zen-observable-ts to remove import issues [PR#515](https://github.com/apollographql/apollo-link/pull/515) | ||
@@ -9,0 +14,0 @@ ### 1.2.0 |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-utilities'), require('zen-observable-ts'), require('graphql/language/printer')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'apollo-utilities', 'zen-observable-ts', 'graphql/language/printer'], factory) : | ||
(factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.core = {}),global.apollo.utilities,global.apolloLink.zenObservable,global.printer)); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-utilities'), require('zen-observable-ts'), require('graphql/language/printer')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'apollo-utilities', 'zen-observable-ts', 'graphql/language/printer'], factory) : | ||
(factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.core = {}),global.apollo.utilities,global.apolloLink.zenObservable,global.printer)); | ||
}(this, (function (exports,apolloUtilities,Observable,printer) { 'use strict'; | ||
Observable = Observable && Observable.hasOwnProperty('default') ? Observable['default'] : Observable; | ||
Observable = Observable && Observable.hasOwnProperty('default') ? Observable['default'] : Observable; | ||
var __extends = (undefined && undefined.__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 __extends = (undefined && undefined.__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 = (undefined && undefined.__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; | ||
}; | ||
})(); | ||
var __assign = (undefined && undefined.__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]; | ||
function validateOperation(operation) { | ||
var OPERATION_FIELDS = [ | ||
'query', | ||
'operationName', | ||
'variables', | ||
'extensions', | ||
'context', | ||
]; | ||
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) { | ||
var key = _a[_i]; | ||
if (OPERATION_FIELDS.indexOf(key) < 0) { | ||
throw new Error("illegal argument: " + key); | ||
} | ||
} | ||
return operation; | ||
} | ||
return t; | ||
}; | ||
function validateOperation(operation) { | ||
var OPERATION_FIELDS = [ | ||
'query', | ||
'operationName', | ||
'variables', | ||
'extensions', | ||
'context', | ||
]; | ||
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) { | ||
var key = _a[_i]; | ||
if (OPERATION_FIELDS.indexOf(key) < 0) { | ||
throw new Error("illegal argument: " + key); | ||
var LinkError = /** @class */ (function (_super) { | ||
__extends(LinkError, _super); | ||
function LinkError(message, link) { | ||
var _this = _super.call(this, message) || this; | ||
_this.link = link; | ||
return _this; | ||
} | ||
return LinkError; | ||
}(Error)); | ||
function isTerminating(link) { | ||
return link.request.length <= 1; | ||
} | ||
return operation; | ||
} | ||
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)); | ||
function isTerminating(link) { | ||
return link.request.length <= 1; | ||
} | ||
function toPromise(observable) { | ||
var completed = false; | ||
return new Promise(function (resolve, reject) { | ||
observable.subscribe({ | ||
next: function (data) { | ||
if (completed) { | ||
console.warn("Promise Wrapper does not support multiple results from Observable"); | ||
} | ||
else { | ||
completed = true; | ||
resolve(data); | ||
} | ||
}, | ||
error: reject, | ||
function toPromise(observable) { | ||
var completed = false; | ||
return new Promise(function (resolve, reject) { | ||
observable.subscribe({ | ||
next: function (data) { | ||
if (completed) { | ||
console.warn("Promise Wrapper does not support multiple results from Observable"); | ||
} | ||
else { | ||
completed = true; | ||
resolve(data); | ||
} | ||
}, | ||
error: reject, | ||
}); | ||
}); | ||
}); | ||
} | ||
var makePromise = toPromise; | ||
function fromPromise(promise) { | ||
return new Observable(function (observer) { | ||
promise | ||
.then(function (value) { | ||
observer.next(value); | ||
observer.complete(); | ||
}) | ||
.catch(observer.error.bind(observer)); | ||
}); | ||
} | ||
function fromError(errorValue) { | ||
return new Observable(function (observer) { | ||
observer.error(errorValue); | ||
}); | ||
} | ||
function transformOperation(operation) { | ||
var transformedOperation = { | ||
variables: operation.variables || {}, | ||
extensions: operation.extensions || {}, | ||
operationName: operation.operationName, | ||
query: operation.query, | ||
}; | ||
if (!transformedOperation.operationName) { | ||
transformedOperation.operationName = | ||
typeof transformedOperation.query !== 'string' | ||
? apolloUtilities.getOperationName(transformedOperation.query) | ||
: ''; | ||
} | ||
return transformedOperation; | ||
} | ||
function createOperation(starting, operation) { | ||
var context = __assign({}, starting); | ||
var setContext = function (next) { | ||
if (typeof next === 'function') { | ||
context = __assign({}, context, next(context)); | ||
} | ||
else { | ||
context = __assign({}, context, next); | ||
} | ||
}; | ||
var getContext = function () { return (__assign({}, context)); }; | ||
Object.defineProperty(operation, 'setContext', { | ||
enumerable: false, | ||
value: setContext, | ||
}); | ||
Object.defineProperty(operation, 'getContext', { | ||
enumerable: false, | ||
value: getContext, | ||
}); | ||
Object.defineProperty(operation, 'toKey', { | ||
enumerable: false, | ||
value: function () { return getKey(operation); }, | ||
}); | ||
return operation; | ||
} | ||
function getKey(operation) { | ||
return printer.print(operation.query) + "|" + JSON.stringify(operation.variables) + "|" + operation.operationName; | ||
} | ||
var passthrough = function (op, forward) { return (forward ? forward(op) : Observable.of()); }; | ||
var toLink = function (handler) { | ||
return typeof handler === 'function' ? new ApolloLink(handler) : handler; | ||
}; | ||
var empty = function () { | ||
return new ApolloLink(function (op, forward) { return Observable.of(); }); | ||
}; | ||
var from = function (links) { | ||
if (links.length === 0) | ||
return empty(); | ||
return links.map(toLink).reduce(function (x, y) { return x.concat(y); }); | ||
}; | ||
var split = function (test, left, right) { | ||
if (right === void 0) { right = new ApolloLink(passthrough); } | ||
var leftLink = toLink(left); | ||
var rightLink = toLink(right); | ||
if (isTerminating(leftLink) && isTerminating(rightLink)) { | ||
return new ApolloLink(function (operation) { | ||
return test(operation) | ||
? leftLink.request(operation) || Observable.of() | ||
: rightLink.request(operation) || Observable.of(); | ||
// backwards compat | ||
var makePromise = toPromise; | ||
function fromPromise(promise) { | ||
return new Observable(function (observer) { | ||
promise | ||
.then(function (value) { | ||
observer.next(value); | ||
observer.complete(); | ||
}) | ||
.catch(observer.error.bind(observer)); | ||
}); | ||
} | ||
else { | ||
return new ApolloLink(function (operation, forward) { | ||
return test(operation) | ||
? leftLink.request(operation, forward) || Observable.of() | ||
: rightLink.request(operation, forward) || Observable.of(); | ||
function fromError(errorValue) { | ||
return new Observable(function (observer) { | ||
observer.error(errorValue); | ||
}); | ||
} | ||
}; | ||
var concat = function (first, second) { | ||
var firstLink = toLink(first); | ||
if (isTerminating(firstLink)) { | ||
console.warn(new LinkError("You are calling concat on a terminating link, which will have no effect", firstLink)); | ||
return firstLink; | ||
function transformOperation(operation) { | ||
var transformedOperation = { | ||
variables: operation.variables || {}, | ||
extensions: operation.extensions || {}, | ||
operationName: operation.operationName, | ||
query: operation.query, | ||
}; | ||
// best guess at an operation name | ||
if (!transformedOperation.operationName) { | ||
transformedOperation.operationName = | ||
typeof transformedOperation.query !== 'string' | ||
? apolloUtilities.getOperationName(transformedOperation.query) | ||
: ''; | ||
} | ||
return transformedOperation; | ||
} | ||
var nextLink = toLink(second); | ||
if (isTerminating(nextLink)) { | ||
return new ApolloLink(function (operation) { | ||
return firstLink.request(operation, function (op) { return nextLink.request(op) || Observable.of(); }) || Observable.of(); | ||
function createOperation(starting, operation) { | ||
var context = __assign({}, starting); | ||
var setContext = function (next) { | ||
if (typeof next === 'function') { | ||
context = __assign({}, context, next(context)); | ||
} | ||
else { | ||
context = __assign({}, context, next); | ||
} | ||
}; | ||
var getContext = function () { return (__assign({}, context)); }; | ||
Object.defineProperty(operation, 'setContext', { | ||
enumerable: false, | ||
value: setContext, | ||
}); | ||
} | ||
else { | ||
return new ApolloLink(function (operation, forward) { | ||
return (firstLink.request(operation, function (op) { | ||
return nextLink.request(op, forward) || Observable.of(); | ||
}) || Observable.of()); | ||
Object.defineProperty(operation, 'getContext', { | ||
enumerable: false, | ||
value: getContext, | ||
}); | ||
Object.defineProperty(operation, 'toKey', { | ||
enumerable: false, | ||
value: function () { return getKey(operation); }, | ||
}); | ||
return operation; | ||
} | ||
}; | ||
var ApolloLink = (function () { | ||
function ApolloLink(request) { | ||
if (request) | ||
this.request = request; | ||
function getKey(operation) { | ||
// XXX we're assuming here that variables will be serialized in the same order. | ||
// that might not always be true | ||
return printer.print(operation.query) + "|" + JSON.stringify(operation.variables) + "|" + operation.operationName; | ||
} | ||
ApolloLink.prototype.split = function (test, left, right) { | ||
var passthrough = function (op, forward) { return (forward ? forward(op) : Observable.of()); }; | ||
var toLink = function (handler) { | ||
return typeof handler === 'function' ? new ApolloLink(handler) : handler; | ||
}; | ||
var empty = function () { | ||
return new ApolloLink(function (op, forward) { return Observable.of(); }); | ||
}; | ||
var from = function (links) { | ||
if (links.length === 0) | ||
return empty(); | ||
return links.map(toLink).reduce(function (x, y) { return x.concat(y); }); | ||
}; | ||
var split = function (test, left, right) { | ||
if (right === void 0) { right = new ApolloLink(passthrough); } | ||
return this.concat(split(test, left, right)); | ||
var leftLink = toLink(left); | ||
var rightLink = toLink(right); | ||
if (isTerminating(leftLink) && isTerminating(rightLink)) { | ||
return new ApolloLink(function (operation) { | ||
return test(operation) | ||
? leftLink.request(operation) || Observable.of() | ||
: rightLink.request(operation) || Observable.of(); | ||
}); | ||
} | ||
else { | ||
return new ApolloLink(function (operation, forward) { | ||
return test(operation) | ||
? leftLink.request(operation, forward) || Observable.of() | ||
: rightLink.request(operation, forward) || Observable.of(); | ||
}); | ||
} | ||
}; | ||
ApolloLink.prototype.concat = function (next) { | ||
return concat(this, next); | ||
// join two Links together | ||
var concat = function (first, second) { | ||
var firstLink = toLink(first); | ||
if (isTerminating(firstLink)) { | ||
console.warn(new LinkError("You are calling concat on a terminating link, which will have no effect", firstLink)); | ||
return firstLink; | ||
} | ||
var nextLink = toLink(second); | ||
if (isTerminating(nextLink)) { | ||
return new ApolloLink(function (operation) { | ||
return firstLink.request(operation, function (op) { return nextLink.request(op) || Observable.of(); }) || Observable.of(); | ||
}); | ||
} | ||
else { | ||
return new ApolloLink(function (operation, forward) { | ||
return (firstLink.request(operation, function (op) { | ||
return nextLink.request(op, forward) || Observable.of(); | ||
}) || Observable.of()); | ||
}); | ||
} | ||
}; | ||
ApolloLink.prototype.request = function (operation, forward) { | ||
throw new Error('request is not implemented'); | ||
}; | ||
ApolloLink.empty = empty; | ||
ApolloLink.from = from; | ||
ApolloLink.split = split; | ||
ApolloLink.execute = execute; | ||
return ApolloLink; | ||
}()); | ||
function execute(link, operation) { | ||
return (link.request(createOperation(operation.context, transformOperation(validateOperation(operation)))) || Observable.of()); | ||
} | ||
var ApolloLink = /** @class */ (function () { | ||
function ApolloLink(request) { | ||
if (request) | ||
this.request = request; | ||
} | ||
ApolloLink.prototype.split = function (test, left, right) { | ||
if (right === void 0) { right = new ApolloLink(passthrough); } | ||
return this.concat(split(test, left, right)); | ||
}; | ||
ApolloLink.prototype.concat = function (next) { | ||
return concat(this, next); | ||
}; | ||
ApolloLink.prototype.request = function (operation, forward) { | ||
throw new Error('request is not implemented'); | ||
}; | ||
ApolloLink.empty = empty; | ||
ApolloLink.from = from; | ||
ApolloLink.split = split; | ||
ApolloLink.execute = execute; | ||
return ApolloLink; | ||
}()); | ||
function execute(link, operation) { | ||
return (link.request(createOperation(operation.context, transformOperation(validateOperation(operation)))) || Observable.of()); | ||
} | ||
exports.Observable = Observable; | ||
exports.createOperation = createOperation; | ||
exports.makePromise = makePromise; | ||
exports.toPromise = toPromise; | ||
exports.fromPromise = fromPromise; | ||
exports.fromError = fromError; | ||
exports.empty = empty; | ||
exports.from = from; | ||
exports.split = split; | ||
exports.concat = concat; | ||
exports.ApolloLink = ApolloLink; | ||
exports.execute = execute; | ||
exports.Observable = Observable; | ||
exports.createOperation = createOperation; | ||
exports.makePromise = makePromise; | ||
exports.toPromise = toPromise; | ||
exports.fromPromise = fromPromise; | ||
exports.fromError = fromError; | ||
exports.empty = empty; | ||
exports.from = from; | ||
exports.split = split; | ||
exports.concat = concat; | ||
exports.ApolloLink = ApolloLink; | ||
exports.execute = execute; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
//# sourceMappingURL=bundle.umd.js.map |
@@ -34,2 +34,3 @@ import Observable from 'zen-observable-ts'; | ||
}; | ||
// join two Links together | ||
export var concat = function (first, second) { | ||
@@ -55,3 +56,3 @@ var firstLink = toLink(first); | ||
}; | ||
var ApolloLink = (function () { | ||
var ApolloLink = /** @class */ (function () { | ||
function ApolloLink(request) { | ||
@@ -58,0 +59,0 @@ if (request) |
@@ -38,3 +38,3 @@ var __extends = (this && this.__extends) || (function () { | ||
} | ||
var LinkError = (function (_super) { | ||
var LinkError = /** @class */ (function (_super) { | ||
__extends(LinkError, _super); | ||
@@ -69,2 +69,3 @@ function LinkError(message, link) { | ||
} | ||
// backwards compat | ||
export var makePromise = toPromise; | ||
@@ -93,2 +94,3 @@ export function fromPromise(promise) { | ||
}; | ||
// best guess at an operation name | ||
if (!transformedOperation.operationName) { | ||
@@ -128,4 +130,6 @@ transformedOperation.operationName = | ||
export function getKey(operation) { | ||
// XXX we're assuming here that variables will be serialized in the same order. | ||
// that might not always be true | ||
return print(operation.query) + "|" + JSON.stringify(operation.variables) + "|" + operation.operationName; | ||
} | ||
//# sourceMappingURL=linkUtils.js.map |
@@ -12,3 +12,3 @@ var __extends = (this && this.__extends) || (function () { | ||
import { ApolloLink } from '../link'; | ||
var MockLink = (function (_super) { | ||
var MockLink = /** @class */ (function (_super) { | ||
__extends(MockLink, _super); | ||
@@ -15,0 +15,0 @@ function MockLink(handleRequest) { |
@@ -12,3 +12,3 @@ var __extends = (this && this.__extends) || (function () { | ||
import { ApolloLink } from '../link'; | ||
var SetContextLink = (function (_super) { | ||
var SetContextLink = /** @class */ (function (_super) { | ||
__extends(SetContextLink, _super); | ||
@@ -15,0 +15,0 @@ function SetContextLink(setContext) { |
import Observable from 'zen-observable-ts'; | ||
import { ExecutionResult, DocumentNode } from 'graphql'; | ||
export { ExecutionResult, DocumentNode }; | ||
export interface GraphQLRequest { | ||
@@ -4,0 +5,0 @@ query: DocumentNode; |
{ | ||
"name": "apollo-link", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Flexible, lightweight transport layer for GraphQL", | ||
@@ -41,5 +41,5 @@ "author": "Evans Hauser <evanshauser@gmail.com>", | ||
"dependencies": { | ||
"@types/node": "^9.4.6", | ||
"@types/graphql": "0.12.6", | ||
"apollo-utilities": "^1.0.0", | ||
"zen-observable-ts": "^0.8.6" | ||
"zen-observable-ts": "^0.8.9" | ||
}, | ||
@@ -50,18 +50,18 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@types/graphql": "0.12.4", | ||
"@types/jest": "21.1.10", | ||
"browserify": "16.1.0", | ||
"graphql": "0.13.1", | ||
"graphql-tag": "2.7.3", | ||
"jest": "21.2.1", | ||
"@types/jest": "22.2.2", | ||
"@types/node": "^9.4.6", | ||
"browserify": "16.1.1", | ||
"graphql": "0.13.2", | ||
"graphql-tag": "2.8.0", | ||
"jest": "22.4.3", | ||
"rimraf": "2.6.1", | ||
"rollup": "0.56.2", | ||
"rollup": "0.57.1", | ||
"ts-jest": "21.2.4", | ||
"tslint": "5.9.1", | ||
"typescript": "2.7.2", | ||
"uglify-js": "3.3.11" | ||
"uglify-js": "3.3.16" | ||
}, | ||
"jest": { | ||
"transform": { | ||
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
".(ts|tsx)": "ts-jest" | ||
}, | ||
@@ -68,0 +68,0 @@ "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", |
import Observable from 'zen-observable-ts'; | ||
import { ExecutionResult, DocumentNode } from 'graphql'; | ||
export { ExecutionResult, DocumentNode }; | ||
@@ -4,0 +5,0 @@ export interface GraphQLRequest { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105377
2142
+ Added@types/graphql@0.12.6
+ Added@types/graphql@0.12.6(transitive)
- Removed@types/node@^9.4.6
- Removed@types/node@9.6.61(transitive)
Updatedzen-observable-ts@^0.8.9