apollo-link-dedup
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -0,32 +1,4 @@ | ||
import { __extends } from 'tslib'; | ||
import { Observable, ApolloLink } from 'apollo-link'; | ||
/*! ***************************************************************************** | ||
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 __()); | ||
} | ||
var DedupLink = (function (_super) { | ||
@@ -33,0 +5,0 @@ __extends(DedupLink, _super); |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-link')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'apollo-link'], factory) : | ||
(global = global || self, factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.dedup = {}), global.apolloLink.core)); | ||
}(this, function (exports, apolloLink) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tslib'), require('apollo-link')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'tslib', 'apollo-link'], factory) : | ||
(global = global || self, factory((global.apolloLink = global.apolloLink || {}, global.apolloLink.dedup = {}), global.tslib, global.apolloLink.core)); | ||
}(this, function (exports, tslib_1, apolloLink) { '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 DedupLink = (function (_super) { | ||
tslib_1.__extends(DedupLink, _super); | ||
function DedupLink() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.inFlightRequestObservables = new Map(); | ||
_this.subscribers = new Map(); | ||
return _this; | ||
} | ||
DedupLink.prototype.request = function (operation, forward) { | ||
var _this = this; | ||
if (operation.getContext().forceFetch) { | ||
return forward(operation); | ||
} | ||
var key = operation.toKey(); | ||
var cleanup = function (operationKey) { | ||
_this.inFlightRequestObservables.delete(operationKey); | ||
var prev = _this.subscribers.get(operationKey); | ||
return prev; | ||
}; | ||
if (!this.inFlightRequestObservables.get(key)) { | ||
var singleObserver_1 = forward(operation); | ||
var subscription_1; | ||
var sharedObserver = new apolloLink.Observable(function (observer) { | ||
var prev = _this.subscribers.get(key); | ||
if (!prev) | ||
prev = { next: [], error: [], complete: [] }; | ||
_this.subscribers.set(key, { | ||
next: prev.next.concat([observer.next.bind(observer)]), | ||
error: prev.error.concat([observer.error.bind(observer)]), | ||
complete: prev.complete.concat([observer.complete.bind(observer)]), | ||
}); | ||
if (!subscription_1) { | ||
subscription_1 = singleObserver_1.subscribe({ | ||
next: function (result) { | ||
var previous = cleanup(key); | ||
_this.subscribers.delete(key); | ||
if (previous) { | ||
previous.next.forEach(function (next) { return next(result); }); | ||
previous.complete.forEach(function (complete) { return complete(); }); | ||
} | ||
}, | ||
error: function (error) { | ||
var previous = cleanup(key); | ||
_this.subscribers.delete(key); | ||
if (previous) | ||
previous.error.forEach(function (err) { return err(error); }); | ||
}, | ||
}); | ||
} | ||
return function () { | ||
if (subscription_1) | ||
subscription_1.unsubscribe(); | ||
_this.inFlightRequestObservables.delete(key); | ||
}; | ||
}); | ||
this.inFlightRequestObservables.set(key, sharedObserver); | ||
} | ||
return this.inFlightRequestObservables.get(key); | ||
}; | ||
return DedupLink; | ||
}(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.DedupLink = DedupLink; | ||
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 __()); | ||
} | ||
var DedupLink = (function (_super) { | ||
__extends(DedupLink, _super); | ||
function DedupLink() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.inFlightRequestObservables = new Map(); | ||
_this.subscribers = new Map(); | ||
return _this; | ||
} | ||
DedupLink.prototype.request = function (operation, forward) { | ||
var _this = this; | ||
if (operation.getContext().forceFetch) { | ||
return forward(operation); | ||
} | ||
var key = operation.toKey(); | ||
var cleanup = function (operationKey) { | ||
_this.inFlightRequestObservables.delete(operationKey); | ||
var prev = _this.subscribers.get(operationKey); | ||
return prev; | ||
}; | ||
if (!this.inFlightRequestObservables.get(key)) { | ||
var singleObserver_1 = forward(operation); | ||
var subscription_1; | ||
var sharedObserver = new apolloLink.Observable(function (observer) { | ||
var prev = _this.subscribers.get(key); | ||
if (!prev) | ||
prev = { next: [], error: [], complete: [] }; | ||
_this.subscribers.set(key, { | ||
next: prev.next.concat([observer.next.bind(observer)]), | ||
error: prev.error.concat([observer.error.bind(observer)]), | ||
complete: prev.complete.concat([observer.complete.bind(observer)]), | ||
}); | ||
if (!subscription_1) { | ||
subscription_1 = singleObserver_1.subscribe({ | ||
next: function (result) { | ||
var previous = cleanup(key); | ||
_this.subscribers.delete(key); | ||
if (previous) { | ||
previous.next.forEach(function (next) { return next(result); }); | ||
previous.complete.forEach(function (complete) { return complete(); }); | ||
} | ||
}, | ||
error: function (error) { | ||
var previous = cleanup(key); | ||
_this.subscribers.delete(key); | ||
if (previous) | ||
previous.error.forEach(function (err) { return err(error); }); | ||
}, | ||
}); | ||
} | ||
return function () { | ||
if (subscription_1) | ||
subscription_1.unsubscribe(); | ||
_this.inFlightRequestObservables.delete(key); | ||
}; | ||
}); | ||
this.inFlightRequestObservables.set(key, sharedObserver); | ||
} | ||
return this.inFlightRequestObservables.get(key); | ||
}; | ||
return DedupLink; | ||
}(apolloLink.ApolloLink)); | ||
exports.DedupLink = DedupLink; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
//# sourceMappingURL=bundle.umd.js.map |
"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 __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var apollo_link_1 = require("apollo-link"); | ||
var DedupLink = (function (_super) { | ||
__extends(DedupLink, _super); | ||
tslib_1.__extends(DedupLink, _super); | ||
function DedupLink() { | ||
@@ -20,0 +8,0 @@ var _this = _super !== null && _super.apply(this, arguments) || this; |
"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("./dedupLink")); | ||
var tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./dedupLink"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "apollo-link-dedup", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"description": "Deduplicates queries that are currently on the wire", | ||
@@ -16,2 +16,3 @@ "author": "Evans Hauser <evanshauser@gmail.com>", | ||
"typings": "./lib/index.d.ts", | ||
"sideEffects": false, | ||
"repository": { | ||
@@ -26,24 +27,19 @@ "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", | ||
"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" | ||
}, | ||
"dependencies": { | ||
"apollo-link": "^1.2.8" | ||
"apollo-link": "^1.2.9", | ||
"tslib": "^1.9.3" | ||
}, | ||
"devDependencies": { | ||
"@types/graphql": "14.0.5", | ||
"@types/graphql": "14.0.7", | ||
"@types/jest": "22.2.3", | ||
"browserify": "16.2.3", | ||
"graphql": "14.1.1", | ||
@@ -53,7 +49,6 @@ "graphql-tag": "2.10.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" | ||
}, | ||
@@ -73,3 +68,3 @@ "jest": { | ||
}, | ||
"gitHead": "6f5d0cfb73e61c6f83caed9e37d37c4451a64c7b" | ||
"gitHead": "2c960e057de9d664855bb18df4a4bd25c88bb6ef" | ||
} |
@@ -27,3 +27,3 @@ --- | ||
```js | ||
import Link from "apollo-link-http"; | ||
import { createHttpLink } from "apollo-link-http"; | ||
import ApolloClient from "apollo-client"; | ||
@@ -33,3 +33,3 @@ import InMemoryCache from "apollo-cache-inmemory"; | ||
const client = new ApolloClient({ | ||
link: new Link({ uri: "/graphql" }), | ||
link: createHttpLink({ uri: "/graphql" }), | ||
cache: new InMemoryCache() | ||
@@ -36,0 +36,0 @@ }); |
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
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
87423
10
114
0
2
+ Addedtslib@^1.9.3
Updatedapollo-link@^1.2.9