@urql/exchange-graphcache
Advanced tools
Comparing version 3.1.8 to 3.1.9
# @urql/exchange-graphcache | ||
## 3.1.9 | ||
### Patch Changes | ||
- ⚠️ Fix the production build overwriting the development build. Specifically in the previous release we mistakenly replaced all development bundles with production bundles. This doesn't have any direct influence on how these packages work, but prevented development warnings from being logged or full errors from being thrown, by [@kitten](https://github.com/kitten) (See [#1097](https://github.com/FormidableLabs/urql/pull/1097)) | ||
- Updated dependencies (See [#1097](https://github.com/FormidableLabs/urql/pull/1097)) | ||
- @urql/core@1.14.1 | ||
## 3.1.8 | ||
@@ -4,0 +12,0 @@ |
@@ -18,5 +18,5 @@ { | ||
"dependencies": { | ||
"@urql/core": ">=1.14.0", | ||
"@urql/core": ">=1.14.1", | ||
"wonka": "^4.0.14" | ||
} | ||
} |
@@ -1,2 +0,17 @@ | ||
"use strict";function t(){return(t=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var e,n=arguments[r];for(e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t}).apply(this,arguments)}exports._extends=t; | ||
"use strict"; | ||
function _extends() { | ||
return (_extends = Object.assign || function(d) { | ||
var b, c, a; | ||
for (b = 1; b < arguments.length; b++) { | ||
c = arguments[b]; | ||
for (a in c) { | ||
Object.prototype.hasOwnProperty.call(c, a) && (d[a] = c[a]); | ||
} | ||
} | ||
return d; | ||
}).apply(this, arguments); | ||
} | ||
exports._extends = _extends; | ||
//# sourceMappingURL=7832a774.js.map |
@@ -1,2 +0,131 @@ | ||
"use strict";var e=require("./7832a774.js"),t=function(e){return new Promise((function(t,n){e.onerror=function(){n(e.error)},e.onsuccess=function(){t(e.result)}}))},n=function(e){return new Promise((function(t,n){e.onerror=function(){n(e.error)},e.oncomplete=t}))};function r(e){return e.replace(/:/g,"%3a")}function a(e){return e.replace(/%3a/g,":")}function o(){return null}function u(){}function i(){}function c(e){window.addEventListener("online",(function(){e()}))}exports.makeDefaultStorage=function(s){function f(e){return(e=e.transaction("metadata","readwrite")).objectStore("metadata").clear(),e.objectStore("entries").clear(),n(e)}function d(e){return t(e.transaction("metadata","readonly").objectStore("metadata").get("metadata"))}function l(e){return t(e.transaction("entries","readwrite").objectStore("entries").put(x(),p))}function h(){return v}s||(s={});var m=s.idbName||"graphcache-v4",v=Object.create(null),p=Math.floor((new Date).valueOf()/864e5),b=p-(s.maxAge||7),j=indexedDB.open(m,1),w=t(j);j.onupgradeneeded=function(){j.result.createObjectStore("entries"),j.result.createObjectStore("metadata")};var g=r,S=a,x=function(){var e,t="";for(e in v){var n=v[e];t+=g(e),t+=":",n&&(t+=g(n)),t+=":"}return t},D=function(e){for(var t,n={},r="",a="",o=0,u=0;u<e.length;){for(t="";":"!==(r=e[u++])&&r;)t+=r;o?(n[a]=S(t)||void 0,o=0):(a=S(t),o=1)}return n};return{clear:function(){return w.then(f)},readMetadata:function(){return w.then(d,o)},writeMetadata:function(e){w.then((function(n){return t(n.transaction("metadata","readwrite").objectStore("metadata").put(e,"metadata"))}),u)},writeData:function(t){return e._extends(v,t),t=i,w.then(l).then(t,t)},readData:function(){var t=[];return w.then((function(r){var a=(r=r.transaction("entries","readwrite")).objectStore("entries");return(a.openKeyCursor||a.openCursor).call(a).onsuccess=function(){if(this.result){var n=this.result.key;if("number"!=typeof n||n<b)a.delete(n);else{var r=a.get(n),o=t.length;t.push(""),r.onsuccess=function(){var a=""+r.result;n===p&&e._extends(v,D(a)),t[o]=a}}this.result.continue()}},n(r)})).then((function(){return D(t.join(""))}),h)},onOnline:c}}; | ||
"use strict"; | ||
function _ref(a) { | ||
return a.replace(/:/g, "%3a"); | ||
} | ||
function _ref2(a) { | ||
return a.replace(/%3a/g, ":"); | ||
} | ||
function _ref5() { | ||
return null; | ||
} | ||
function _ref6() {} | ||
function _ref7() {} | ||
function _onOnline(a) { | ||
window.addEventListener("online", (function() { | ||
a(); | ||
})); | ||
} | ||
var _rollupPluginBabelHelpers = require("./7832a774.js"), getRequestPromise = function(a) { | ||
return new Promise((function(d, e) { | ||
a.onerror = function() { | ||
e(a.error); | ||
}; | ||
a.onsuccess = function() { | ||
d(a.result); | ||
}; | ||
})); | ||
}, getTransactionPromise = function(a) { | ||
return new Promise((function(d, e) { | ||
a.onerror = function() { | ||
e(a.error); | ||
}; | ||
a.oncomplete = d; | ||
})); | ||
}, makeDefaultStorage = function(a) { | ||
function d(b) { | ||
(b = b.transaction("metadata", "readwrite")).objectStore("metadata").clear(); | ||
b.objectStore("entries").clear(); | ||
return getTransactionPromise(b); | ||
} | ||
function e(b) { | ||
return getRequestPromise(b.transaction("metadata", "readonly").objectStore("metadata").get("metadata")); | ||
} | ||
function r(b) { | ||
return getRequestPromise(b.transaction("entries", "readwrite").objectStore("entries").put(t(), l)); | ||
} | ||
function u() { | ||
return g; | ||
} | ||
var v, g, l, w, k, h, n, p, t, q; | ||
a || (a = {}); | ||
v = a.idbName || "graphcache-v4", g = Object.create(null), l = Math.floor((new Date).valueOf() / 864e5), | ||
w = l - (a.maxAge || 7), k = indexedDB.open(v, 1), h = getRequestPromise(k); | ||
k.onupgradeneeded = function() { | ||
k.result.createObjectStore("entries"); | ||
k.result.createObjectStore("metadata"); | ||
}; | ||
n = _ref, p = _ref2, t = function() { | ||
var a, c, b = ""; | ||
for (a in g) { | ||
c = g[a]; | ||
b += n(a); | ||
b += ":"; | ||
c && (b += n(c)); | ||
b += ":"; | ||
} | ||
return b; | ||
}, q = function(b) { | ||
for (var f, a = {}, c = "", d = "", m = 0, e = 0; e < b.length; ) { | ||
for (f = ""; ":" !== (c = b[e++]) && c; ) { | ||
f += c; | ||
} | ||
m ? (a[d] = p(f) || void 0, m = 0) : (d = p(f), m = 1); | ||
} | ||
return a; | ||
}; | ||
return { | ||
clear: function() { | ||
return h.then(d); | ||
}, | ||
readMetadata: function() { | ||
return h.then(e, _ref5); | ||
}, | ||
writeMetadata: function(b) { | ||
h.then((function(a) { | ||
return getRequestPromise(a.transaction("metadata", "readwrite").objectStore("metadata").put(b, "metadata")); | ||
}), _ref6); | ||
}, | ||
writeData: function(b) { | ||
_rollupPluginBabelHelpers._extends(g, b); | ||
b = _ref7; | ||
return h.then(r).then(b, b); | ||
}, | ||
readData: function() { | ||
var b = []; | ||
return h.then((function(a) { | ||
var c = (a = a.transaction("entries", "readwrite")).objectStore("entries"); | ||
(c.openKeyCursor || c.openCursor).call(c).onsuccess = function() { | ||
var f, d, e; | ||
if (this.result) { | ||
if ("number" != typeof (f = this.result.key) || f < w) { | ||
c.delete(f); | ||
} else { | ||
d = c.get(f), e = b.length; | ||
b.push(""); | ||
d.onsuccess = function a() { | ||
var a = "" + d.result; | ||
f === l && _rollupPluginBabelHelpers._extends(g, q(a)); | ||
b[e] = a; | ||
}; | ||
} | ||
this.result.continue(); | ||
} | ||
}; | ||
return getTransactionPromise(a); | ||
})).then((function() { | ||
return q(b.join("")); | ||
}), u); | ||
}, | ||
onOnline: _onOnline | ||
}; | ||
}; | ||
exports.makeDefaultStorage = makeDefaultStorage; | ||
//# sourceMappingURL=urql-exchange-graphcache-default-storage.js.map |
@@ -1,2 +0,200 @@ | ||
"use strict";var e=require("./7832a774.js"),r=require("@urql/core"),n={__typename:"PageInfo",endCursor:null,startCursor:null,hasNextPage:!1,hasPreviousPage:!1},t=function(e){return"string"==typeof e?e:null},s=function(e,r,n){for(var t=new Set,s=0,a=r.length;s<a;s++){var o=e.resolve(r[s],"node");"string"==typeof o&&t.add(o)}for(r=r.slice(),s=0,a=n.length;s<a;s++){var i=e.resolve(o=n[s],"node");"string"!=typeof i||t.has(i)||(t.add(i),r.push(o))}return r},a=function(e,r){for(var n=new Set,t=0,s=e.length;t<s;t++){var a=e[t];"string"==typeof a&&n.add(a)}for(e=e.slice(),t=0,s=r.length;t<s;t++)"string"!=typeof(a=r[t])||n.has(a)||(n.add(a),e.push(a));return e},o=function(e,n){for(var t in n)if("first"!==t&&"last"!==t&&"after"!==t&&"before"!==t){if(!(t in e))return!1;var s=e[t],a=n[t];if(typeof s!=typeof a||"object"!=typeof s?s!==a:r.stringifyVariables(s)!==r.stringifyVariables(a))return!1}for(var o in e)if("first"!==o&&"last"!==o&&"after"!==o&&"before"!==o&&!(o in n))return!1;return!0},i=function(e,r,s){var a=t(e.resolveFieldByKey(r,s));if(!a)return null;s=e.resolve(a,"__typename"),r=e.resolve(a,"edges")||[];var o=e.resolve(a,"nodes")||[];if("string"!=typeof s)return null;s={__typename:s,edges:r,nodes:o,pageInfo:n};var i=e.resolve(a,"pageInfo");if("string"==typeof i){a=t(e.resolve(i,"__typename")),o=t(e.resolve(i,"endCursor"));var f=t(e.resolve(i,"startCursor")),l=e.resolve(i,"hasNextPage");i=e.resolve(i,"hasPreviousPage"),null===(a=s.pageInfo={__typename:"string"==typeof a?a:"PageInfo",hasNextPage:"boolean"==typeof l?l:!!o,hasPreviousPage:"boolean"==typeof i?i:!!f,endCursor:o,startCursor:f}).endCursor&&(o=r[r.length-1])&&(o=e.resolve(o,"cursor"),a.endCursor=t(o)),null===a.startCursor&&(r=r[0])&&(e=e.resolve(r,"cursor"),a.startCursor=t(e))}return s};exports.relayPagination=function(r){void 0===r&&(r={});var f=r.mergeMode||"inwards";return function(r,l,u,g){var d=g.fieldName,p=u.inspectFields(r=g.parentKey).filter((function(e){return e.fieldName===d})),v=p.length;if(0!==v){for(var y=null,h=[],m=[],c=[],_=[],P=e._extends({},n),C=0;C<v;C++){var b=p[C],I=b.fieldKey;if(null!==(b=b.arguments)&&o(l,b)&&null!==(I=i(u,r,I))){if("inwards"===f&&"number"==typeof b.last&&"number"==typeof b.first){P=I.edges.slice(0,b.first+1);var N=I.edges.slice(-b.last),x=I.nodes.slice(0,b.first+1);b=I.nodes.slice(-b.last),h=s(u,h,P),m=s(u,N,m),c=a(c,x),_=a(b,_),P=I.pageInfo}else b.after?(h=s(u,h,I.edges),c=a(c,I.nodes),P.endCursor=I.pageInfo.endCursor,P.hasNextPage=I.pageInfo.hasNextPage):b.before?(m=s(u,I.edges,m),_=a(I.nodes,_),P.startCursor=I.pageInfo.startCursor,P.hasPreviousPage=I.pageInfo.hasPreviousPage):("number"==typeof b.last?(m=s(u,m,I.edges),_=a(_,I.nodes)):(h=s(u,h,I.edges),c=a(c,I.nodes)),P=I.pageInfo);I.pageInfo.__typename!==P.__typename&&(P.__typename=I.pageInfo.__typename),y!==I.__typename&&(y=I.__typename)}}if("string"==typeof y){if(!t(u.resolve(r,d,l))){if(!g.store.schema)return;g.partial=!0}return{__typename:y,edges:"inwards"===f?s(u,h,m):s(u,m,h),nodes:"inwards"===f?a(c,_):a(_,c),pageInfo:{__typename:P.__typename,endCursor:P.endCursor,startCursor:P.startCursor,hasNextPage:P.hasNextPage,hasPreviousPage:P.hasPreviousPage}}}}}},exports.simplePagination=function(e){void 0===e&&(e={});var n=e.offsetArgument;void 0===n&&(n="skip");var t=e.limitArgument;void 0===t&&(t="limit");var s=function(e,s){for(var a in s)if(a!==n&&a!==t){if(!(a in e))return!1;var o=e[a],i=s[a];if(typeof o!=typeof i||"object"!=typeof o?o!==i:r.stringifyVariables(o)!==r.stringifyVariables(i))return!1}for(var f in e)if(f!==n&&f!==t&&!(f in s))return!1;return!0};return function(e,r,t,a){var o=a.fieldName,i=t.inspectFields(e=a.parentKey).filter((function(e){return e.fieldName===o})),f=i.length;if(0!==f){for(var l=new Set,u=[],g=null,d=0;d<f;d++){var p=i[d],v=p.fieldKey;if(null!==(p=p.arguments)&&s(r,p)&&(v=t.resolveFieldByKey(e,v),p=p[n],null!==v&&0!==v.length&&"number"==typeof p)){if(!g||p>g)for(g=0;g<v.length;g++){var y=v[g];l.has(y)||(u.push(y),l.add(y))}else{for(g=[],y=0;y<v.length;y++){var h=v[y];l.has(h)||(g.push(h),l.add(h))}u=g.concat(u)}g=p}}if(t.resolve(e,o,r))return u;if(a.store.schema)return a.partial=!0,u}}}; | ||
"use strict"; | ||
var _rollupPluginBabelHelpers = require("./7832a774.js"), core = require("@urql/core"), defaultPageInfo = { | ||
__typename: "PageInfo", | ||
endCursor: null, | ||
startCursor: null, | ||
hasNextPage: !1, | ||
hasPreviousPage: !1 | ||
}, ensureKey = function(a) { | ||
return "string" == typeof a ? a : null; | ||
}, concatEdges = function(a, g, e) { | ||
var c, b, d, r, m; | ||
for (c = new Set, b = 0, d = g.length; b < d; b++) { | ||
"string" == typeof (r = a.resolve(g[b], "node")) && c.add(r); | ||
} | ||
g = g.slice(); | ||
b = 0; | ||
for (d = e.length; b < d; b++) { | ||
"string" != typeof (m = a.resolve(r = e[b], "node")) || c.has(m) || (c.add(m), g.push(r)); | ||
} | ||
return g; | ||
}, concatNodes = function(a, g) { | ||
var e, c, b, d; | ||
for (e = new Set, c = 0, b = a.length; c < b; c++) { | ||
"string" == typeof (d = a[c]) && e.add(d); | ||
} | ||
a = a.slice(); | ||
c = 0; | ||
for (b = g.length; c < b; c++) { | ||
"string" != typeof (d = g[c]) || e.has(d) || (e.add(d), a.push(d)); | ||
} | ||
return a; | ||
}, compareArgs = function(a, g) { | ||
var e, c, b, d; | ||
for (e in g) { | ||
if ("first" !== e && "last" !== e && "after" !== e && "before" !== e) { | ||
if (!(e in a)) { | ||
return !1; | ||
} | ||
if (typeof (c = a[e]) != typeof (b = g[e]) || "object" != typeof c ? c !== b : core.stringifyVariables(c) !== core.stringifyVariables(b)) { | ||
return !1; | ||
} | ||
} | ||
} | ||
for (d in a) { | ||
if ("first" !== d && "last" !== d && "after" !== d && "before" !== d && !(d in g)) { | ||
return !1; | ||
} | ||
} | ||
return !0; | ||
}, getPage = function(a, g, e) { | ||
var b, d, r, m, c = ensureKey(a.resolveFieldByKey(g, e)); | ||
if (!c) { | ||
return null; | ||
} | ||
e = a.resolve(c, "__typename"); | ||
g = a.resolve(c, "edges") || []; | ||
b = a.resolve(c, "nodes") || []; | ||
if ("string" != typeof e) { | ||
return null; | ||
} | ||
e = { | ||
__typename: e, | ||
edges: g, | ||
nodes: b, | ||
pageInfo: defaultPageInfo | ||
}; | ||
if ("string" == typeof (d = a.resolve(c, "pageInfo"))) { | ||
c = ensureKey(a.resolve(d, "__typename")); | ||
b = ensureKey(a.resolve(d, "endCursor")); | ||
r = ensureKey(a.resolve(d, "startCursor")), m = a.resolve(d, "hasNextPage"); | ||
d = a.resolve(d, "hasPreviousPage"); | ||
null === (c = e.pageInfo = { | ||
__typename: "string" == typeof c ? c : "PageInfo", | ||
hasNextPage: "boolean" == typeof m ? m : !!b, | ||
hasPreviousPage: "boolean" == typeof d ? d : !!r, | ||
endCursor: b, | ||
startCursor: r | ||
}).endCursor && (b = g[g.length - 1]) && (b = a.resolve(b, "cursor"), c.endCursor = ensureKey(b)); | ||
null === c.startCursor && (g = g[0]) && (a = a.resolve(g, "cursor"), c.startCursor = ensureKey(a)); | ||
} | ||
return e; | ||
}; | ||
exports.relayPagination = function(a) { | ||
void 0 === a && (a = {}); | ||
var g = a.mergeMode || "inwards"; | ||
return function(a, c, b, d) { | ||
var e, m, v, t, u, q, n, k, l, p, h, f, w, x; | ||
e = d.fieldName; | ||
if (0 !== (v = (m = b.inspectFields(a = d.parentKey).filter((function(a) { | ||
return a.fieldName === e; | ||
}))).length)) { | ||
for (t = null, u = [], q = [], n = [], k = [], l = _rollupPluginBabelHelpers._extends({}, defaultPageInfo), | ||
p = 0; p < v; p++) { | ||
f = (h = m[p]).fieldKey; | ||
if (null !== (h = h.arguments) && compareArgs(c, h) && null !== (f = getPage(b, a, f))) { | ||
if ("inwards" === g && "number" == typeof h.last && "number" == typeof h.first) { | ||
l = f.edges.slice(0, h.first + 1); | ||
w = f.edges.slice(-h.last), x = f.nodes.slice(0, h.first + 1); | ||
h = f.nodes.slice(-h.last); | ||
u = concatEdges(b, u, l); | ||
q = concatEdges(b, w, q); | ||
n = concatNodes(n, x); | ||
k = concatNodes(h, k); | ||
l = f.pageInfo; | ||
} else { | ||
h.after ? (u = concatEdges(b, u, f.edges), n = concatNodes(n, f.nodes), l.endCursor = f.pageInfo.endCursor, | ||
l.hasNextPage = f.pageInfo.hasNextPage) : h.before ? (q = concatEdges(b, f.edges, q), | ||
k = concatNodes(f.nodes, k), l.startCursor = f.pageInfo.startCursor, l.hasPreviousPage = f.pageInfo.hasPreviousPage) : ("number" == typeof h.last ? (q = concatEdges(b, q, f.edges), | ||
k = concatNodes(k, f.nodes)) : (u = concatEdges(b, u, f.edges), n = concatNodes(n, f.nodes)), | ||
l = f.pageInfo); | ||
} | ||
f.pageInfo.__typename !== l.__typename && (l.__typename = f.pageInfo.__typename); | ||
t !== f.__typename && (t = f.__typename); | ||
} | ||
} | ||
if ("string" == typeof t) { | ||
if (!ensureKey(b.resolve(a, e, c))) { | ||
if (d.store.schema) { | ||
d.partial = !0; | ||
} else { | ||
return; | ||
} | ||
} | ||
return { | ||
__typename: t, | ||
edges: "inwards" === g ? concatEdges(b, u, q) : concatEdges(b, q, u), | ||
nodes: "inwards" === g ? concatNodes(n, k) : concatNodes(k, n), | ||
pageInfo: { | ||
__typename: l.__typename, | ||
endCursor: l.endCursor, | ||
startCursor: l.startCursor, | ||
hasNextPage: l.hasNextPage, | ||
hasPreviousPage: l.hasPreviousPage | ||
} | ||
}; | ||
} | ||
} | ||
}; | ||
}; | ||
exports.simplePagination = function(a) { | ||
var g, e, c; | ||
void 0 === a && (a = {}); | ||
void 0 === (g = a.offsetArgument) && (g = "skip"); | ||
void 0 === (e = a.limitArgument) && (e = "limit"); | ||
c = function(a, d) { | ||
var b, c, v, t; | ||
for (b in d) { | ||
if (b !== g && b !== e) { | ||
if (!(b in a)) { | ||
return !1; | ||
} | ||
if (typeof (c = a[b]) != typeof (v = d[b]) || "object" != typeof c ? c !== v : core.stringifyVariables(c) !== core.stringifyVariables(v)) { | ||
return !1; | ||
} | ||
} | ||
} | ||
for (t in a) { | ||
if (t !== g && t !== e && !(t in d)) { | ||
return !1; | ||
} | ||
} | ||
return !0; | ||
}; | ||
return function(a, d, e, m) { | ||
var b, t, u, q, n, k, l, p, h, f, r; | ||
b = m.fieldName; | ||
if (0 !== (u = (t = e.inspectFields(a = m.parentKey).filter((function(a) { | ||
return a.fieldName === b; | ||
}))).length)) { | ||
for (q = new Set, n = [], k = null, l = 0; l < u; l++) { | ||
h = (p = t[l]).fieldKey; | ||
if (null !== (p = p.arguments) && c(d, p) && (h = e.resolveFieldByKey(a, h), p = p[g], | ||
null !== h && 0 !== h.length && "number" == typeof p)) { | ||
if (!k || p > k) { | ||
for (k = 0; k < h.length; k++) { | ||
q.has(f = h[k]) || (n.push(f), q.add(f)); | ||
} | ||
} else { | ||
k = []; | ||
for (f = 0; f < h.length; f++) { | ||
q.has(r = h[f]) || (k.push(r), q.add(r)); | ||
} | ||
n = k.concat(n); | ||
} | ||
k = p; | ||
} | ||
} | ||
if (e.resolve(a, b, d)) { | ||
return n; | ||
} | ||
if (m.store.schema) { | ||
return m.partial = !0, n; | ||
} | ||
} | ||
}; | ||
}; | ||
//# sourceMappingURL=urql-exchange-graphcache-extras.js.map |
@@ -1,2 +0,1106 @@ | ||
"use strict";var e=require("./7832a774.js"),t=require("graphql"),r=require("@urql/core"),n=require("wonka"),i=function(e){return e.name.value},o=function(e){return e.typeCondition.name.value},a=function(e){return e.alias?e.alias.value:i(e)},u=function(e){return e.selectionSet?e.selectionSet.selections:[]},s=function(e){return e.typeCondition?i(e.typeCondition):null},f=function(e){return e.kind===t.Kind.FIELD},c=function(e){return e.kind===t.Kind.INLINE_FRAGMENT},l=function(e,r){var n={},o=0;if(e.arguments&&e.arguments.length)for(var a=0,u=e.arguments.length;a<u;a++){var s=e.arguments[a],f=t.valueFromASTUntyped(s.value,r);null!=f&&(n[i(s)]=f,o++)}return 0<o?n:null},d=function(e,t){if(t&&e.variableDefinitions){for(var r={},n=0,o=e.variableDefinitions.length;n<o;n++){var a=i(e.variableDefinitions[n].variable);r[a]=t[a]}return r}},p=function(e,r){var n={};if(!r)return n;if(e.variableDefinitions)for(var o=0,a=e.variableDefinitions.length;o<a;o++){var u=e.variableDefinitions[o],s=i(u.variable);n[s]=void 0===r[s]&&u.defaultValue?t.valueFromASTUntyped(u.defaultValue,r):r[s]}for(var f in r)f in n||(n[f]=r[f]);return n};function v(e,t,r){if(!e)throw(e=Error((t||"Minfied Error #"+r+"\n")+"\nhttps://bit.ly/2XbVrpR#"+r)).name="Graphcache Error",e}new Set;var y=function(e){for(var r=0;r<e.definitions.length;r++)if(e.definitions[r].kind===t.Kind.OPERATION_DEFINITION)return e.definitions[r];v(!1,"",1)},m=function(e){for(var r={},n=0;n<e.definitions.length;n++){var o=e.definitions[n];o.kind===t.Kind.FRAGMENT_DEFINITION&&(r[i(o)]=o)}return r},h=function(e,r){var n=e.directives;if(!n)return!0;for(var o=0,a=n.length;o<a;o++){var u=n[o];if(("include"===(e=i(u))||"skip"===e)&&u.arguments&&u.arguments[0]&&"if"===i(u.arguments[0]))return r=t.valueFromASTUntyped(u.arguments[0].value,r),"include"===e?!!r:!r}return!0},g=/^__/,k=function(e,r,n){return!!g.test(n)||!!(e=q(e,r,n))&&t.isNullableType(e.type)},b=function(e,r,n){return!!(e=q(e,r,n))&&(e=t.isNonNullType(e.type)?e.type.ofType:e.type,t.isListType(e)&&t.isNullableType(e.ofType))},O=function(e,r,n){if(!n)return!1;if(!(r=s(r))||n===r)return!0;var i=e.getType(r),o=e.getType(n);return i instanceof t.GraphQLObjectType?i===o:(function(e,r){v(e instanceof t.GraphQLInterfaceType||e instanceof t.GraphQLUnionType,"",5)}(i),_(o),e.isPossibleType(i,o))},q=function(e,t,r){return _(e=e.getType(t)),e.getFields()[r]};function _(e,r){v(e instanceof t.GraphQLObjectType,"",3)}var w=function(e,t){return t?e+"("+r.stringifyVariables(t)+")":e},x=function(e,t){return e+"."+t},K=function(e){var t=e.indexOf("(");return-1<t?{fieldKey:e,fieldName:e.slice(0,t),arguments:JSON.parse(e.slice(t+1,-1))}:{fieldKey:e,fieldName:e,arguments:null}},E=function(e){var t=e.indexOf(".");return{entityKey:e.slice(0,t).replace(/%2e/g,"."),fieldKey:e=e.slice(t+1)}},S=function(){return Object.create(null)},T=null,F=null,N=null,A=null,M=!1,L=function(){return{optimistic:S(),base:new Map}},D=function(e,t,r,n){T=e,F=t,N=S(),M=!!n,r?n||0<t.optimisticOrder.length?(n||t.commutativeKeys.has(r)?n&&t.commutativeKeys.delete(r):$(t,r),A=r,ee(t,r)):(A=null,re(t,r)):A=null},P=function(){var e=F,t=A;if(M=!1,A=null,t&&-1<e.optimisticOrder.indexOf(t))for(t=e.optimisticOrder.length;0<=--t&&e.refLock[e.optimisticOrder[t]]&&e.commutativeKeys.has(e.optimisticOrder[t]);)oe(e.optimisticOrder[t]);N=F=T=null,e.defer||(e.defer=!0,Promise.resolve().then((function(){D("read",e,null),B(),ue(),P(),e.defer=!1})))},I=function(e,t,r){D("read",e,t,r),P()},R=function(){return v(null!==N,"",2),N},j=function(e,t,r,n){var i=(e=A?e.optimistic[A]:e.base).get(t);void 0===i&&e.set(t,i=S()),void 0!==n||A?i[r]=n:delete i[r]},C=function(e,t,r){for(var n,i=0,o=F.optimisticOrder.length;i<o;i++){var a=F.optimisticOrder[i],u=e.optimistic[a];if(u&&(!M||"write"===T||F.commutativeKeys.has(a))&&void 0!==(n=u.get(t))&&r in n)return n[r]}return void 0!==(n=e.base.get(t))?n[r]:void 0},Q=function(e,t,r,n){var i=void 0!==t[r]?t[r]:0;t=t[r]=i+n|0,void 0!==e&&(0>=t?e.add(r):0>=i&&0<t&&e.delete(r))},G=function(e,t,r,n){if("string"==typeof r)Q(e,t,r,n);else if(Array.isArray(r))for(var i=0,o=r.length;i<o;i++){var a=r[i];a&&Q(e,t,a,n)}},V=function(e,t,r){if(void 0!==r)for(var n in r)t.has(n)||(e.push(K(n)),t.add(n))},U=function(e,t,r,n){V(e,t,n.base.get(r));for(var i=0,o=F.optimisticOrder.length;i<o;i++){var a=n.optimistic[F.optimisticOrder[i]];void 0!==a&&V(e,t,a.get(r))}};function J(e,t,r){if(0<(F.refCount[e]||0))r.delete(e);else{for(var n in F.refLock){if(0<((t=F.refLock[n])[e]||0))return;delete t[e]}if(delete F.refCount[e],r.delete(e),F.records.base.delete(e),n=F.links.base.get(e))for(var i in F.links.base.delete(e),n)G(r,F.refCount,n[i],-1)}}var B=function(){F.gc.forEach(J)},z=function(e,t){"__typename"!==t&&(e!==F.queryRootKey?N[e]=!0:void 0!==t&&(N[x(e,t)]=!0))},X=function(e,t){!M&&F.storage&&F.persist.add(function(e,t){return e.replace(/\./g,"%2e")+"."+t}(e,t))},H=function(e,t){return z(e,t),C(F.records,e,t)},W=function(e,t){return z(e,t),C(F.links,e,t)},Y=function(e,t,r){z(e,t),X(e,t),j(F.records,e,t,r)},Z=function(e,t,r){var n=F;if(A)var i=n.refLock[A]||(n.refLock[A]=S()),o=n.links.optimistic[A];else{i=n.refCount,o=n.links.base;var a=n.gc}o=(o=o&&o.get(e))&&o[t],z(e,t),X(e,t),j(n.links,e,t,r),G(a,i,o,-1),G(a,i,r,1)},$=function(e,t){var r=e.optimisticOrder.indexOf(t);-1===r?e.optimisticOrder.unshift(t):e.commutativeKeys.has(t)||(te(e,t),e.optimisticOrder.splice(r,1),e.optimisticOrder.unshift(t)),e.commutativeKeys.add(t)},ee=function(e,t){-1===e.optimisticOrder.indexOf(t)&&e.optimisticOrder.unshift(t),e.refLock[t]||(e.refLock[t]=S(),e.links.optimistic[t]=new Map,e.records.optimistic[t]=new Map)},te=function(e,t){e.refLock[t]&&(delete e.refLock[t],delete e.records.optimistic[t],delete e.links.optimistic[t])},re=function(e,t){var r=e.optimisticOrder.indexOf(t);-1<r&&(e.optimisticOrder.splice(r,1),e.commutativeKeys.delete(t)),te(e,t)};function ne(e,t){for(var r in e)Z(t,r,e[r])}function ie(e,t){for(var r in e)Y(t,r,e[r])}var oe=function(e){var t=N;N=S();var r=F.links.optimistic[e];r&&r.forEach(ne),(r=F.records.optimistic[e])&&r.forEach(ie),N=t,re(F,e)},ae=function(e){var t=F.links,r=F.records,n=[],i=new Set;return z(e),U(n,i,e,t),U(n,i,e,r),n},ue=function(){if(F.storage){M=!0,T="read";var e=S();F.persist.forEach((function(t){var n,i=E(t),o=i.entityKey;e[t]=void 0!==(n=W(o,i=i.fieldKey))?":"+r.stringifyVariables(n):void 0!==(n=H(o,i))?r.stringifyVariables(n):void 0})),M=!1,F.storage.writeData(e),F.persist.clear()}},se=function(e,t,r,n,i,o){return{store:e,variables:t,fragments:r,parentTypeName:n,parentKey:i,parentFieldKey:"",fieldName:"",partial:!1,optimistic:!!o}},fe=function(e,t,r,n,i){e.parentTypeName=t,e.parentKey=r,e.parentFieldKey=n,e.fieldName=i},ce=function(e,t,r,n){if(!t)return!1;var o=s(e);return!o||t===o||!u(e).some((function(e){return!!f(e)&&(e=w(i(e),l(e,n)),!function(e,t){return void 0!==H(e,t)||void 0!==W(e,t)}(r,e))}))},le=function(e,t,r,n){var o,a=0;return function(){if(void 0!==o){var s=o();if(void 0!==s)return s;o=void 0}for(;a<r.length;)if(s=r[a++],h(s,n.variables))if(f(s)){if("__typename"!==i(s))return s}else if(void 0!==(s=c(s)?s:n.fragments[i(s)])&&(n.store.schema?O(n.store.schema,s,e):ce(s,e,t,n.variables)))return(o=le(e,t,u(s),n))()}},de=function(e){return void 0===e?null:e},pe=function(e,t,r,n){return D("write",e.data,n||null),e=ve(e,t,r),P(),e},ve=function(e,t,r){var n=y(t.query),i={data:r,dependencies:R()},o=e.rootFields[n.operation];return e=se(e,p(n,t.variables),m(t.query),o,o),ye(e,o,u(n),r),i},ye=function(e,t,r,n){var o=t===e.store.rootFields.query,s=!o&&!!e.store.rootNames[t],f=s||o?t:n.__typename;if(f){s||o||!t||Y(t,"__typename",f),r=le(f,t||f,r,e);for(var c;c=r();){o=i(c);var d=l(c,e.variables),p=w(o,d),v=a(c),y=n[v];if(e.optimistic&&s){if(!(y=e.store.optimisticMutations[o]))continue;fe(e,f,f,p,o),y=n[v]=de(y(d||{},e.store,e))}c.selectionSet?t&&!s?(v=x(t,p),c=me(e,u(c),de(y),v),Z(t||f,p,c)):me(e,u(c),de(y)):t&&!s&&Y(t||f,p,y),s&&(fe(e,f,f,x(f,p),o),p=e.store.updates[f][o])&&(n[o]=y,p(n,d||{},e.store,e))}}},me=function(e,t,r,n){if(Array.isArray(r)){for(var i=Array(r.length),o=0,a=r.length;o<a;o++){var u=r[o],s=n?x(n,""+o):void 0;u=me(e,t,u,s),i[o]=u}return i}return null===r?null:(n=e.store.keyOfEntity(r)||n,ye(e,n,t,r),n||null)},he=function(e){var r,n;this.keyOfField=w,e||(e={}),this.resolvers=e.resolvers||{},this.optimisticMutations=e.optimistic||{},this.keys=e.keys||{};var i="Query",o="Mutation",a="Subscription";if(e.schema){var u=this.schema=t.buildClientSchema(e.schema),s=u.getQueryType(),f=u.getMutationType();u=u.getSubscriptionType(),i=s?s.name:i,o=f?f.name:o,a=u?u.name:a}this.updates=((r={})[o]=e.updates&&e.updates.Mutation||{},r[a]=e.updates&&e.updates.Subscription||{},r),this.rootFields={query:i,mutation:o,subscription:a},this.rootNames=((n={})[i]="query",n[o]="mutation",n[a]="subscription",n),this.data=function(e){return{defer:!1,gc:new Set,persist:new Set,queryRootKey:e,refCount:S(),refLock:S(),links:L(),records:L(),commutativeKeys:new Set,optimisticOrder:[],storage:null}}(i)};he.prototype.keyOfEntity=function(e){var t,r=e.__typename,n=e.id,i=e._id;return r?void 0!==this.rootNames[r]?r:(this.keys[r]?t=this.keys[r](e):null!=n?t=""+n:null!=i&&(t=""+i),t?r+":"+t:null):null},he.prototype.resolveFieldByKey=function(e,t){if(null===(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e))return null;var r=H(e,t);return void 0!==r?r:(t=W(e,t))?t:null},he.prototype.resolve=function(e,t,r){return this.resolveFieldByKey(e,w(t,r))},he.prototype.invalidate=function(e,t,r){v(e="string"==typeof e?e:this.keyOfEntity(e),"",19),function(e,t,r){t=t?[{fieldKey:w(t,r)}]:ae(e),r=0;for(var n=t.length;r<n;r++){var i=t[r].fieldKey;void 0!==W(e,i)?Z(e,i,void 0):Y(e,i,void 0)}}(e,t,r)},he.prototype.inspectFields=function(e){return null!==(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e)?ae(e):[]},he.prototype.updateQuery=function(e,t){e=r.createRequest(e.query,e.variables),null!==(t=t(this.readQuery(e)))&&ve(this,e,t)},he.prototype.readQuery=function(e){return ke(this,r.createRequest(e.query,e.variables)).data},he.prototype.readFragment=function(e,t,r){return qe(this,e,t,r)},he.prototype.writeFragment=function(t,r,n){!function(t,r,n,i){r=m(r);var a=Object.keys(r);if(void 0!==(a=r[a[0]])){var s=o(a);n=e._extends({},{__typename:s},n);var f=t.keyOfEntity(n);f&&(t=se(t,i||{},r,s,f),ye(t,f,u(a),n))}}(this,t,r,n)};var ge=function(e,t,r){return D("read",e.data,null),e=ke(e,t,r),P(),e},ke=function(e,t,r){var n=y(t.query),i=e.rootFields[n.operation],o=u(n);return r=r||{},r=i!==(e=se(e,p(n,t.variables),m(t.query),i,i)).store.rootFields.query?be(e,i,o,r):_e(e,i,o,r),{dependencies:R(),partial:void 0!==r&&e.partial,data:void 0===r?null:r}},be=function(e,t,r,n){if("string"!=typeof n.__typename)return n;t=le(t,t,r,e),(r={}).__typename=n.__typename;for(var i;void 0!==(i=t());){var o=a(i),s=n[o];void 0!==i.selectionSet&&null!==s?(s=de(s),r[o]=Oe(e,u(i),s)):r[o]=s}return r},Oe=function(e,t,r){if(Array.isArray(r)){for(var n=Array(r.length),i=0,o=r.length;i<o;i++)n[i]=Oe(e,t,r[i]);return n}return null===r?null:null!==(n=e.store.keyOfEntity(r))?void 0===(e=_e(e,n,t,{}))?null:e:be(e,r.__typename,t,r)},qe=function(t,r,n,i){r=m(r);var a=Object.keys(r);if(void 0===(a=r[a[0]]))return null;var s=o(a);return"string"==typeof n||n.__typename||(n.__typename=s),(n="string"!=typeof n?t.keyOfEntity(e._extends({},{__typename:s},n)):n)?(t=se(t,i||{},r,s,n),_e(t,n,u(a),{})||null):null},_e=function(e,t,r,n,o){var s=e.store,f=t===s.rootFields.query,c=o&&s.keyOfEntity(o)||t;if("string"==typeof(t=f?t:H(c,"__typename")||o&&o.__typename)&&(!o||t===o.__typename)){n.__typename=t,r=le(t,c,r,e);for(var d,p=!1,y=!1;void 0!==(d=r());){var m=i(d),h=l(d,e.variables),g=a(d),b=w(m,h),O=x(c,b),q=H(c,b),_=o?o[m]:void 0,K=s.resolvers[t],E=void 0;if(void 0!==_&&void 0===d.selectionSet)E=_;else if("read"===(v(null!==T,"",2),T)&&K&&"function"==typeof K[m]){if(fe(e,t,c,O,m),void 0!==q&&(n[g]=q),E=K[m](n,h||{},s,e),void 0!==d.selectionSet&&(E=we(e,t,m,O,u(d),n[g]||{},E)),s.schema&&null===E&&!k(s.schema,t,m))return}else void 0===d.selectionSet?E=q:void 0!==_?E=we(e,t,m,O,u(d),n[g],_):void 0!==(h=W(c,b))?E=xe(e,h,t,m,u(d),n[g]):"object"==typeof q&&null!==q&&(E=q);if(void 0===E&&s.schema&&k(s.schema,t,m))y=!0,n[g]=null;else{if(void 0===E)return;p=!0,n[g]=E}}return y&&(e.partial=!0),f&&y&&!p?void 0:n}},we=function(e,t,r,n,i,o,a){if(Array.isArray(a)){var u=e.store;u=!u.schema||b(u.schema,t,r);for(var s=Array(a.length),f=0,c=a.length;f<c;f++){var l=we(e,t,r,x(n,""+f),i,null!=o?o[f]:void 0,a[f]);if(void 0===l&&!u)return;s[f]=void 0!==l?l:null}return s}return null==a?a:null===o?null:Ke(a)?(t=o||{},"string"==typeof a?_e(e,a,i,t):_e(e,n,i,t,a)):void 0},xe=function(e,t,r,n,i,o){if(Array.isArray(t)){var a=e.store;a=a.schema&&b(a.schema,r,n);for(var u=Array(t.length),s=0,f=t.length;s<f;s++){var c=xe(e,t[s],r,n,i,null!=o?o[s]:void 0);if(void 0===c&&!a)return;u[s]=void 0!==c?c:null}return u}return null===t||null===o?null:_e(e,t,i,o||{})},Ke=function(e){return"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename},Ee=function(t,r){return e._extends({},t,{context:e._extends({},t.context,{meta:e._extends({},t.context.meta,{cacheOutcome:r})})})},Se=function(t,n){return r.makeOperation(t.kind,t,e._extends({},t.context,{requestPolicy:n}))};function Te(e){return n.fromArray(e[0])}function Fe(e,t){return e.push(t),e}function Ne(e){return"query"===e.kind&&"network-only"!==e.context.requestPolicy}function Ae(e){return"query"!==e.kind||"network-only"===e.context.requestPolicy}function Me(e){return"miss"!==e.outcome||"cache-only"===e.operation.context.requestPolicy}var Le=function(e){return function(t){function i(e){return Ee(e.operation,"miss")}function o(e){return"miss"===e.outcome&&"cache-only"!==e.operation.context.requestPolicy&&!T(e.dependencies)}function a(e){var t=e.operation,r=e.outcome,n=e.dependencies;return e={operation:Ee(t,r),data:e.data,error:e.error,extensions:e.extensions},("cache-and-network"===t.context.requestPolicy||"cache-first"===t.context.requestPolicy&&"partial"===r)&&(e.stale=!0,T(n)?"cache-and-network"===t.context.requestPolicy&&x.add(t.key):k.reexecuteOperation(Se(t,"network-only"))),e}function s(e){var t=new Set,r=j(e,t);return N(e.operation,t),r}function f(e){return!O.has(e.operation.key)}function c(e){if(q.push(e)<O.size)return n.empty;for(var t=0;t<q.length;t++)$(b.data,q[t].operation.key);for(var r in w)delete w[r];t=[],r=new Set;for(var i;i=q.shift();)t.push(j(i,r));return N(e.operation,r),n.fromArray(t)}function l(e){return O.has(e.operation.key)}var h,g=t.forward,k=t.client,b=new he(e);e&&e.storage&&(h=e.storage.readData().then((function(t){!function(e,t,r){for(var n in D("write",e,null),r){var i=r[n];if(void 0!==i){var o=E(n),a=o.entityKey;o=o.fieldKey,":"===i[0]?Z(a,o,JSON.parse(i.slice(1))):Y(a,o,JSON.parse(i))}}P(),e.storage=t}(b.data,e.storage,t)})));var O=new Map,q=[],_=new Map,w=S(),x=new Set,K=S(),T=function(e){for(var t in e)if(w[t])return!0;return!1},F=function(e,t){if(t)for(var r in t)if(t=K[r]){K[r]=[];for(var n=0,i=t.length;n<i;n++)e.add(t[n])}},N=function(e,t){t.forEach((function(t){if(t!==e.key){var r=_.get(t);if(r){_.delete(t);var n="cache-first";x.has(t)&&(x.delete(t),n="cache-and-network"),k.reexecuteOperation(Se(r,n))}}}))},A=function(e){if("query"===e.kind)$(b.data,e.key);else if("teardown"===e.kind)_.delete(e.key),I(b.data,e.key);else if("mutation"===e.kind&&"network-only"!==e.context.requestPolicy){var t=function(e,t,r){D("write",e.data,r,!0),r=y(t.query);var n={data:{},dependencies:R()},i=e.rootFields[r.operation];return v(i===e.rootFields.mutation,"",10),e=se(e,p(r,t.variables),m(t.query),i,i,!0),ye(e,i,u(r),n.data),P(),n}(b,e,e.key).dependencies;if(!function(e){for(var t in e)return!1;return!0}(t)){for(var n in t)w[n]=!0;O.set(e.key,t),n=new Set,F(n,t),N(e,n)}}return r.makeOperation(e.kind,{key:e.key,query:r.formatDocument(e.query),variables:e.variables?d(y(e.query),e.variables):e.variables},e.context)},M=function(e,t){for(var r in t)(K[r]||(K[r]=[])).push(e.key),_.set(e.key,e)},L=function(e){var t=ge(b,e),r=t.data?t.partial?"partial":"hit":"miss";return M(e,t.dependencies),{outcome:r,operation:e,data:t.data,dependencies:t.dependencies}},j=function(e,t){var r=e.operation,n=e.error,i=e.extensions,o=r.key;if("mutation"===r.kind){var a=O.get(o);F(t,a),O.delete(o)}else $(b.data,r.key);if(e.data){if(o=pe(b,r,e.data,o).dependencies,F(t,o),o=ge(b,r,e.data),e.data=o.data,"query"===r.kind){var u=o.dependencies;F(t,u)}}else I(b.data,r.key);return u&&M(e.operation,u),{data:e.data,error:n,extensions:i,operation:r}};return function(e){e=n.share(e);var t=h?n.mergeMap(Te)(n.take(1)(n.combine(n.scan(Fe,[])(e),n.fromPromise(h)))):n.empty;t=n.share(n.concat([t,e])),e=n.share(n.map(L)(n.filter(Ne)(t))),t=n.filter(Ae)(t);var r=n.map(i)(n.filter(o)(e));return e=n.map(a)(n.filter(Me)(e)),r=n.share(g(n.map(A)(n.merge([t,r])))),t=n.map(s)(n.filter(f)(r)),r=n.mergeMap(c)(n.filter(l)(r)),n.merge([t,r,e])}}},De=function(e){return e&&e.networkError&&!e.response&&("undefined"!=typeof navigator&&!1===navigator.onLine||/request failed|failed to fetch|network\s?error/i.test(e.networkError.message))};exports.Store=he,exports.cacheExchange=Le,exports.offlineExchange=function(e){return function(o){function a(e){return"mutation"!==e.operation.kind||!De(e.error)||!function(e,t){var r,n=t.variables||S(),o=m(t.query);for(t=[].concat(u(y(t.query)));r=t.pop();)if(h(r,n))if(f(r)){if(e[i(r)])return!0}else(r=c(r)?r:o[i(r)])&&t.push.apply(t,u(r));return!1}(b,e.operation)||(O.push(e.operation),q(),!1)}function s(e){return"query"!==e.operation.kind||!De(e.error)||(k(Se(e.operation,"cache-only")),O.push(e.operation),!1)}var l=e.storage;if(l&&l.onOnline&&l.readMetadata&&l.writeMetadata){var d=o.forward,p=o.client;o=o.dispatchDebug;var v=n.makeSubject(),g=v.source,k=v.next,b=e.optimistic||{},O=[],q=function(){for(var e=[],r=0;r<O.length;r++){var n=O[r];"mutation"===n.kind&&e.push({query:t.print(n.query),variables:n.variables})}l.writeMetadata(e)},_=!1,w=function(){if(!_){_=!0;for(var e=0;e<O.length;e++){var t=O[e];"mutation"===t.kind&&k(r.makeOperation("teardown",t))}for(e=0;e<O.length;e++)p.reexecuteOperation(O[e]);O.length=0,_=!1,q()}};l.onOnline(w),l.readMetadata().then((function(e){if(e){for(var t=0;t<e.length;t++)O.push(p.createRequestOperation("mutation",r.createRequest(e[t].query,e[t].variables)));w()}}));var x=Le(e)({client:p,dispatchDebug:o,forward:function(e){return n.filter(a)(d(e))}});return function(e){return e=n.share(e),e=n.merge([g,e]),n.filter(s)(x(e))}}return Le(e)(o)}},exports.query=ge,exports.write=pe; | ||
"use strict"; | ||
function invariant(a, b, c) { | ||
if (!a) { | ||
throw a = b || "Minfied Error #" + c + "\n", "production" !== process.env.NODE_ENV && (a += getDebugOutput()), | ||
(c = Error(a + helpUrl + c)).name = "Graphcache Error", c; | ||
} | ||
} | ||
function warn(a, b) { | ||
cache.has(a) || (console.warn(a + getDebugOutput() + helpUrl + b), cache.add(a)); | ||
} | ||
function expectObjectType(a, b) { | ||
invariant(a instanceof graphql.GraphQLObjectType, "production" !== process.env.NODE_ENV ? "Invalid Object type: The type `" + b + "` is not an object in the defined schema, but the GraphQL document is traversing it." : "", 3); | ||
} | ||
function warnAboutResolver(a) { | ||
"production" !== process.env.NODE_ENV && warn("Invalid resolver: `" + a + "` is not in the defined schema, but the `resolvers` option is referencing it.", 23); | ||
} | ||
function _ref2(a, b, c) { | ||
var d, e; | ||
if (0 < (currentData.refCount[a] || 0)) { | ||
c.delete(a); | ||
} else { | ||
for (d in currentData.refLock) { | ||
if (0 < ((b = currentData.refLock[d])[a] || 0)) { | ||
return; | ||
} | ||
delete b[a]; | ||
} | ||
delete currentData.refCount[a]; | ||
c.delete(a); | ||
currentData.records.base.delete(a); | ||
if (d = currentData.links.base.get(a)) { | ||
currentData.links.base.delete(a); | ||
for (e in d) { | ||
updateRCForLink(c, currentData.refCount, d[e], -1); | ||
} | ||
} | ||
} | ||
} | ||
function _ref3(a, b) { | ||
for (var c in a) { | ||
writeLink(b, c, a[c]); | ||
} | ||
} | ||
function _ref4(a, b) { | ||
for (var c in a) { | ||
writeRecord(b, c, a[c]); | ||
} | ||
} | ||
function _ref2$1(a) { | ||
return wonka.fromArray(a[0]); | ||
} | ||
function _ref3$1(a, b) { | ||
return a.push(b), a; | ||
} | ||
function _ref4$1(a) { | ||
return "query" === a.kind && "network-only" !== a.context.requestPolicy; | ||
} | ||
function _ref5(a) { | ||
return "query" !== a.kind || "network-only" === a.context.requestPolicy; | ||
} | ||
function _ref9(a) { | ||
return "miss" !== a.outcome || "cache-only" === a.operation.context.requestPolicy; | ||
} | ||
var query, read, readRoot, readRootField, readFragment, readSelection, resolveResolverResult, resolveLink, isDataOrKey, addCacheOutcome, toRequestPolicy, cacheExchange, isOptimisticMutation, isOfflineError, offlineExchange, _rollupPluginBabelHelpers = require("./7832a774.js"), graphql = require("graphql"), core = require("@urql/core"), wonka = require("wonka"), getName = function(a) { | ||
return a.name.value; | ||
}, getFragmentTypeName = function(a) { | ||
return a.typeCondition.name.value; | ||
}, getFieldAlias = function(a) { | ||
return a.alias ? a.alias.value : getName(a); | ||
}, getSelectionSet = function(a) { | ||
return a.selectionSet ? a.selectionSet.selections : []; | ||
}, getTypeCondition = function(a) { | ||
return a.typeCondition ? getName(a.typeCondition) : null; | ||
}, isFieldNode = function(a) { | ||
return a.kind === graphql.Kind.FIELD; | ||
}, isInlineFragment = function(a) { | ||
return a.kind === graphql.Kind.INLINE_FRAGMENT; | ||
}, getFieldArguments = function(a, b) { | ||
var e, f, g, h, c = {}, d = 0; | ||
if (a.arguments && a.arguments.length) { | ||
for (e = 0, f = a.arguments.length; e < f; e++) { | ||
null != (h = graphql.valueFromASTUntyped((g = a.arguments[e]).value, b)) && (c[getName(g)] = h, | ||
d++); | ||
} | ||
} | ||
return 0 < d ? c : null; | ||
}, filterVariables = function(a, b) { | ||
var c, d, e, f; | ||
if (b && a.variableDefinitions) { | ||
for (c = {}, d = 0, e = a.variableDefinitions.length; d < e; d++) { | ||
c[f = getName(a.variableDefinitions[d].variable)] = b[f]; | ||
} | ||
return c; | ||
} | ||
}, normalizeVariables = function(a, b) { | ||
var d, e, f, g, h, c = {}; | ||
if (!b) { | ||
return c; | ||
} | ||
if (a.variableDefinitions) { | ||
for (d = 0, e = a.variableDefinitions.length; d < e; d++) { | ||
c[g = getName((f = a.variableDefinitions[d]).variable)] = void 0 === b[g] && f.defaultValue ? graphql.valueFromASTUntyped(f.defaultValue, b) : b[g]; | ||
} | ||
} | ||
for (h in b) { | ||
h in c || (c[h] = b[h]); | ||
} | ||
return c; | ||
}, helpUrl = "\nhttps://bit.ly/2XbVrpR#", cache = new Set, currentDebugStack = [], popDebugNode = function() { | ||
return currentDebugStack.pop(); | ||
}, pushDebugNode = function(a, b) { | ||
var c = ""; | ||
b.kind === graphql.Kind.INLINE_FRAGMENT ? c = a ? 'Inline Fragment on "' + a + '"' : "Inline Fragment" : b.kind === graphql.Kind.OPERATION_DEFINITION ? c = (b.name ? '"' + b.name.value + '"' : "Unnamed") + " " + b.operation : b.kind === graphql.Kind.FRAGMENT_DEFINITION && (c = '"' + b.name.value + '" Fragment'); | ||
c && currentDebugStack.push(c); | ||
}, getDebugOutput = function() { | ||
return currentDebugStack.length ? "\n(Caused At: " + currentDebugStack.join(", ") + ")" : ""; | ||
}, getMainOperation = function(a) { | ||
for (var b = 0; b < a.definitions.length; b++) { | ||
if (a.definitions[b].kind === graphql.Kind.OPERATION_DEFINITION) { | ||
return a.definitions[b]; | ||
} | ||
} | ||
invariant(!1, "production" !== process.env.NODE_ENV ? "Invalid GraphQL document: All GraphQL documents must contain an OperationDefinitionnode for a query, subscription, or mutation." : "", 1); | ||
}, getFragments = function(a) { | ||
var b, c, d; | ||
for (b = {}, c = 0; c < a.definitions.length; c++) { | ||
(d = a.definitions[c]).kind === graphql.Kind.FRAGMENT_DEFINITION && (b[getName(d)] = d); | ||
} | ||
return b; | ||
}, shouldInclude = function(a, b) { | ||
var d, e, f, c = a.directives; | ||
if (!c) { | ||
return !0; | ||
} | ||
for (d = 0, e = c.length; d < e; d++) { | ||
if (("include" === (a = getName(f = c[d])) || "skip" === a) && f.arguments && f.arguments[0] && "if" === getName(f.arguments[0])) { | ||
return b = graphql.valueFromASTUntyped(f.arguments[0].value, b), "include" === a ? !!b : !b; | ||
} | ||
} | ||
return !0; | ||
}, BUILTIN_FIELD_RE = /^__/, isFieldNullable = function(a, b, c) { | ||
if (BUILTIN_FIELD_RE.test(c)) { | ||
return !0; | ||
} | ||
return !!(a = getField(a, b, c)) && graphql.isNullableType(a.type); | ||
}, isListNullable = function(a, b, c) { | ||
if (!(a = getField(a, b, c))) { | ||
return !1; | ||
} | ||
a = graphql.isNonNullType(a.type) ? a.type.ofType : a.type; | ||
return graphql.isListType(a) && graphql.isNullableType(a.ofType); | ||
}, isFieldAvailableOnType = function(a, b, c) { | ||
return BUILTIN_FIELD_RE.test(c) ? !0 : !!getField(a, b, c); | ||
}, isInterfaceOfType = function(a, b, c) { | ||
if (!c) { | ||
return !1; | ||
} | ||
if (!(b = getTypeCondition(b)) || c === b) { | ||
return !0; | ||
} | ||
var d = a.getType(b), e = a.getType(c); | ||
if (d instanceof graphql.GraphQLObjectType) { | ||
return d === e; | ||
} | ||
!function expectAbstractType(a, b) { | ||
invariant(a instanceof graphql.GraphQLInterfaceType || a instanceof graphql.GraphQLUnionType, "production" !== process.env.NODE_ENV ? "Invalid Abstract type: The type `" + b + "` is not an Interface or Union type in the defined schema, but a fragment in the GraphQL document is using it as a type condition." : "", 5); | ||
}(d, b); | ||
expectObjectType(e, c); | ||
return a.isPossibleType(d, e); | ||
}, getField = function(a, b, c) { | ||
expectObjectType(a = a.getType(b), b); | ||
a = a.getFields()[c]; | ||
"production" !== process.env.NODE_ENV && (a || warn("Invalid field: The field `" + c + "` does not exist on `" + b + "`, but the GraphQL document expects it to exist.\nTraversal will continue, however this may lead to undefined behavior!", 4)); | ||
return a; | ||
}, keyOfField = function(a, b) { | ||
return b ? a + "(" + core.stringifyVariables(b) + ")" : a; | ||
}, joinKeys = function(a, b) { | ||
return a + "." + b; | ||
}, fieldInfoOfKey = function(a) { | ||
var b = a.indexOf("("); | ||
return -1 < b ? { | ||
fieldKey: a, | ||
fieldName: a.slice(0, b), | ||
arguments: JSON.parse(a.slice(b + 1, -1)) | ||
} : { | ||
fieldKey: a, | ||
fieldName: a, | ||
arguments: null | ||
}; | ||
}, serializeKeys = function(a, b) { | ||
return a.replace(/\./g, "%2e") + "." + b; | ||
}, deserializeKeyInfo = function(a) { | ||
var b = a.indexOf("."); | ||
return { | ||
entityKey: a.slice(0, b).replace(/%2e/g, "."), | ||
fieldKey: a = a.slice(b + 1) | ||
}; | ||
}, makeDict = function() { | ||
return Object.create(null); | ||
}, isDictEmpty = function(a) { | ||
for (var b in a) { | ||
return !1; | ||
} | ||
return !0; | ||
}, currentOperation = null, currentData = null, currentDependencies = null, currentOptimisticKey = null, currentOptimistic = !1, makeNodeMap = function() { | ||
return { | ||
optimistic: makeDict(), | ||
base: new Map | ||
}; | ||
}, initDataState = function(a, b, c, d) { | ||
currentOperation = a; | ||
currentData = b; | ||
currentDependencies = makeDict(); | ||
currentOptimistic = !!d; | ||
"production" !== process.env.NODE_ENV && (currentDebugStack.length = 0); | ||
c ? d || 0 < b.optimisticOrder.length ? (d || b.commutativeKeys.has(c) ? d && b.commutativeKeys.delete(c) : reserveLayer(b, c), | ||
currentOptimisticKey = c, createLayer(b, c)) : (currentOptimisticKey = null, deleteLayer(b, c)) : currentOptimisticKey = null; | ||
}, clearDataState = function() { | ||
"production" !== process.env.NODE_ENV && getCurrentDependencies(); | ||
var b = currentData, c = currentOptimisticKey; | ||
currentOptimistic = !1; | ||
currentOptimisticKey = null; | ||
if (c && -1 < b.optimisticOrder.indexOf(c)) { | ||
for (c = b.optimisticOrder.length; 0 <= --c && b.refLock[b.optimisticOrder[c]] && b.commutativeKeys.has(b.optimisticOrder[c]); ) { | ||
squashLayer(b.optimisticOrder[c]); | ||
} | ||
} | ||
currentDependencies = currentData = currentOperation = null; | ||
"production" !== process.env.NODE_ENV && (currentDebugStack.length = 0); | ||
"test" === process.env.NODE_ENV || b.defer || (b.defer = !0, Promise.resolve().then((function a() { | ||
initDataState("read", b, null); | ||
gc(); | ||
persistData(); | ||
clearDataState(); | ||
b.defer = !1; | ||
}))); | ||
}, noopDataState = function(a, b, c) { | ||
initDataState("read", a, b, c); | ||
clearDataState(); | ||
}, getCurrentOperation = function() { | ||
invariant(null !== currentOperation, "production" !== process.env.NODE_ENV ? "Invalid Cache call: The cache may only be accessed or mutated duringoperations like write or query, or as part of its resolvers, updaters, or optimistic configs." : "", 2); | ||
return currentOperation; | ||
}, getCurrentDependencies = function() { | ||
invariant(null !== currentDependencies, "production" !== process.env.NODE_ENV ? "Invalid Cache call: The cache may only be accessed or mutated duringoperations like write or query, or as part of its resolvers, updaters, or optimistic configs." : "", 2); | ||
return currentDependencies; | ||
}, make = function(a) { | ||
return { | ||
defer: !1, | ||
gc: new Set, | ||
persist: new Set, | ||
queryRootKey: a, | ||
refCount: makeDict(), | ||
refLock: makeDict(), | ||
links: makeNodeMap(), | ||
records: makeNodeMap(), | ||
commutativeKeys: new Set, | ||
optimisticOrder: [], | ||
storage: null | ||
}; | ||
}, setNode = function(a, b, c, d) { | ||
var e = (a = currentOptimisticKey ? a.optimistic[currentOptimisticKey] : a.base).get(b); | ||
void 0 === e && a.set(b, e = makeDict()); | ||
void 0 !== d || currentOptimisticKey ? e[c] = d : delete e[c]; | ||
}, getNode = function(a, b, c) { | ||
var d, e, f, g, h; | ||
for (e = 0, f = currentData.optimisticOrder.length; e < f; e++) { | ||
if ((h = a.optimistic[g = currentData.optimisticOrder[e]]) && (!currentOptimistic || "write" === currentOperation || currentData.commutativeKeys.has(g)) && void 0 !== (d = h.get(b)) && c in d) { | ||
return d[c]; | ||
} | ||
} | ||
return void 0 !== (d = a.base.get(b)) ? d[c] : void 0; | ||
}, updateRCForEntity = function(a, b, c, d) { | ||
var e = void 0 !== b[c] ? b[c] : 0; | ||
b = b[c] = e + d | 0; | ||
void 0 !== a && (0 >= b ? a.add(c) : 0 >= e && 0 < b && a.delete(c)); | ||
}, updateRCForLink = function(a, b, c, d) { | ||
var e, f, g; | ||
if ("string" == typeof c) { | ||
updateRCForEntity(a, b, c, d); | ||
} else if (Array.isArray(c)) { | ||
for (e = 0, f = c.length; e < f; e++) { | ||
(g = c[e]) && updateRCForEntity(a, b, g, d); | ||
} | ||
} | ||
}, extractNodeFields = function(a, b, c) { | ||
if (void 0 !== c) { | ||
for (var d in c) { | ||
b.has(d) || (a.push(fieldInfoOfKey(d)), b.add(d)); | ||
} | ||
} | ||
}, extractNodeMapFields = function(a, b, c, d) { | ||
var e, f, g; | ||
extractNodeFields(a, b, d.base.get(c)); | ||
for (e = 0, f = currentData.optimisticOrder.length; e < f; e++) { | ||
void 0 !== (g = d.optimistic[currentData.optimisticOrder[e]]) && extractNodeFields(a, b, g.get(c)); | ||
} | ||
}, gc = function() { | ||
currentData.gc.forEach(_ref2); | ||
}, updateDependencies = function(a, b) { | ||
"__typename" !== b && (a !== currentData.queryRootKey ? currentDependencies[a] = !0 : void 0 !== b && (currentDependencies[joinKeys(a, b)] = !0)); | ||
}, updatePersist = function(a, b) { | ||
!currentOptimistic && currentData.storage && currentData.persist.add(serializeKeys(a, b)); | ||
}, readRecord = function(a, b) { | ||
updateDependencies(a, b); | ||
return getNode(currentData.records, a, b); | ||
}, readLink = function(a, b) { | ||
updateDependencies(a, b); | ||
return getNode(currentData.links, a, b); | ||
}, writeRecord = function(a, b, c) { | ||
updateDependencies(a, b); | ||
updatePersist(a, b); | ||
setNode(currentData.records, a, b, c); | ||
}, hasField = function(a, b) { | ||
return void 0 !== readRecord(a, b) || void 0 !== readLink(a, b); | ||
}, writeLink = function(a, b, c) { | ||
var e, f, g, d = currentData; | ||
if (currentOptimisticKey) { | ||
e = d.refLock[currentOptimisticKey] || (d.refLock[currentOptimisticKey] = makeDict()); | ||
f = d.links.optimistic[currentOptimisticKey]; | ||
} else { | ||
e = d.refCount; | ||
f = d.links.base; | ||
g = d.gc; | ||
} | ||
f = (f = f && f.get(a)) && f[b]; | ||
updateDependencies(a, b); | ||
updatePersist(a, b); | ||
setNode(d.links, a, b, c); | ||
updateRCForLink(g, e, f, -1); | ||
updateRCForLink(g, e, c, 1); | ||
}, reserveLayer = function(a, b) { | ||
var c = a.optimisticOrder.indexOf(b); | ||
-1 === c ? a.optimisticOrder.unshift(b) : a.commutativeKeys.has(b) || (clearLayer(a, b), | ||
a.optimisticOrder.splice(c, 1), a.optimisticOrder.unshift(b)); | ||
a.commutativeKeys.add(b); | ||
}, createLayer = function(a, b) { | ||
-1 === a.optimisticOrder.indexOf(b) && a.optimisticOrder.unshift(b); | ||
a.refLock[b] || (a.refLock[b] = makeDict(), a.links.optimistic[b] = new Map, a.records.optimistic[b] = new Map); | ||
}, clearLayer = function(a, b) { | ||
a.refLock[b] && (delete a.refLock[b], delete a.records.optimistic[b], delete a.links.optimistic[b]); | ||
}, deleteLayer = function(a, b) { | ||
var c = a.optimisticOrder.indexOf(b); | ||
-1 < c && (a.optimisticOrder.splice(c, 1), a.commutativeKeys.delete(b)); | ||
clearLayer(a, b); | ||
}, squashLayer = function(a) { | ||
var c, b = currentDependencies; | ||
currentDependencies = makeDict(); | ||
(c = currentData.links.optimistic[a]) && c.forEach(_ref3); | ||
(c = currentData.records.optimistic[a]) && c.forEach(_ref4); | ||
currentDependencies = b; | ||
deleteLayer(currentData, a); | ||
}, inspectFields = function(a) { | ||
var b = currentData.links, c = currentData.records, d = [], e = new Set; | ||
updateDependencies(a); | ||
extractNodeMapFields(d, e, a, b); | ||
extractNodeMapFields(d, e, a, c); | ||
return d; | ||
}, persistData = function() { | ||
if (currentData.storage) { | ||
currentOptimistic = !0; | ||
currentOperation = "read"; | ||
var b = makeDict(); | ||
currentData.persist.forEach((function a(a) { | ||
var f, c = deserializeKeyInfo(a), e = c.entityKey; | ||
void 0 !== (f = readLink(e, c = c.fieldKey)) ? b[a] = ":" + core.stringifyVariables(f) : void 0 !== (f = readRecord(e, c)) ? b[a] = core.stringifyVariables(f) : b[a] = void 0; | ||
})); | ||
currentOptimistic = !1; | ||
currentData.storage.writeData(b); | ||
currentData.persist.clear(); | ||
} | ||
}, hydrateData = function(a, b, c) { | ||
var d, e, f, g; | ||
initDataState("write", a, null); | ||
for (d in c) { | ||
if (void 0 !== (e = c[d])) { | ||
g = (f = deserializeKeyInfo(d)).entityKey; | ||
f = f.fieldKey; | ||
":" === e[0] ? writeLink(g, f, JSON.parse(e.slice(1))) : writeRecord(g, f, JSON.parse(e)); | ||
} | ||
} | ||
clearDataState(); | ||
a.storage = b; | ||
}, makeContext = function(a, b, c, d, e, f) { | ||
return { | ||
store: a, | ||
variables: b, | ||
fragments: c, | ||
parentTypeName: d, | ||
parentKey: e, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
partial: !1, | ||
optimistic: !!f | ||
}; | ||
}, updateContext = function(a, b, c, d, e) { | ||
a.parentTypeName = b; | ||
a.parentKey = c; | ||
a.parentFieldKey = d; | ||
a.fieldName = e; | ||
}, isFragmentHeuristicallyMatching = function(a, b, c, d) { | ||
if (!b) { | ||
return !1; | ||
} | ||
var e = getTypeCondition(a); | ||
if (!e || b === e) { | ||
return !0; | ||
} | ||
"production" !== process.env.NODE_ENV && warn("Heuristic Fragment Matching: A fragment is trying to match against the `" + b + "` type, but the type condition is `" + e + "`. Since GraphQL allows for interfaces `" + e + "` may be aninterface.\nA schema needs to be defined for this match to be deterministic, otherwise the fragment will be matched heuristically!", 16); | ||
return !getSelectionSet(a).some((function(a) { | ||
if (!isFieldNode(a)) { | ||
return !1; | ||
} | ||
a = keyOfField(getName(a), getFieldArguments(a, d)); | ||
return !hasField(c, a); | ||
})); | ||
}, makeSelectionIterator = function(a, b, c, d) { | ||
var e, f = 0; | ||
return function() { | ||
if (void 0 !== e) { | ||
var g = e(); | ||
if (void 0 !== g) { | ||
return g; | ||
} | ||
e = void 0; | ||
"production" !== process.env.NODE_ENV && popDebugNode(); | ||
} | ||
for (;f < c.length; ) { | ||
if (g = c[f++], shouldInclude(g, d.variables)) { | ||
if (!isFieldNode(g)) { | ||
if (void 0 !== (g = isInlineFragment(g) ? g : d.fragments[getName(g)]) && (d.store.schema ? isInterfaceOfType(d.store.schema, g, a) : isFragmentHeuristicallyMatching(g, a, b, d.variables))) { | ||
return "production" !== process.env.NODE_ENV && pushDebugNode(a, g), (e = makeSelectionIterator(a, b, getSelectionSet(g), d))(); | ||
} | ||
} else if ("__typename" !== getName(g)) { | ||
return g; | ||
} | ||
} | ||
} | ||
}; | ||
}, ensureData = function(a) { | ||
return void 0 === a ? null : a; | ||
}, write = function(a, b, c, d) { | ||
initDataState("write", a.data, d || null); | ||
a = startWrite(a, b, c); | ||
clearDataState(); | ||
return a; | ||
}, startWrite = function(a, b, c) { | ||
var d = getMainOperation(b.query), e = { | ||
data: c, | ||
dependencies: getCurrentDependencies() | ||
}, f = a.rootFields[d.operation]; | ||
a = makeContext(a, normalizeVariables(d, b.variables), getFragments(b.query), f, f); | ||
"production" !== process.env.NODE_ENV && pushDebugNode(f, d); | ||
writeSelection(a, f, getSelectionSet(d), c); | ||
"production" !== process.env.NODE_ENV && popDebugNode(); | ||
return e; | ||
}, writeOptimistic = function(a, b, c) { | ||
initDataState("write", a.data, c, !0); | ||
c = getMainOperation(b.query); | ||
var d = { | ||
data: {}, | ||
dependencies: getCurrentDependencies() | ||
}, e = a.rootFields[c.operation]; | ||
invariant(e === a.rootFields.mutation, "production" !== process.env.NODE_ENV ? "writeOptimistic(...) was called with an operation that is not a mutation.\nThis case is unsupported and should never occur." : "", 10); | ||
"production" !== process.env.NODE_ENV && pushDebugNode(e, c); | ||
a = makeContext(a, normalizeVariables(c, b.variables), getFragments(b.query), e, e, !0); | ||
writeSelection(a, e, getSelectionSet(c), d.data); | ||
"production" !== process.env.NODE_ENV && popDebugNode(); | ||
clearDataState(); | ||
return d; | ||
}, writeFragment = function(a, b, c, d) { | ||
var e, f, g; | ||
if (void 0 === (e = (b = getFragments(b))[(e = Object.keys(b))[0]])) { | ||
return "production" !== process.env.NODE_ENV ? warn("writeFragment(...) was called with an empty fragment.\nYou have to call it with at least one fragment in your GraphQL document.", 11) : void 0; | ||
} | ||
f = getFragmentTypeName(e); | ||
c = _rollupPluginBabelHelpers._extends({}, { | ||
__typename: f | ||
}, c); | ||
if (!(g = a.keyOfEntity(c))) { | ||
return "production" !== process.env.NODE_ENV ? warn("Can't generate a key for writeFragment(...) data.\nYou have to pass an `id` or `_id` field or create a custom `keys` config for `" + f + "`.", 12) : void 0; | ||
} | ||
"production" !== process.env.NODE_ENV && pushDebugNode(f, e); | ||
a = makeContext(a, d || {}, b, f, g); | ||
writeSelection(a, g, getSelectionSet(e), c); | ||
"production" !== process.env.NODE_ENV && popDebugNode(); | ||
}, writeSelection = function(a, b, c, d) { | ||
var h, k, m, r, l, e = b === a.store.rootFields.query, f = !e && !!a.store.rootNames[b], g = f || e ? b : d.__typename; | ||
if (g) { | ||
f || e || !b || writeRecord(b, "__typename", g); | ||
c = makeSelectionIterator(g, b || g, c, a); | ||
for (;h = c(); ) { | ||
k = getName(h), m = getFieldArguments(h, a.variables); | ||
e = keyOfField(k, m); | ||
l = d[r = getFieldAlias(h)]; | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (f || void 0 !== l) { | ||
a.store.schema && g && isFieldAvailableOnType(a.store.schema, g, k); | ||
} else { | ||
k = a.optimistic ? "\nYour optimistic result may be missing a field!" : ""; | ||
m = void 0 === h.selectionSet ? "scalar (number, boolean, etc)" : "selection set"; | ||
"production" !== process.env.NODE_ENV && warn("Invalid undefined: The field at `" + e + "` is `undefined`, but the GraphQL query expects a " + m + " for this field." + k, 13); | ||
continue; | ||
} | ||
} | ||
if (a.optimistic && f) { | ||
if (!(l = a.store.optimisticMutations[k])) { | ||
continue; | ||
} | ||
updateContext(a, g, g, e, k); | ||
l = d[r] = ensureData(l(m || {}, a.store, a)); | ||
} | ||
h.selectionSet ? b && !f ? (r = joinKeys(b, e), h = writeField(a, getSelectionSet(h), ensureData(l), r), | ||
writeLink(b || g, e, h)) : writeField(a, getSelectionSet(h), ensureData(l)) : b && !f && writeRecord(b || g, e, l); | ||
f && (updateContext(a, g, g, joinKeys(g, e), k), e = a.store.updates[g][k]) && (d[k] = l, | ||
e(d, m || {}, a.store, a)); | ||
} | ||
} | ||
}, KEYLESS_TYPE_RE = /^__|PageInfo|(Connection|Edge)$/, writeField = function(a, b, c, d) { | ||
var e, f, g, h, k; | ||
if (Array.isArray(c)) { | ||
for (e = Array(c.length), f = 0, g = c.length; f < g; f++) { | ||
h = c[f], k = d ? joinKeys(d, "" + f) : void 0; | ||
h = writeField(a, b, h, k); | ||
e[f] = h; | ||
} | ||
return e; | ||
} | ||
if (null === c) { | ||
return null; | ||
} | ||
e = a.store.keyOfEntity(c); | ||
f = c.__typename; | ||
"production" !== process.env.NODE_ENV && d && void 0 === a.store.keys[c.__typename] && null === e && "string" == typeof f && !KEYLESS_TYPE_RE.test(f) && warn("Invalid key: The GraphQL query at the field at `" + d + "` has a selection set, but no key could be generated for the data at this field.\nYou have to request `id` or `_id` fields for all selection sets or create a custom `keys` config for `" + f + "`.\nEntities without keys will be embedded directly on the parent entity. If this is intentional, create a `keys` config for `" + f + "` that always returns null.", 15); | ||
writeSelection(a, d = e || d, b, c); | ||
return d || null; | ||
}, invalidateEntity = function(a, b, c) { | ||
var d, e; | ||
b = b ? [ { | ||
fieldKey: keyOfField(b, c) | ||
} ] : inspectFields(a); | ||
c = 0; | ||
for (d = b.length; c < d; c++) { | ||
void 0 !== readLink(a, e = b[c].fieldKey) ? writeLink(a, e, void 0) : writeRecord(a, e, void 0); | ||
} | ||
}, Store = function(a) { | ||
var b, c, d, e, f, g, h, k; | ||
this.keyOfField = keyOfField; | ||
a || (a = {}); | ||
this.resolvers = a.resolvers || {}; | ||
this.optimisticMutations = a.optimistic || {}; | ||
this.keys = a.keys || {}; | ||
d = "Query", e = "Mutation", f = "Subscription"; | ||
if (a.schema) { | ||
h = (g = this.schema = graphql.buildClientSchema(a.schema)).getQueryType(), k = g.getMutationType(); | ||
g = g.getSubscriptionType(); | ||
d = h ? h.name : d; | ||
e = k ? k.name : e; | ||
f = g ? g.name : f; | ||
} | ||
this.updates = ((b = {})[e] = a.updates && a.updates.Mutation || {}, b[f] = a.updates && a.updates.Subscription || {}, | ||
b); | ||
this.rootFields = { | ||
query: d, | ||
mutation: e, | ||
subscription: f | ||
}; | ||
this.rootNames = ((c = {})[d] = "query", c[e] = "mutation", c[f] = "subscription", | ||
c); | ||
this.data = make(d); | ||
this.schema && "production" !== process.env.NODE_ENV && (function expectValidKeyingConfig(a, b) { | ||
if ("production" !== process.env.NODE_ENV) { | ||
a = a.getTypeMap(); | ||
for (var c in b) { | ||
"production" !== process.env.NODE_ENV && (a[c] || warn("Invalid Object type: The type `" + c + "` is not an object in the defined schema, but the `keys` option is referencing it.", 20)); | ||
} | ||
} | ||
}(this.schema, this.keys), function expectValidUpdatesConfig(a, b) { | ||
var c, d, e, f, g; | ||
if ("production" !== process.env.NODE_ENV) { | ||
c = a.getMutationType(), d = a.getSubscriptionType(); | ||
a = c ? c.getFields() : {}; | ||
e = d ? d.getFields() : {}; | ||
c = c && b[c.name] || {}; | ||
b = d && b[d.name] || {}; | ||
for (f in c) { | ||
"production" !== process.env.NODE_ENV && void 0 === a[f] && warn("Invalid mutation field: `" + f + "` is not in the defined schema, but the `updates.Mutation` option is referencing it.", 21); | ||
} | ||
for (g in b) { | ||
"production" !== process.env.NODE_ENV && void 0 === e[g] && warn("Invalid subscription field: `" + g + "` is not in the defined schema, but the `updates.Subscription` option is referencing it.", 22); | ||
} | ||
} | ||
}(this.schema, this.updates), function expectValidResolversConfig(a, b) { | ||
var c, d, e, f, g; | ||
if ("production" !== process.env.NODE_ENV) { | ||
c = a.getTypeMap(); | ||
for (d in b) { | ||
if ("Query" === d) { | ||
if (e = a.getQueryType()) { | ||
e = e.getFields(); | ||
for (f in b.Query) { | ||
e[f] || warnAboutResolver("Query." + f); | ||
} | ||
} else { | ||
warnAboutResolver("Query"); | ||
} | ||
} else if (c[d]) { | ||
e = a.getType(d).getFields(); | ||
for (g in b[d]) { | ||
e[g] || warnAboutResolver(d + "." + g); | ||
} | ||
} else { | ||
warnAboutResolver(d); | ||
} | ||
} | ||
} | ||
}(this.schema, this.resolvers), function expectValidOptimisticMutationsConfig(a, b) { | ||
if ("production" !== process.env.NODE_ENV) { | ||
a = a.getMutationType() ? a.getMutationType().getFields() : {}; | ||
for (var c in b) { | ||
"production" !== process.env.NODE_ENV && (a[c] || warn("Invalid optimistic mutation field: `" + c + "` is not a mutation field in the defined schema, but the `optimistic` option is referencing it.", 24)); | ||
} | ||
} | ||
}(this.schema, this.optimisticMutations)); | ||
}; | ||
Store.prototype.keyOfEntity = function(a) { | ||
var e, b = a.__typename, c = a.id, d = a._id; | ||
if (!b) { | ||
return null; | ||
} | ||
if (void 0 !== this.rootNames[b]) { | ||
return b; | ||
} | ||
this.keys[b] ? e = this.keys[b](a) : null != c ? e = "" + c : null != d && (e = "" + d); | ||
return e ? b + ":" + e : null; | ||
}; | ||
Store.prototype.resolveFieldByKey = function(a, b) { | ||
if (null === (a = null !== a && "string" != typeof a ? this.keyOfEntity(a) : a)) { | ||
return null; | ||
} | ||
var c = readRecord(a, b); | ||
return void 0 !== c ? c : (b = readLink(a, b)) ? b : null; | ||
}; | ||
Store.prototype.resolve = function(a, b, c) { | ||
return this.resolveFieldByKey(a, keyOfField(b, c)); | ||
}; | ||
Store.prototype.invalidate = function(a, b, c) { | ||
var d = "string" == typeof a ? a : this.keyOfEntity(a); | ||
invariant(d, "production" !== process.env.NODE_ENV ? "object" == "Can't generate a key for invalidate(...).\nYou have to pass an id or _id field or create a custom `keys` field for `" + typeof a ? a.__typename : a + "`." : "", 19); | ||
invalidateEntity(d, b, c); | ||
}; | ||
Store.prototype.inspectFields = function(a) { | ||
return null !== (a = null !== a && "string" != typeof a ? this.keyOfEntity(a) : a) ? inspectFields(a) : []; | ||
}; | ||
Store.prototype.updateQuery = function(a, b) { | ||
a = core.createRequest(a.query, a.variables); | ||
null !== (b = b(this.readQuery(a))) && startWrite(this, a, b); | ||
}; | ||
Store.prototype.readQuery = function(a) { | ||
return read(this, core.createRequest(a.query, a.variables)).data; | ||
}; | ||
Store.prototype.readFragment = function(a, b, c) { | ||
return readFragment(this, a, b, c); | ||
}; | ||
Store.prototype.writeFragment = function(a, b, c) { | ||
writeFragment(this, a, b, c); | ||
}; | ||
query = function(a, b, c) { | ||
initDataState("read", a.data, null); | ||
a = read(a, b, c); | ||
clearDataState(); | ||
return a; | ||
}, read = function(a, b, c) { | ||
var d = getMainOperation(b.query), e = a.rootFields[d.operation], f = getSelectionSet(d); | ||
a = makeContext(a, normalizeVariables(d, b.variables), getFragments(b.query), e, e); | ||
"production" !== process.env.NODE_ENV && pushDebugNode(e, d); | ||
c = c || {}; | ||
c = e !== a.store.rootFields.query ? readRoot(a, e, f, c) : readSelection(a, e, f, c); | ||
"production" !== process.env.NODE_ENV && popDebugNode(); | ||
return { | ||
dependencies: getCurrentDependencies(), | ||
partial: void 0 === c ? !1 : a.partial, | ||
data: void 0 === c ? null : c | ||
}; | ||
}, readRoot = function(a, b, c, d) { | ||
var e, f, g; | ||
if ("string" != typeof d.__typename) { | ||
return d; | ||
} | ||
b = makeSelectionIterator(b, b, c, a); | ||
(c = {}).__typename = d.__typename; | ||
for (;void 0 !== (e = b()); ) { | ||
g = d[f = getFieldAlias(e)]; | ||
void 0 !== e.selectionSet && null !== g ? (g = ensureData(g), c[f] = readRootField(a, getSelectionSet(e), g)) : c[f] = g; | ||
} | ||
return c; | ||
}, readRootField = function(a, b, c) { | ||
if (Array.isArray(c)) { | ||
for (var d = Array(c.length), e = 0, f = c.length; e < f; e++) { | ||
d[e] = readRootField(a, b, c[e]); | ||
} | ||
return d; | ||
} | ||
if (null === c) { | ||
return null; | ||
} | ||
return null !== (d = a.store.keyOfEntity(c)) ? void 0 === (a = readSelection(a, d, b, {})) ? null : a : readRoot(a, c.__typename, b, c); | ||
}, readFragment = function(a, b, c, d) { | ||
var e, f; | ||
if (void 0 === (e = (b = getFragments(b))[(e = Object.keys(b))[0]])) { | ||
return "production" !== process.env.NODE_ENV && warn("readFragment(...) was called with an empty fragment.\nYou have to call it with at least one fragment in your GraphQL document.", 6), | ||
null; | ||
} | ||
f = getFragmentTypeName(e); | ||
"string" == typeof c || c.__typename || (c.__typename = f); | ||
if (!(c = "string" != typeof c ? a.keyOfEntity(_rollupPluginBabelHelpers._extends({}, { | ||
__typename: f | ||
}, c)) : c)) { | ||
return "production" !== process.env.NODE_ENV && warn("Can't generate a key for readFragment(...).\nYou have to pass an `id` or `_id` field or create a custom `keys` config for `" + f + "`.", 7), | ||
null; | ||
} | ||
"production" !== process.env.NODE_ENV && pushDebugNode(f, e); | ||
a = makeContext(a, d || {}, b, f, c); | ||
a = readSelection(a, c, getSelectionSet(e), {}) || null; | ||
"production" !== process.env.NODE_ENV && popDebugNode(); | ||
return a; | ||
}, readSelection = function(a, b, c, d, e) { | ||
var k, m, r, l, w, p, x, t, n, u, v, q, f = a.store, g = b === f.rootFields.query, h = e && f.keyOfEntity(e) || b; | ||
"production" !== process.env.NODE_ENV && !g && a.store.rootNames[h] && warn("Invalid root traversal: A selection was being read on `" + h + "` which is an uncached root type.\nThe `" + a.store.rootFields.mutation + "` and `" + a.store.rootFields.subscription + "` types are special Operation Root Types and cannot be read back from the cache.", 25); | ||
if ("string" == typeof (b = g ? b : readRecord(h, "__typename") || e && e.__typename)) { | ||
if (e && b !== e.__typename) { | ||
"production" !== process.env.NODE_ENV && warn("Invalid resolver data: The resolver at `" + h + "` returned an invalid typename that could not be reconciled with the cache.", 8); | ||
} else { | ||
d.__typename = b; | ||
c = makeSelectionIterator(b, h, c, a); | ||
for (m = !1, r = !1; void 0 !== (k = c()); ) { | ||
l = getName(k), w = getFieldArguments(k, a.variables), p = getFieldAlias(k), x = keyOfField(l, w), | ||
t = joinKeys(h, x), n = readRecord(h, x), u = e ? e[l] : void 0, v = f.resolvers[b]; | ||
"production" !== process.env.NODE_ENV && f.schema && b && isFieldAvailableOnType(f.schema, b, l); | ||
q = void 0; | ||
if (void 0 !== u && void 0 === k.selectionSet) { | ||
q = u; | ||
} else if ("read" === getCurrentOperation() && v && "function" == typeof v[l]) { | ||
if (updateContext(a, b, h, t, l), void 0 !== n && (d[p] = n), q = v[l](d, w || {}, f, a), | ||
void 0 !== k.selectionSet && (q = resolveResolverResult(a, b, l, t, getSelectionSet(k), d[p] || {}, q)), | ||
f.schema && null === q && !isFieldNullable(f.schema, b, l)) { | ||
return; | ||
} | ||
} else { | ||
void 0 === k.selectionSet ? q = n : void 0 !== u ? q = resolveResolverResult(a, b, l, t, getSelectionSet(k), d[p], u) : void 0 !== (w = readLink(h, x)) ? q = resolveLink(a, w, b, l, getSelectionSet(k), d[p]) : "object" == typeof n && null !== n && (q = n); | ||
} | ||
if (void 0 === q && f.schema && isFieldNullable(f.schema, b, l)) { | ||
r = !0, d[p] = null; | ||
} else { | ||
if (void 0 === q) { | ||
return; | ||
} | ||
m = !0; | ||
d[p] = q; | ||
} | ||
} | ||
r && (a.partial = !0); | ||
return g && r && !m ? void 0 : d; | ||
} | ||
} | ||
}, resolveResolverResult = function(a, b, c, d, e, f, g) { | ||
var h, k, m, r, l; | ||
if (Array.isArray(g)) { | ||
h = !(h = a.store).schema || isListNullable(h.schema, b, c); | ||
for (k = Array(g.length), m = 0, r = g.length; m < r; m++) { | ||
if (void 0 !== (l = resolveResolverResult(a, b, c, joinKeys(d, "" + m), e, null != f ? f[m] : void 0, g[m])) || h) { | ||
k[m] = void 0 !== l ? l : null; | ||
} else { | ||
return; | ||
} | ||
} | ||
return k; | ||
} | ||
if (null == g) { | ||
return g; | ||
} | ||
if (null === f) { | ||
return null; | ||
} | ||
if (isDataOrKey(g)) { | ||
return b = f || {}, "string" == typeof g ? readSelection(a, g, e, b) : readSelection(a, d, e, b, g); | ||
} | ||
"production" !== process.env.NODE_ENV && warn("Invalid resolver value: The field at `" + d + "` is a scalar (number, boolean, etc), but the GraphQL query expects a selection set for this field.", 9); | ||
}, resolveLink = function(a, b, c, d, e, f) { | ||
var g, h, k, m, r; | ||
if (Array.isArray(b)) { | ||
g = (g = a.store).schema && isListNullable(g.schema, c, d); | ||
for (h = Array(b.length), k = 0, m = b.length; k < m; k++) { | ||
if (void 0 !== (r = resolveLink(a, b[k], c, d, e, null != f ? f[k] : void 0)) || g) { | ||
h[k] = void 0 !== r ? r : null; | ||
} else { | ||
return; | ||
} | ||
} | ||
return h; | ||
} | ||
return null === b || null === f ? null : readSelection(a, b, e, f || {}); | ||
}, isDataOrKey = function(a) { | ||
return "string" == typeof a || "object" == typeof a && "string" == typeof a.__typename; | ||
}, addCacheOutcome = function(a, b) { | ||
return _rollupPluginBabelHelpers._extends({}, a, { | ||
context: _rollupPluginBabelHelpers._extends({}, a.context, { | ||
meta: _rollupPluginBabelHelpers._extends({}, a.context.meta, { | ||
cacheOutcome: b | ||
}) | ||
}) | ||
}); | ||
}, toRequestPolicy = function(a, b) { | ||
return core.makeOperation(a.kind, a, _rollupPluginBabelHelpers._extends({}, a.context, { | ||
requestPolicy: b | ||
})); | ||
}; | ||
cacheExchange = function(a) { | ||
return function(b) { | ||
function d(a) { | ||
"production" !== process.env.NODE_ENV && w({ | ||
type: "cacheMiss", | ||
message: "The result could not be retrieved from the cache", | ||
operation: a.operation, | ||
source: "cacheExchange" | ||
}); | ||
return addCacheOutcome(a.operation, "miss"); | ||
} | ||
function e(a) { | ||
return "miss" === a.outcome && "cache-only" !== a.operation.context.requestPolicy && !B(a.dependencies); | ||
} | ||
function f(a) { | ||
var b = a.operation, c = a.outcome, d = a.dependencies, e = { | ||
operation: addCacheOutcome(b, c), | ||
data: a.data, | ||
error: a.error, | ||
extensions: a.extensions | ||
}; | ||
if ("cache-and-network" === b.context.requestPolicy || "cache-first" === b.context.requestPolicy && "partial" === c) { | ||
e.stale = !0, B(d) ? "cache-and-network" === b.context.requestPolicy && q.add(b.key) : l.reexecuteOperation(toRequestPolicy(b, "network-only")); | ||
} | ||
"production" !== process.env.NODE_ENV && w({ | ||
type: "cacheHit", | ||
message: "A requested operation was found and returned from the cache.", | ||
operation: a.operation, | ||
data: { | ||
value: e | ||
}, | ||
source: "cacheExchange" | ||
}); | ||
return e; | ||
} | ||
function g(a) { | ||
var b = new Set, c = C(a, b); | ||
A(a.operation, b); | ||
return c; | ||
} | ||
function h(a) { | ||
return !t.has(a.operation.key); | ||
} | ||
function k(a) { | ||
var b, c, d; | ||
if (n.push(a) < t.size) { | ||
return wonka.empty; | ||
} | ||
for (b = 0; b < n.length; b++) { | ||
reserveLayer(p.data, n[b].operation.key); | ||
} | ||
for (c in v) { | ||
delete v[c]; | ||
} | ||
b = []; | ||
c = new Set; | ||
for (;d = n.shift(); ) { | ||
b.push(C(d, c)); | ||
} | ||
A(a.operation, c); | ||
return wonka.fromArray(b); | ||
} | ||
function m(a) { | ||
return t.has(a.operation.key); | ||
} | ||
var x, t, n, u, v, q, y, B, z, A, E, D, F, C, r = b.forward, l = b.client, w = b.dispatchDebug, p = new Store(a); | ||
a && a.storage && (x = a.storage.readData().then((function c(b) { | ||
hydrateData(p.data, a.storage, b); | ||
}))); | ||
t = new Map, n = [], u = new Map, v = makeDict(), q = new Set, y = makeDict(), B = function(a) { | ||
for (var b in a) { | ||
if (v[b]) { | ||
return !0; | ||
} | ||
} | ||
return !1; | ||
}, z = function(a, b) { | ||
var c, d, e; | ||
if (b) { | ||
for (c in b) { | ||
if (b = y[c]) { | ||
y[c] = []; | ||
for (d = 0, e = b.length; d < e; d++) { | ||
a.add(b[d]); | ||
} | ||
} | ||
} | ||
} | ||
}, A = function(a, b) { | ||
b.forEach((function(b) { | ||
var c, d; | ||
if (b !== a.key) { | ||
if (c = u.get(b)) { | ||
u.delete(b); | ||
d = "cache-first"; | ||
q.has(b) && (q.delete(b), d = "cache-and-network"); | ||
l.reexecuteOperation(toRequestPolicy(c, d)); | ||
} | ||
} | ||
})); | ||
}, E = function(a) { | ||
var b, c; | ||
if ("query" === a.kind) { | ||
reserveLayer(p.data, a.key); | ||
} else if ("teardown" === a.kind) { | ||
u.delete(a.key), noopDataState(p.data, a.key); | ||
} else if ("mutation" === a.kind && "network-only" !== a.context.requestPolicy) { | ||
b = writeOptimistic(p, a, a.key).dependencies; | ||
if (!isDictEmpty(b)) { | ||
for (c in b) { | ||
v[c] = !0; | ||
} | ||
t.set(a.key, b); | ||
c = new Set; | ||
z(c, b); | ||
A(a, c); | ||
} | ||
} | ||
return core.makeOperation(a.kind, { | ||
key: a.key, | ||
query: core.formatDocument(a.query), | ||
variables: a.variables ? filterVariables(getMainOperation(a.query), a.variables) : a.variables | ||
}, a.context); | ||
}, D = function(a, b) { | ||
for (var c in b) { | ||
(y[c] || (y[c] = [])).push(a.key), u.set(a.key, a); | ||
} | ||
}, F = function(a) { | ||
var b = query(p, a), c = b.data ? b.partial ? "partial" : "hit" : "miss"; | ||
D(a, b.dependencies); | ||
return { | ||
outcome: c, | ||
operation: a, | ||
data: b.data, | ||
dependencies: b.dependencies | ||
}; | ||
}, C = function(a, b) { | ||
var g, h, c = a.operation, d = a.error, e = a.extensions, f = c.key; | ||
if ("mutation" === c.kind) { | ||
g = t.get(f); | ||
z(b, g); | ||
t.delete(f); | ||
} else { | ||
reserveLayer(p.data, c.key); | ||
} | ||
if (a.data) { | ||
if (f = write(p, c, a.data, f).dependencies, z(b, f), f = query(p, c, a.data), a.data = f.data, | ||
"query" === c.kind) { | ||
z(b, h = f.dependencies); | ||
} | ||
} else { | ||
noopDataState(p.data, c.key); | ||
} | ||
h && D(a.operation, h); | ||
return { | ||
data: a.data, | ||
error: d, | ||
extensions: e, | ||
operation: c | ||
}; | ||
}; | ||
return function(a) { | ||
var b, c; | ||
a = wonka.share(a); | ||
b = x ? wonka.mergeMap(_ref2$1)(wonka.take(1)(wonka.combine(wonka.scan(_ref3$1, [])(a), wonka.fromPromise(x)))) : wonka.empty; | ||
b = wonka.share(wonka.concat([ b, a ])); | ||
a = wonka.share(wonka.map(F)(wonka.filter(_ref4$1)(b))); | ||
b = wonka.filter(_ref5)(b); | ||
c = wonka.map(d)(wonka.filter(e)(a)); | ||
a = wonka.map(f)(wonka.filter(_ref9)(a)); | ||
c = wonka.share(r(wonka.map(E)(wonka.merge([ b, c ])))); | ||
b = wonka.map(g)(wonka.filter(h)(c)); | ||
c = wonka.mergeMap(k)(wonka.filter(m)(c)); | ||
return wonka.merge([ b, c, a ]); | ||
}; | ||
}; | ||
}, isOptimisticMutation = function(a, b) { | ||
var e, c = b.variables || makeDict(), d = getFragments(b.query); | ||
b = [].concat(getSelectionSet(getMainOperation(b.query))); | ||
for (;e = b.pop(); ) { | ||
if (shouldInclude(e, c)) { | ||
if (!isFieldNode(e)) { | ||
(e = isInlineFragment(e) ? e : d[getName(e)]) && b.push.apply(b, getSelectionSet(e)); | ||
} else if (a[getName(e)]) { | ||
return !0; | ||
} | ||
} | ||
} | ||
return !1; | ||
}, isOfflineError = function(a) { | ||
return a && a.networkError && !a.response && ("undefined" != typeof navigator && !1 === navigator.onLine || /request failed|failed to fetch|network\s?error/i.test(a.networkError.message)); | ||
}, offlineExchange = function(a) { | ||
return function(b) { | ||
function e(a) { | ||
return "mutation" === a.operation.kind && isOfflineError(a.error) && isOptimisticMutation(t, a.operation) ? (n.push(a.operation), | ||
u(), !1) : !0; | ||
} | ||
function h(a) { | ||
return "query" === a.operation.kind && isOfflineError(a.error) ? (x(toRequestPolicy(a.operation, "cache-only")), | ||
n.push(a.operation), !1) : !0; | ||
} | ||
var r, l, w, p, x, t, n, u, v, q, y, m = a.storage; | ||
if (m && m.onOnline && m.readMetadata && m.writeMetadata) { | ||
r = b.forward, l = b.client; | ||
b = b.dispatchDebug; | ||
w = wonka.makeSubject(), p = w.source, x = w.next, t = a.optimistic || {}, n = [], | ||
u = function c() { | ||
var a, b, c; | ||
for (a = [], b = 0; b < n.length; b++) { | ||
"mutation" === (c = n[b]).kind && a.push({ | ||
query: graphql.print(c.query), | ||
variables: c.variables | ||
}); | ||
} | ||
m.writeMetadata(a); | ||
}, v = !1; | ||
m.onOnline(q = function d() { | ||
var a, b; | ||
if (!v) { | ||
v = !0; | ||
for (a = 0; a < n.length; a++) { | ||
"mutation" === (b = n[a]).kind && x(core.makeOperation("teardown", b)); | ||
} | ||
for (a = 0; a < n.length; a++) { | ||
l.reexecuteOperation(n[a]); | ||
} | ||
n.length = 0; | ||
v = !1; | ||
u(); | ||
} | ||
}); | ||
m.readMetadata().then((function g(a) { | ||
if (a) { | ||
for (var b = 0; b < a.length; b++) { | ||
n.push(l.createRequestOperation("mutation", core.createRequest(a[b].query, a[b].variables))); | ||
} | ||
q(); | ||
} | ||
})); | ||
y = cacheExchange(a)({ | ||
client: l, | ||
dispatchDebug: b, | ||
forward: function f(a) { | ||
return wonka.filter(e)(r(a)); | ||
} | ||
}); | ||
return function k(a) { | ||
a = wonka.share(a); | ||
a = wonka.merge([ p, a ]); | ||
return wonka.filter(h)(y(a)); | ||
}; | ||
} | ||
return cacheExchange(a)(b); | ||
}; | ||
}; | ||
exports.Store = Store; | ||
exports.cacheExchange = cacheExchange; | ||
exports.offlineExchange = offlineExchange; | ||
exports.query = query; | ||
exports.write = write; | ||
//# sourceMappingURL=urql-exchange-graphcache.js.map |
@@ -18,5 +18,5 @@ { | ||
"dependencies": { | ||
"@urql/core": ">=1.14.0", | ||
"@urql/core": ">=1.14.1", | ||
"wonka": "^4.0.14" | ||
} | ||
} |
{ | ||
"name": "@urql/exchange-graphcache", | ||
"version": "3.1.8", | ||
"version": "3.1.9", | ||
"description": "A normalized and configurable cache exchange for urql", | ||
@@ -68,3 +68,3 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@urql/core": ">=1.14.0", | ||
"@urql/core": ">=1.14.1", | ||
"wonka": "^4.0.14" | ||
@@ -71,0 +71,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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
673516
63
3451
98
Updated@urql/core@>=1.14.1