@urql/exchange-request-policy
Advanced tools
Comparing version 0.1.0 to 0.1.1
# Changelog | ||
## 0.1.1 | ||
### Patch Changes | ||
- ⚠️ Fix non-query operations being upgraded by `requestPolicyExchange` and time being stored by last issuance rather than last result, by [@kitten](https://github.com/kitten) (See [#1377](https://github.com/FormidableLabs/urql/pull/1377)) | ||
- Updated dependencies (See [#1374](https://github.com/FormidableLabs/urql/pull/1374), [#1357](https://github.com/FormidableLabs/urql/pull/1357), and [#1375](https://github.com/FormidableLabs/urql/pull/1375)) | ||
- @urql/core@2.0.0 | ||
## v0.1.0 | ||
**Initial Release** |
@@ -16,21 +16,18 @@ "use strict"; | ||
var wonka = require("wonka"), defaultTTL = 3e5, requestPolicyExchange = function(d) { | ||
var core = require("@urql/core"), wonka = require("wonka"), defaultTTL = 3e5, requestPolicyExchange = function(d) { | ||
return function(c) { | ||
var e = c.forward, b = new Map, f = (d || {}).ttl || defaultTTL, g = function(a) { | ||
if ("cache-first" !== a.context.requestPolicy && "cache-only" !== a.context.requestPolicy) { | ||
if ("query" !== a.kind || "cache-first" !== a.context.requestPolicy && "cache-only" !== a.context.requestPolicy || !b.has(a.key)) { | ||
return a; | ||
} | ||
if (!b.has(a.key)) { | ||
return b.set(a.key, new Date), a; | ||
} | ||
var c = b.get(a.key); | ||
return (new Date).getTime() - c.getTime() > f && (d.shouldUpgrade ? d.shouldUpgrade(a) : 1) ? (b.set(a.key, new Date), | ||
_extends({}, a, { | ||
context: _extends({}, a.context, { | ||
requestPolicy: "cache-and-network" | ||
}) | ||
})) : a; | ||
return (new Date).getTime() - c > f && (d.shouldUpgrade ? d.shouldUpgrade(a) : 1) ? (b.delete(a.key), | ||
core.makeOperation(a.kind, a, _extends({}, a.context, { | ||
requestPolicy: "cache-and-network" | ||
}))) : a; | ||
}, h = function(a) { | ||
b.set(a.operation.key, (new Date).getTime()); | ||
}; | ||
return function(a) { | ||
return e(wonka.map(g)(a)); | ||
return wonka.tap(h)(e(wonka.map(g)(a))); | ||
}; | ||
@@ -37,0 +34,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("wonka");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}exports.requestPolicyExchange=function(r){return function(n){var o=n.forward,c=new Map,a=(r||{}).ttl||3e5,u=function(e){if("cache-first"!==e.context.requestPolicy&&"cache-only"!==e.context.requestPolicy)return e;if(!c.has(e.key))return c.set(e.key,new Date),e;var n=c.get(e.key);return(new Date).getTime()-n.getTime()>a&&(!r.shouldUpgrade||r.shouldUpgrade(e))?(c.set(e.key,new Date),t({},e,{context:t({},e.context,{requestPolicy:"cache-and-network"})})):e};return function(t){return o(e.map(u)(t))}}}; | ||
"use strict";var e=require("@urql/core"),t=require("wonka");function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}exports.requestPolicyExchange=function(n){return function(o){var a=o.forward,c=new Map,i=(n||{}).ttl||3e5,u=function(t){if("query"!==t.kind||"cache-first"!==t.context.requestPolicy&&"cache-only"!==t.context.requestPolicy||!c.has(t.key))return t;var o=c.get(t.key);return(new Date).getTime()-o>i&&(!n.shouldUpgrade||n.shouldUpgrade(t))?(c.delete(t.key),e.makeOperation(t.kind,t,r({},t.context,{requestPolicy:"cache-and-network"}))):t},s=function(e){c.set(e.operation.key,(new Date).getTime())};return function(e){return t.tap(s)(a(t.map(u)(e)))}}}; | ||
//# sourceMappingURL=urql-exchange-request-policy.min.js.map |
{ | ||
"name": "@urql/exchange-request-policy", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "An exchange for operation request-policy upgrading in urql", | ||
@@ -19,3 +19,2 @@ "sideEffects": false, | ||
"exchanges", | ||
"react", | ||
"request-policy" | ||
@@ -55,3 +54,3 @@ ], | ||
"devDependencies": { | ||
"graphql": "^15.1.0" | ||
"graphql": "^15.4.0" | ||
}, | ||
@@ -62,3 +61,3 @@ "peerDependencies": { | ||
"dependencies": { | ||
"@urql/core": ">=1.12.0", | ||
"@urql/core": ">=2.0.0", | ||
"wonka": "^4.0.14" | ||
@@ -65,0 +64,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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
16071
87
Updated@urql/core@>=2.0.0