Socket
Socket
Sign inDemoInstall

@urql/exchange-graphcache

Package Overview
Dependencies
Maintainers
31
Versions
294
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@urql/exchange-graphcache - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

dist/5d7007fe.es.js

8

CHANGELOG.md
# @urql/exchange-graphcache
## 2.2.3
### Patch Changes
- Apply commutative layers to all operations, so now including mutations and subscriptions, to ensure that unordered data is written in the correct order, by [@kitten](https://github.com/kitten) (See [#593](https://github.com/FormidableLabs/urql/pull/593))
- Updated dependencies (See [#607](https://github.com/FormidableLabs/urql/pull/607) and [#601](https://github.com/FormidableLabs/urql/pull/601))
- @urql/core@1.10.0
## 2.2.2

@@ -4,0 +12,0 @@

6

dist/types/store/data.d.ts

@@ -36,7 +36,7 @@ import { Link, EntityField, FieldInfo, StorageAdapter, SerializedEntries } from '../types';

/** Before reading or writing the global state needs to be initialised */
export declare const initDataState: (data: InMemoryData, layerKey: number | null, forceOptimistic?: boolean | undefined) => void;
export declare const initDataState: (data: InMemoryData, layerKey: number | null, isOptimistic?: boolean | undefined) => void;
/** Reset the data state after read/write is complete */
export declare const clearDataState: () => void;
/** Initialises then resets the data state, which may squash this layer if necessary */
export declare const noopDataState: (data: InMemoryData, layerKey: number | null) => void;
export declare const noopDataState: (data: InMemoryData, layerKey: number | null, isOptimistic?: boolean | undefined) => void;
/** As we're writing, we keep around all the records and links we've read or have written to */

@@ -58,3 +58,3 @@ export declare const getCurrentDependencies: () => Set<string>;

export declare const reserveLayer: (data: InMemoryData, layerKey: number) => void;
/** Removes an optimistic layer of links and records */
/** Clears all links and records of an optimistic layer */
export declare const clearLayer: (data: InMemoryData, layerKey: number) => void;

@@ -61,0 +61,0 @@ /** Return an array of FieldInfo (info on all the fields and their arguments) for a given entity */

@@ -162,15 +162,12 @@ "use strict";

"production" !== process.env.NODE_ENV && (currentDebugStack.length = 0);
b ? c || 1 < a.commutativeKeys.size && a.commutativeKeys.has(b) ? (currentOptimisticKey = b,
createLayer(a, b)) : (currentOptimisticKey = null, clearLayer(a, b)) : currentOptimisticKey = null;
b ? c || 1 < a.optimisticOrder.length && -1 < a.optimisticOrder.indexOf(b) ? (c || a.commutativeKeys.has(b) || (clearLayer(a, b),
a.commutativeKeys.add(b)), currentOptimisticKey = b, createLayer(a, b)) : (currentOptimisticKey = null,
deleteLayer(a, b)) : currentOptimisticKey = null;
}, clearDataState = function() {
var c = currentData, e = currentOptimisticKey;
currentOptimisticKey = null;
if (e && c.commutativeKeys.has(e)) {
if (e && -1 < c.optimisticOrder.indexOf(e)) {
e = c.optimisticOrder.length - c.commutativeKeys.size;
for (var d = c.optimisticOrder.length; --d >= e; ) {
if (c.refLock[c.optimisticOrder[d]]) {
squashLayer(c.optimisticOrder[d]);
} else {
break;
}
for (var d = c.optimisticOrder.length; --d >= e && c.refLock[c.optimisticOrder[d]] && c.commutativeKeys.has(c.optimisticOrder[d]); ) {
squashLayer(c.optimisticOrder[d]);
}

@@ -188,4 +185,4 @@ }

})));
}, noopDataState = function(a, b) {
initDataState(a, b);
}, noopDataState = function(a, b, c) {
initDataState(a, b, c);
clearDataState();

@@ -289,2 +286,4 @@ }, getCurrentDependencies = function() {

updateRCForLink(g, d, c, 1);
}, reserveLayer = function(a, b) {
a.commutativeKeys.has(b) || (a.optimisticOrder.unshift(b), a.commutativeKeys.add(b));
}, createLayer = function(a, b) {

@@ -294,5 +293,7 @@ -1 === a.optimisticOrder.indexOf(b) && a.optimisticOrder.unshift(b);

}, 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));
a.refLock[b] && (delete a.refLock[b], delete a.records.optimistic[b], delete a.links.optimistic[b]);
clearLayer(a, b);
};

@@ -319,3 +320,3 @@

currentDependencies = b;
clearLayer(currentData, a);
deleteLayer(currentData, a);
}, isFragmentHeuristicallyMatching = function(a, b, c, e) {

@@ -846,2 +847,4 @@ if (!b) {

return "query" === a.operationName;
}, isMutationOperation = function(a) {
return "mutation" === a.operationName;
}, isCacheableQuery = function(a) {

@@ -944,14 +947,12 @@ return isQueryOperation(a) && "network-only" !== getRequestPolicy(a);

}, r = function(a) {
"query" === a.operationName ? function(a, b) {
a.commutativeKeys.has(b) || (a.optimisticOrder.splice(a.optimisticOrder.length - a.commutativeKeys.size, 0, b),
a.commutativeKeys.add(b));
}(g.data, a.key) : "teardown" === a.operationName && noopDataState(g.data, a.key);
isQueryOperation(a) ? reserveLayer(g.data, a.key) : "teardown" === a.operationName && noopDataState(g.data, a.key);
}, t = function(a) {
var b = a.key;
if (function(a) {
return function(a) {
return "mutation" === a.operationName;
}(a) && "network-only" !== getRequestPolicy(a);
return isMutationOperation(a) && "network-only" !== getRequestPolicy(a);
}(a)) {
var b = a.key, c = writeOptimistic(g, a, b).dependencies;
var c = writeOptimistic(g, a, b).dependencies;
0 !== c.size && (m.set(b, c), b = new Set, q(b, c), u(a, b));
} else {
noopDataState(g.data, b, !0);
}

@@ -974,3 +975,5 @@ }, p = function(a, b) {

var b = a.operation, c = a.error, d = a.extensions, e = isQueryOperation(b), f = a.data, h = b.key, k = new Set;
e || (q(k, m.get(h)), m.delete(h), clearLayer(g.data, h));
isMutationOperation(b) ? (q(k, m.get(h)), m.delete(h)) : function(a) {
return "subscription" === a.operationName;
}(b) && reserveLayer(g.data, b.key);
if (null != f) {

@@ -977,0 +980,0 @@ var l = write(g, b, f, h).dependencies;

@@ -1,2 +0,2 @@

"use strict";var e=require("./5329e1b9.cjs.min.js"),t=require("graphql"),n=require("@urql/core"),r=require("wonka"),i=require("@urql/exchange-populate"),o=function(e){return e.name.value},a=function(e){return e.typeCondition.name.value},s=function(e){return void 0!==e.alias?e.alias.value:o(e)},u=function(e){return void 0!==e.selectionSet?e.selectionSet.selections:[]},c=function(e){return void 0!==(e=e.typeCondition)?o(e):null},l=function(e){return e.kind===t.Kind.FIELD},f=function(e){return e.kind===t.Kind.INLINE_FRAGMENT},d=function(){return Object.create(null)},p=function(e,n){if(void 0===e.arguments||0===e.arguments.length)return null;for(var r=d(),i=0,a=0,s=e.arguments.length;a<s;a++){var u=e.arguments[a],c=t.valueFromASTUntyped(u.value,n);null!=c&&(r[o(u)]=c,i++)}return 0<i?r:null},y=function(e,n){if(void 0===e.variableDefinitions)return{};var r=n||{};return e.variableDefinitions.reduce((function(e,n){var i=o(n.variable),a=r[i];if(void 0===a){if(void 0===n.defaultValue)return e;a=t.valueFromASTUntyped(n.defaultValue,r)}return e[i]=a,e}),d())};function v(e,t,n){if(!e)throw(e=Error((t||"Minfied Error #"+n+"\n")+"\nhttps://bit.ly/38yWDau#"+n)).name="Graphcache Error",e}var m=function(e){return e.kind===t.Kind.FRAGMENT_DEFINITION};function h(e){return e.kind===t.Kind.OPERATION_DEFINITION}var g=function(e){return v(!!(e=e.definitions.find(h)),"",1),e};function k(e,t){return e[o(t)]=t,e}var b=function(e){return e.definitions.filter(m).reduce(k,{})},_=function(e,n){if(void 0===(e=e.directives))return!0;for(var r=0,i=e.length;r<i;r++){var a=e[r],s=o(a),u="include"===s;if((u||"skip"===s)&&(a=a.arguments?a.arguments[0]:null)&&"if"===o(a)&&("boolean"==typeof(a=t.valueFromASTUntyped(a.value,n))||null===a))return u?!!a:!a}return!0},x=function(e,n,r){return void 0!==(e=O(e,n,r))&&t.isNullableType(e.type)},S=function(e,n,r){return void 0!==(e=O(e,n,r))&&(e=t.isNonNullType(e.type)?e.type.ofType:e.type,t.isListType(e)&&t.isNullableType(e.ofType))},K=function(e,n,r){return!(!r||!n)&&(r===n||(n=e.getType(n),r=e.getType(r),n instanceof t.GraphQLObjectType?n===r:(function(e,n){v(e instanceof t.GraphQLInterfaceType||e instanceof t.GraphQLUnionType,"",5)}(n),q(r),e.isPossibleType(n,r))))},O=function(e,t,n){if(q(e=e.getType(t)),void 0!==(n=e.getFields()[n]))return n};function q(e,n){v(e instanceof t.GraphQLObjectType,"",3)}var N=function(e,t){return t?e+"("+n.stringifyVariables(t)+")":e},w=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}},T=function(e,t){return e+"."+t},E=function(e,t){return e+"|"+t},A="undefined"!=typeof Promise?Promise.prototype.then.bind(Promise.resolve()):function(e){return setTimeout(e,0)},F=null,R=null,L=null,M=function(){return{optimistic:d(),base:new Map}},B=function(e,t,n){F=e,R=new Set,t?n||1<e.commutativeKeys.size&&e.commutativeKeys.has(t)?(L=t,Z(e,t)):(L=null,$(e,t)):L=null},Q=function(){var e=F,t=L;if(L=null,t&&e.commutativeKeys.has(t)){t=e.optimisticOrder.length-e.commutativeKeys.size;for(var n=e.optimisticOrder.length;--n>=t&&e.refLock[e.optimisticOrder[n]];)ne(e.optimisticOrder[n])}R=F=null,!e.gcScheduled&&0<e.gcBatch.size&&(e.gcScheduled=!0,A((function(){V(e)}))),e.storage&&!e.persistenceScheduled&&(e.persistenceScheduled=!0,A((function(){e.storage.write(e.persistenceBatch),e.persistenceScheduled=!1,e.persistenceBatch=d()})))},I=function(e,t){B(e,t),Q()},j=function(){return v(null!==R,"",2),R},C=function(e,t,n,r){var i=(e=L?e.optimistic[L]:e.base).get(t);void 0===i&&e.set(t,i=d()),void 0!==r||L?i[n]=r:delete i[n]},D=function(e,t,n){for(var r,i=0,o=F.optimisticOrder.length;i<o;i++){var a=e.optimistic[F.optimisticOrder[i]];if(a&&void 0!==(r=a.get(t))&&n in r)return r[n]}return void 0!==(r=e.base.get(t))?r[n]:void 0},P=function(e,t,n,r){var i=void 0!==t[n]?t[n]:0;t=t[n]=i+r|0,void 0!==e&&(0>=t?e.add(n):0>=i&&0<t&&e.delete(n))},G=function(e,t,n,r){if("string"==typeof n)P(e,t,n,r);else if(Array.isArray(n))for(var i=0,o=n.length;i<o;i++){var a=n[i];a&&P(e,t,a,r)}},z=function(e,t,n){if(void 0!==n)for(var r in n)t.has(r)||(e.push(w(r)),t.add(r))},U=function(e,t,n,r){z(e,t,r.base.get(n));for(var i=0,o=F.optimisticOrder.length;i<o;i++)z(e,t,r.optimistic[F.optimisticOrder[i]].get(n))},V=function(e){e.gcScheduled=!1,e.gcBatch.forEach((function(t){if(0>=(e.refCount[t]||0)){for(var n in e.refLock){var r=e.refLock[n];if(0<(r[t]||0))return;delete r[t]}if(delete e.refCount[t],e.gcBatch.delete(t),void 0!==(n=e.records.base.get(t))&&(e.records.base.delete(t),e.storage))for(var i in n)n=E("r",T(t,i)),e.persistenceBatch[n]=void 0;if(void 0!==(i=e.links.base.get(t)))for(var o in e.links.base.delete(t),i)e.storage&&(n=E("l",T(t,o)),e.persistenceBatch[n]=void 0),G(e.gcBatch,e.refCount,i[o],-1)}else e.gcBatch.delete(t)}))},W=function(e,t){"__typename"!==t&&(e!==F.queryRootKey?R.add(e):void 0!==t&&R.add(T(e,t)))},J=function(e,t){return W(e,t),D(F.records,e,t)},H=function(e,t){return W(e,t),D(F.links,e,t)},X=function(e,t,n){W(e,t),C(F.records,e,t,n),F.storage&&!L&&(e=E("r",T(e,t)),F.persistenceBatch[e]=n)},Y=function(e,t,n){var r=F;if(L)var i=r.refLock[L]||(r.refLock[L]=d()),o=r.links.optimistic[L];else{r.storage&&(i=E("l",T(e,t)),r.persistenceBatch[i]=n),i=r.refCount,o=r.links.base;var a=r.gcBatch}o=void 0!==(o=void 0!==o?o.get(e):void 0)?o[t]:null,W(e,t),C(r.links,e,t,n),G(a,i,o,-1),G(a,i,n,1)},Z=function(e,t){-1===e.optimisticOrder.indexOf(t)&&e.optimisticOrder.unshift(t),e.refLock[t]||(e.refLock[t]=d(),e.links.optimistic[t]=new Map,e.records.optimistic[t]=new Map)},$=function(e,t){var n=e.optimisticOrder.indexOf(t);-1<n&&(e.optimisticOrder.splice(n,1),e.commutativeKeys.delete(t)),e.refLock[t]&&(delete e.refLock[t],delete e.records.optimistic[t],delete e.links.optimistic[t])};function ee(e,t){for(var n in e)Y(t,n,e[n])}function te(e,t){for(var n in e)X(t,n,e[n])}var ne=function(e){var t=R;R=new Set;var n=F.links.optimistic[e];n&&n.forEach(ee),(n=F.records.optimistic[e])&&n.forEach(te),R=t,$(F,e)},re=function(e,t,n,r){return!(!t||t!==c(e)&&u(e).some((function(e){return!!l(e)&&(e=N(o(e),p(e,r)),!function(e,t){return void 0!==J(e,t)||void 0!==H(e,t)}(n,e))})))},ie=function(e,t,n,r){this.typename=e,this.entityKey=t,this.context=r,this.indexStack=[0],this.selectionStack=[n]};ie.prototype.next=function(){for(;0!==this.indexStack.length;){var e=this.indexStack[this.indexStack.length-1]++,t=this.selectionStack[this.selectionStack.length-1];if(e>=t.length)this.indexStack.pop(),this.selectionStack.pop();else if(_(e=t[e],this.context.variables))if(l(e)){if("__typename"!==o(e))return e}else void 0!==(e=f(e)?e:this.context.fragments[o(e)])&&(this.context.store.schema?K(this.context.store.schema,c(e),this.typename):re(e,this.typename,this.entityKey,this.context.variables))&&(this.indexStack.push(0),this.selectionStack.push(u(e)))}};var oe=function(e){return void 0===e?null:e},ae=function(e,t,n,r){return B(e.data,r||null),e=se(e,t,n),Q(),e},se=function(e,t,n){var r=g(t.query),i={dependencies:j()},o=u(r),a=e.getRootKey(r.operation);return a===(e={parentTypeName:a,parentKey:a,parentFieldKey:"",fieldName:"",store:e,variables:y(r,t.variables),fragments:b(t.query)}).store.getRootKey("query")?le(e,a,o,n):de(e,a,o,n),i},ue=function(e,t,n){B(e.data,n,!0);var r=g(t.query);n={dependencies:j()};var i,a=e.getRootKey("mutation"),s=e.getRootKey(r.operation);for(v(s===a,"",10),e={parentTypeName:a,parentKey:a,parentFieldKey:"",fieldName:"",variables:y(r,t.variables),fragments:b(t.query),store:e,optimistic:!0},t=d(),r=new ie(s,s,u(r),e);void 0!==(i=r.next());)if(void 0!==i.selectionSet){var c=o(i),l=e.store.optimisticMutations[c];if(void 0!==l){e.fieldName=c,l=l((s=p(i,e.variables))||d(),e.store,e);var f=oe(l);pe(e,f,u(i)),t[c]=l,void 0!==(i=e.store.updates[a][c])&&i(t,s||d(),e.store,e)}}return Q(),n},ce=function(t,n,r,i){n=b(n);var o=Object.keys(n);if(void 0!==(o=n[o[0]])){var s=a(o);r=e._extends({},{__typename:s},r);var c=t.keyOfEntity(r);c&&le({parentTypeName:s,parentKey:c,parentFieldKey:"",fieldName:"",variables:i||{},fragments:n,store:t},c,u(o),r)}},le=function(e,t,n,r){var i=t===e.store.getRootKey("query")?t:r.__typename;if("string"==typeof i)for(X(t,"__typename",i),n=new ie(i,t,n,e);void 0!==(i=n.next());){var a=o(i),c=p(i,e.variables);a=N(a,c);var l=r[s(i)];c=T(t,a),void 0===i.selectionSet?X(t,a,l):(l=oe(l),i=fe(e,c,u(i),l),Y(t,a,i))}},fe=function(e,t,n,r){if(Array.isArray(r)){for(var i=Array(r.length),o=0,a=r.length;o<a;o++){var s=r[o],u=T(t,""+o);s=fe(e,u,n,s),i[o]=s}return i}return null===r?null:(t=null!==(i=e.store.keyOfEntity(r))?i:t,o=r.__typename,void 0!==e.store.keys[r.__typename]||null!==i||"string"!=typeof o||o.endsWith("Connection")||o.endsWith("Edge"),le(e,t,n,r),t)},de=function(e,t,n,r){var i,a=t===e.store.getRootKey("mutation")||t===e.store.getRootKey("subscription");for(n=new ie(t,t,n,e);void 0!==(i=n.next());){var c=o(i),l=p(i,e.variables),f=T(t,N(c,l));if(void 0!==i.selectionSet){var y=oe(r[s(i)]);pe(e,y,u(i))}a&&(e.parentTypeName=t,e.parentKey=t,e.parentFieldKey=f,e.fieldName=c,void 0!==(i=e.store.updates[t][c])&&i(r,l||d(),e.store,e))}},pe=function(e,t,n){if(Array.isArray(t)){for(var r=Array(t.length),i=0,o=t.length;i<o;i++)r[i]=pe(e,t[i],n);return r}null!==t&&(null!==(r=e.store.keyOfEntity(t))?le(e,r,n,t):de(e,t.__typename,n,t))},ye=function(e,t,n){if("Query"!==t){var r=J(t,"__typename");if("string"!=typeof r)return;X(t,"__typename",void 0)}else r=t;for(n=new ie(r,t,n,e);void 0!==(r=n.next());){var i=o(r),a=N(i,p(r,e.variables));if(void 0===r.selectionSet)X(t,a,void 0);else if(r=u(r),i=H(t,a),Y(t,a,void 0),X(t,a,void 0),Array.isArray(i)){a=0;for(var s=i.length;a<s;a++){var c=i[a];null!==c&&ye(e,c,r)}}else i&&ye(e,i,r)}},ve=function(e,n,r,i,o){var a,s=this;this.gcScheduled=!1,this.gc=function(){V(s.data),s.gcScheduled=!1},this.keyOfField=N,this.resolvers=n||{},this.optimisticMutations=i||{},this.keys=o||{},this.updates={Mutation:r&&r.Mutation||{},Subscription:r&&r.Subscription||{}},e?(r=(n=this.schema=t.buildClientSchema(e)).getQueryType(),e=n.getMutationType(),n=n.getSubscriptionType(),this.rootFields={query:r=r?r.name:"Query",mutation:e=e?e.name:"Mutation",subscription:n=n?n.name:"Subscription"},this.rootNames=((a={})[r]="query",a[e]="mutation",a[n]="subscription",a)):(this.rootFields={query:"Query",mutation:"Mutation",subscription:"Subscription"},this.rootNames={Query:"query",Mutation:"mutation",Subscription:"subscription"}),this.data=function(e){return{persistenceScheduled:!1,persistenceBatch:d(),gcScheduled:!1,queryRootKey:e,gcBatch:new Set,refCount:d(),refLock:d(),links:M(),records:M(),commutativeKeys:new Set,optimisticOrder:[],storage:null}}(this.getRootKey("query"))};ve.prototype.getRootKey=function(e){return this.rootFields[e]},ve.prototype.keyOfEntity=function(e){var t,n=e.__typename,r=e.id,i=e._id;return n?void 0!==this.rootNames[n]?n:(this.keys[n]?t=this.keys[n](e):null!=r?t=""+r:null!=i&&(t=""+i),t?n+":"+t:null):null},ve.prototype.resolveFieldByKey=function(e,t){if(null===(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e))return null;var n=J(e,t);return void 0!==n?n:(t=H(e,t))?t:null},ve.prototype.resolve=function(e,t,n){return this.resolveFieldByKey(e,N(t,n))},ve.prototype.invalidateQuery=function(e,t){!function(e,t){var n=g(t.query);e={variables:y(n,t.variables),fragments:b(t.query),store:e},ye(e,e.store.getRootKey("query"),u(n))}(this,n.createRequest(e,t))},ve.prototype.invalidate=function(e){v(e="string"==typeof e?e:this.keyOfEntity(e),"",19);for(var t=0,n=this.inspectFields(e);t<n.length;t+=1){var r=n[t];H(e,r.fieldKey)?Y(e,r.fieldKey,void 0):X(e,r.fieldKey,void 0)}},ve.prototype.inspectFields=function(e){return null!==(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e)?function(e){var t=F.links,n=F.records,r=[],i=new Set;return W(e),U(r,i,e,t),U(r,i,e,n),r}(e):[]},ve.prototype.updateQuery=function(e,t){e=n.createRequest(e.query,e.variables),null!==(t=t(this.readQuery(e)))&&se(this,e,t)},ve.prototype.readQuery=function(e){return he(this,n.createRequest(e.query,e.variables)).data},ve.prototype.readFragment=function(e,t,n){return be(this,e,t,n)},ve.prototype.writeFragment=function(e,t,n){ce(this,e,t,n)};var me=function(e,t,n){return B(e.data,null),e=he(e,t,n),Q(),e},he=function(e,t,n){var r=g(t.query),i=e.getRootKey(r.operation),o=u(r);return e={parentTypeName:i,parentKey:i,parentFieldKey:"",fieldName:"",store:e,variables:y(r,t.variables),fragments:b(t.query),partial:!1},n=n||d(),n=i!==e.store.getRootKey("query")?ge(e,i,o,n):_e(e,i,o,n),{dependencies:j(),partial:void 0!==n&&e.partial,data:void 0===n?null:n}},ge=function(e,t,n,r){if("string"!=typeof r.__typename)return r;t=new ie(t,t,n,e),(n=d()).__typename=r.__typename;for(var i;void 0!==(i=t.next());){var o=s(i),a=r[o];void 0!==i.selectionSet&&null!==a?(a=oe(a),n[o]=ke(e,u(i),a)):n[o]=a}return n},ke=function(e,t,n){if(Array.isArray(n)){for(var r=Array(n.length),i=0,o=n.length;i<o;i++)r[i]=ke(e,t,n[i]);return r}return null===n?null:null!==(r=e.store.keyOfEntity(n))?void 0===(e=_e(e,r,t,d()))?null:e:ge(e,n.__typename,t,n)},be=function(t,n,r,i){n=b(n);var o=Object.keys(n);if(void 0===(o=n[o[0]]))return null;var s=a(o);return"string"==typeof r||r.__typename||(r.__typename=s),(r="string"!=typeof r?t.keyOfEntity(e._extends({},{__typename:s},r)):r)&&_e({parentTypeName:s,parentKey:r,parentFieldKey:"",fieldName:"",variables:i||{},fragments:n,partial:!1,store:t},r,u(o),d())||null},_e=function(e,t,n,r){var i=e.store,a=t===i.getRootKey("query"),c=a?t:J(t,"__typename");if("string"==typeof c){r.__typename=c,n=new ie(c,t,n,e);for(var l,f=!1,y=!1;void 0!==(l=n.next());){var v=o(l),m=p(l,e.variables),h=s(l),g=N(v,m),k=J(t,g),b=T(t,g),_=void 0,S=i.resolvers[c];if(void 0!==S&&"function"==typeof S[v]){if(e.parentTypeName=c,e.parentKey=t,e.parentFieldKey=b,e.fieldName=v,void 0!==k&&(r[h]=k),_=S[v](r,m||d(),i,e),void 0!==l.selectionSet&&(_=xe(e,c,v,b,u(l),r[h]||d(),_)),i.schema&&null===_&&!x(i.schema,c,v))return}else void 0===l.selectionSet?_=k:void 0!==(m=H(t,g))?_=Se(e,m,c,v,u(l),r[h]):"object"==typeof k&&null!==k&&(_=k);if(void 0===_&&i.schema&&x(i.schema,c,v))y=!0,r[h]=null;else{if(void 0===_)return;f=!0,r[h]=_}}return y&&(e.partial=!0),a&&y&&!f?void 0:r}},xe=function(e,t,n,r,i,a,c){if(Array.isArray(c)){var l=e.store;l=!l.schema||S(l.schema,t,n);for(var f=Array(c.length),y=0,v=c.length;y<v;y++){var m=xe(e,t,n,T(r,""+y),i,void 0!==a?a[y]:void 0,c[y]);if(void 0===m&&!l)return;f[y]=void 0!==m?m:null}return f}return null==c?c:Ke(c)?(t=void 0===a?d():a,"string"==typeof c?_e(e,c,i,t):function(e,t,n,r,i){var a=e.store;t=a.keyOfEntity(i)||t;var c=i.__typename,l=J(t,"__typename")||c;if(!("string"!=typeof l||c&&l!==c)){r.__typename=l,n=new ie(l,t,n,e);for(var f=!1,d=!1;void 0!==(c=n.next());){var y=o(c),v=s(c),m=N(y,p(c,e.variables)),h=T(t,m),g=J(t,m),k=i[y],b=void 0;if(void 0!==k&&void 0===c.selectionSet?b=k:void 0===c.selectionSet?b=g:void 0!==k?b=xe(e,l,y,h,u(c),r[v],k):void 0!==(m=H(t,m))?b=Se(e,m,l,y,u(c),r[v]):"object"==typeof g&&null!==g&&(b=g),void 0===b&&void 0!==a.schema&&x(a.schema,l,y))d=!0,r[v]=null;else{if(void 0===b)return;f=!0,r[v]=b}}return d&&(e.partial=!0),f?r:void 0}}(e,r,i,t,c)):void 0},Se=function(e,t,n,r,i,o){if(Array.isArray(t)){var a=e.store;a=a.schema&&S(a.schema,n,r);for(var s=Array(t.length),u=0,c=t.length;u<c;u++){var l=Se(e,t[u],n,r,i,void 0!==o?o[u]:void 0);if(void 0===l&&!a)return;s[u]=void 0!==l?l:null}return s}return null===t?null:_e(e,t,i,void 0===o?d():o)},Ke=function(e){return"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename},Oe=function(t,n){return e._extends({},t,{context:e._extends({},t.context,{meta:e._extends({},t.context.meta,{cacheOutcome:n})})})},qe=function(t){return e._extends({},t,{query:n.formatDocument(t.query)})},Ne=function(e){return e.context.requestPolicy},we=function(e){return"query"===e.operationName},Te=function(e){return we(e)&&"network-only"!==Ne(e)},Ee=function(t,n){return e._extends({},t,{context:e._extends({},t.context,{requestPolicy:n})})};function Ae(e){return Te(e)}function Fe(e){return Oe(e.operation,e.outcome)}function Re(e){return"miss"===e.outcome}function Le(e){return"miss"!==e.outcome}function Me(e){return"cache-only"!==e.context.requestPolicy}function Be(e){return!Te(e)}exports.populateExchange=i.populateExchange,exports.Store=ve,exports.cacheExchange=function(e){return function(t){function n(e){var t=e.operation,n=e.outcome,r=Ne(t);return e={operation:Oe(t,n),data:e.data,error:e.error,extensions:e.extensions},("cache-and-network"===r||"cache-first"===r&&"partial"===n)&&(e.stale=!0,o.reexecuteOperation(Ee(t,"network-only"))),e}var i=t.forward,o=t.client;e||(e={});var a=new ve(e.schema,e.resolvers,e.updates,e.optimistic,e.keys);if(e.storage)var s=e.storage,u=s.read().then((function(e){!function(e,t,n){for(var r in B(e,null),n){var i=r.indexOf("."),o=r.slice(2,i);switch(i=r.slice(i+1),r.charCodeAt(0)){case 108:Y(o,i,n[r]);break;case 114:X(o,i,n[r])}}Q(),e.storage=t}(a.data,s,e)}));var c=new Map,l=new Map,f=d(),p=function(e,t){void 0!==t&&t.forEach((function(t){var n=f[t];if(void 0!==n){f[t]=[],t=0;for(var r=n.length;t<r;t++)e.add(n[t])}}))},y=function(e,t){t.forEach((function(t){if(t!==e.key){var n=l.get(t);void 0!==n&&(l.delete(t),o.reexecuteOperation(Ee(n,"cache-first")))}}))},v=function(e){"query"===e.operationName?function(e,t){e.commutativeKeys.has(t)||(e.optimisticOrder.splice(e.optimisticOrder.length-e.commutativeKeys.size,0,t),e.commutativeKeys.add(t))}(a.data,e.key):"teardown"===e.operationName&&I(a.data,e.key)},m=function(e){if(function(e){return function(e){return"mutation"===e.operationName}(e)&&"network-only"!==Ne(e)}(e)){var t=e.key,n=ue(a,e,t).dependencies;0!==n.size&&(c.set(t,n),t=new Set,p(t,n),y(e,t))}},h=function(e,t){t.forEach((function(t){(f[t]||(f[t]=[])).push(e.key),l.has(e.key)||l.set(e.key,"network-only"===Ne(e)?Ee(e,"cache-and-network"):e)}))},g=function(e){var t=me(a,e),n=t.data,r=t.dependencies;return t=t.partial,null===n?r="miss":(h(e,r),r=t&&"cache-only"!==Ne(e)?"partial":"hit"),{outcome:r,operation:e,data:n}},k=function(e){var t=e.operation,n=e.error,r=e.extensions,i=we(t),o=e.data,s=t.key,u=new Set;if(i||(p(u,c.get(s)),c.delete(s),$(a.data,s)),null!=o){var l=ae(a,t,o,s).dependencies;if(i){o=(s=me(a,t)).data;var f=s.dependencies}else o=me(a,t,o).data}else I(a.data,t.key);return p(u,l),i&&p(u,f),y(e.operation,u),i&&void 0!==f&&h(e.operation,f),{data:o,error:n,extensions:r,operation:t}};return function(e){e=r.share(e);var t=u?r.mergeMap(r.fromArray)(r.take(1)(r.buffer(r.fromPromise(u))(e))):r.empty;e=r.share(r.tap(m)(r.map(qe)(r.concat([t,e]))));var o=r.share(r.map(g)(r.filter(Ae)(e)));return t=r.map(Fe)(r.filter(Re)(o)),o=r.map(n)(r.filter(Le)(o)),e=r.map(k)(i(r.tap(v)(r.filter(Me)(r.merge([r.filter(Be)(e),t]))))),r.merge([e,o])}}},exports.clearDataState=Q,exports.initDataState=B,exports.query=me,exports.read=he,exports.write=ae,exports.writeFragment=ce,exports.writeOptimistic=ue;
"use strict";var e=require("./5329e1b9.cjs.min.js"),t=require("graphql"),n=require("@urql/core"),r=require("wonka"),i=require("@urql/exchange-populate"),o=function(e){return e.name.value},a=function(e){return e.typeCondition.name.value},s=function(e){return void 0!==e.alias?e.alias.value:o(e)},u=function(e){return void 0!==e.selectionSet?e.selectionSet.selections:[]},c=function(e){return void 0!==(e=e.typeCondition)?o(e):null},l=function(e){return e.kind===t.Kind.FIELD},f=function(e){return e.kind===t.Kind.INLINE_FRAGMENT},d=function(){return Object.create(null)},p=function(e,n){if(void 0===e.arguments||0===e.arguments.length)return null;for(var r=d(),i=0,a=0,s=e.arguments.length;a<s;a++){var u=e.arguments[a],c=t.valueFromASTUntyped(u.value,n);null!=c&&(r[o(u)]=c,i++)}return 0<i?r:null},y=function(e,n){if(void 0===e.variableDefinitions)return{};var r=n||{};return e.variableDefinitions.reduce((function(e,n){var i=o(n.variable),a=r[i];if(void 0===a){if(void 0===n.defaultValue)return e;a=t.valueFromASTUntyped(n.defaultValue,r)}return e[i]=a,e}),d())};function v(e,t,n){if(!e)throw(e=Error((t||"Minfied Error #"+n+"\n")+"\nhttps://bit.ly/38yWDau#"+n)).name="Graphcache Error",e}var m=function(e){return e.kind===t.Kind.FRAGMENT_DEFINITION};function h(e){return e.kind===t.Kind.OPERATION_DEFINITION}var g=function(e){return v(!!(e=e.definitions.find(h)),"",1),e};function k(e,t){return e[o(t)]=t,e}var b=function(e){return e.definitions.filter(m).reduce(k,{})},x=function(e,n){if(void 0===(e=e.directives))return!0;for(var r=0,i=e.length;r<i;r++){var a=e[r],s=o(a),u="include"===s;if((u||"skip"===s)&&(a=a.arguments?a.arguments[0]:null)&&"if"===o(a)&&("boolean"==typeof(a=t.valueFromASTUntyped(a.value,n))||null===a))return u?!!a:!a}return!0},_=function(e,n,r){return void 0!==(e=O(e,n,r))&&t.isNullableType(e.type)},S=function(e,n,r){return void 0!==(e=O(e,n,r))&&(e=t.isNonNullType(e.type)?e.type.ofType:e.type,t.isListType(e)&&t.isNullableType(e.ofType))},K=function(e,n,r){return!(!r||!n)&&(r===n||(n=e.getType(n),r=e.getType(r),n instanceof t.GraphQLObjectType?n===r:(function(e,n){v(e instanceof t.GraphQLInterfaceType||e instanceof t.GraphQLUnionType,"",5)}(n),q(r),e.isPossibleType(n,r))))},O=function(e,t,n){if(q(e=e.getType(t)),void 0!==(n=e.getFields()[n]))return n};function q(e,n){v(e instanceof t.GraphQLObjectType,"",3)}var N=function(e,t){return t?e+"("+n.stringifyVariables(t)+")":e},w=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}},T=function(e,t){return e+"."+t},E=function(e,t){return e+"|"+t},A="undefined"!=typeof Promise?Promise.prototype.then.bind(Promise.resolve()):function(e){return setTimeout(e,0)},F=null,R=null,L=null,M=function(){return{optimistic:d(),base:new Map}},B=function(e,t,n){F=e,R=new Set,t?n||1<e.optimisticOrder.length&&-1<e.optimisticOrder.indexOf(t)?(n||e.commutativeKeys.has(t)||(ee(e,t),e.commutativeKeys.add(t)),L=t,$(e,t)):(L=null,te(e,t)):L=null},Q=function(){var e=F,t=L;if(L=null,t&&-1<e.optimisticOrder.indexOf(t)){t=e.optimisticOrder.length-e.commutativeKeys.size;for(var n=e.optimisticOrder.length;--n>=t&&e.refLock[e.optimisticOrder[n]]&&e.commutativeKeys.has(e.optimisticOrder[n]);)ie(e.optimisticOrder[n])}R=F=null,!e.gcScheduled&&0<e.gcBatch.size&&(e.gcScheduled=!0,A((function(){V(e)}))),e.storage&&!e.persistenceScheduled&&(e.persistenceScheduled=!0,A((function(){e.storage.write(e.persistenceBatch),e.persistenceScheduled=!1,e.persistenceBatch=d()})))},I=function(e,t,n){B(e,t,n),Q()},j=function(){return v(null!==R,"",2),R},C=function(e,t,n,r){var i=(e=L?e.optimistic[L]:e.base).get(t);void 0===i&&e.set(t,i=d()),void 0!==r||L?i[n]=r:delete i[n]},D=function(e,t,n){for(var r,i=0,o=F.optimisticOrder.length;i<o;i++){var a=e.optimistic[F.optimisticOrder[i]];if(a&&void 0!==(r=a.get(t))&&n in r)return r[n]}return void 0!==(r=e.base.get(t))?r[n]:void 0},P=function(e,t,n,r){var i=void 0!==t[n]?t[n]:0;t=t[n]=i+r|0,void 0!==e&&(0>=t?e.add(n):0>=i&&0<t&&e.delete(n))},G=function(e,t,n,r){if("string"==typeof n)P(e,t,n,r);else if(Array.isArray(n))for(var i=0,o=n.length;i<o;i++){var a=n[i];a&&P(e,t,a,r)}},U=function(e,t,n){if(void 0!==n)for(var r in n)t.has(r)||(e.push(w(r)),t.add(r))},z=function(e,t,n,r){U(e,t,r.base.get(n));for(var i=0,o=F.optimisticOrder.length;i<o;i++)U(e,t,r.optimistic[F.optimisticOrder[i]].get(n))},V=function(e){e.gcScheduled=!1,e.gcBatch.forEach((function(t){if(0>=(e.refCount[t]||0)){for(var n in e.refLock){var r=e.refLock[n];if(0<(r[t]||0))return;delete r[t]}if(delete e.refCount[t],e.gcBatch.delete(t),void 0!==(n=e.records.base.get(t))&&(e.records.base.delete(t),e.storage))for(var i in n)n=E("r",T(t,i)),e.persistenceBatch[n]=void 0;if(void 0!==(i=e.links.base.get(t)))for(var o in e.links.base.delete(t),i)e.storage&&(n=E("l",T(t,o)),e.persistenceBatch[n]=void 0),G(e.gcBatch,e.refCount,i[o],-1)}else e.gcBatch.delete(t)}))},W=function(e,t){"__typename"!==t&&(e!==F.queryRootKey?R.add(e):void 0!==t&&R.add(T(e,t)))},J=function(e,t){return W(e,t),D(F.records,e,t)},H=function(e,t){return W(e,t),D(F.links,e,t)},X=function(e,t,n){W(e,t),C(F.records,e,t,n),F.storage&&!L&&(e=E("r",T(e,t)),F.persistenceBatch[e]=n)},Y=function(e,t,n){var r=F;if(L)var i=r.refLock[L]||(r.refLock[L]=d()),o=r.links.optimistic[L];else{r.storage&&(i=E("l",T(e,t)),r.persistenceBatch[i]=n),i=r.refCount,o=r.links.base;var a=r.gcBatch}o=void 0!==(o=void 0!==o?o.get(e):void 0)?o[t]:null,W(e,t),C(r.links,e,t,n),G(a,i,o,-1),G(a,i,n,1)},Z=function(e,t){e.commutativeKeys.has(t)||(e.optimisticOrder.unshift(t),e.commutativeKeys.add(t))},$=function(e,t){-1===e.optimisticOrder.indexOf(t)&&e.optimisticOrder.unshift(t),e.refLock[t]||(e.refLock[t]=d(),e.links.optimistic[t]=new Map,e.records.optimistic[t]=new Map)},ee=function(e,t){e.refLock[t]&&(delete e.refLock[t],delete e.records.optimistic[t],delete e.links.optimistic[t])},te=function(e,t){var n=e.optimisticOrder.indexOf(t);-1<n&&(e.optimisticOrder.splice(n,1),e.commutativeKeys.delete(t)),ee(e,t)};function ne(e,t){for(var n in e)Y(t,n,e[n])}function re(e,t){for(var n in e)X(t,n,e[n])}var ie=function(e){var t=R;R=new Set;var n=F.links.optimistic[e];n&&n.forEach(ne),(n=F.records.optimistic[e])&&n.forEach(re),R=t,te(F,e)},oe=function(e,t,n,r){return!(!t||t!==c(e)&&u(e).some((function(e){return!!l(e)&&(e=N(o(e),p(e,r)),!function(e,t){return void 0!==J(e,t)||void 0!==H(e,t)}(n,e))})))},ae=function(e,t,n,r){this.typename=e,this.entityKey=t,this.context=r,this.indexStack=[0],this.selectionStack=[n]};ae.prototype.next=function(){for(;0!==this.indexStack.length;){var e=this.indexStack[this.indexStack.length-1]++,t=this.selectionStack[this.selectionStack.length-1];if(e>=t.length)this.indexStack.pop(),this.selectionStack.pop();else if(x(e=t[e],this.context.variables))if(l(e)){if("__typename"!==o(e))return e}else void 0!==(e=f(e)?e:this.context.fragments[o(e)])&&(this.context.store.schema?K(this.context.store.schema,c(e),this.typename):oe(e,this.typename,this.entityKey,this.context.variables))&&(this.indexStack.push(0),this.selectionStack.push(u(e)))}};var se=function(e){return void 0===e?null:e},ue=function(e,t,n,r){return B(e.data,r||null),e=ce(e,t,n),Q(),e},ce=function(e,t,n){var r=g(t.query),i={dependencies:j()},o=u(r),a=e.getRootKey(r.operation);return a===(e={parentTypeName:a,parentKey:a,parentFieldKey:"",fieldName:"",store:e,variables:y(r,t.variables),fragments:b(t.query)}).store.getRootKey("query")?de(e,a,o,n):ye(e,a,o,n),i},le=function(e,t,n){B(e.data,n,!0);var r=g(t.query);n={dependencies:j()};var i,a=e.getRootKey("mutation"),s=e.getRootKey(r.operation);for(v(s===a,"",10),e={parentTypeName:a,parentKey:a,parentFieldKey:"",fieldName:"",variables:y(r,t.variables),fragments:b(t.query),store:e,optimistic:!0},t=d(),r=new ae(s,s,u(r),e);void 0!==(i=r.next());)if(void 0!==i.selectionSet){var c=o(i),l=e.store.optimisticMutations[c];if(void 0!==l){e.fieldName=c,l=l((s=p(i,e.variables))||d(),e.store,e);var f=se(l);ve(e,f,u(i)),t[c]=l,void 0!==(i=e.store.updates[a][c])&&i(t,s||d(),e.store,e)}}return Q(),n},fe=function(t,n,r,i){n=b(n);var o=Object.keys(n);if(void 0!==(o=n[o[0]])){var s=a(o);r=e._extends({},{__typename:s},r);var c=t.keyOfEntity(r);c&&de({parentTypeName:s,parentKey:c,parentFieldKey:"",fieldName:"",variables:i||{},fragments:n,store:t},c,u(o),r)}},de=function(e,t,n,r){var i=t===e.store.getRootKey("query")?t:r.__typename;if("string"==typeof i)for(X(t,"__typename",i),n=new ae(i,t,n,e);void 0!==(i=n.next());){var a=o(i),c=p(i,e.variables);a=N(a,c);var l=r[s(i)];c=T(t,a),void 0===i.selectionSet?X(t,a,l):(l=se(l),i=pe(e,c,u(i),l),Y(t,a,i))}},pe=function(e,t,n,r){if(Array.isArray(r)){for(var i=Array(r.length),o=0,a=r.length;o<a;o++){var s=r[o],u=T(t,""+o);s=pe(e,u,n,s),i[o]=s}return i}return null===r?null:(t=null!==(i=e.store.keyOfEntity(r))?i:t,o=r.__typename,void 0!==e.store.keys[r.__typename]||null!==i||"string"!=typeof o||o.endsWith("Connection")||o.endsWith("Edge"),de(e,t,n,r),t)},ye=function(e,t,n,r){var i,a=t===e.store.getRootKey("mutation")||t===e.store.getRootKey("subscription");for(n=new ae(t,t,n,e);void 0!==(i=n.next());){var c=o(i),l=p(i,e.variables),f=T(t,N(c,l));if(void 0!==i.selectionSet){var y=se(r[s(i)]);ve(e,y,u(i))}a&&(e.parentTypeName=t,e.parentKey=t,e.parentFieldKey=f,e.fieldName=c,void 0!==(i=e.store.updates[t][c])&&i(r,l||d(),e.store,e))}},ve=function(e,t,n){if(Array.isArray(t)){for(var r=Array(t.length),i=0,o=t.length;i<o;i++)r[i]=ve(e,t[i],n);return r}null!==t&&(null!==(r=e.store.keyOfEntity(t))?de(e,r,n,t):ye(e,t.__typename,n,t))},me=function(e,t,n){if("Query"!==t){var r=J(t,"__typename");if("string"!=typeof r)return;X(t,"__typename",void 0)}else r=t;for(n=new ae(r,t,n,e);void 0!==(r=n.next());){var i=o(r),a=N(i,p(r,e.variables));if(void 0===r.selectionSet)X(t,a,void 0);else if(r=u(r),i=H(t,a),Y(t,a,void 0),X(t,a,void 0),Array.isArray(i)){a=0;for(var s=i.length;a<s;a++){var c=i[a];null!==c&&me(e,c,r)}}else i&&me(e,i,r)}},he=function(e,n,r,i,o){var a,s=this;this.gcScheduled=!1,this.gc=function(){V(s.data),s.gcScheduled=!1},this.keyOfField=N,this.resolvers=n||{},this.optimisticMutations=i||{},this.keys=o||{},this.updates={Mutation:r&&r.Mutation||{},Subscription:r&&r.Subscription||{}},e?(r=(n=this.schema=t.buildClientSchema(e)).getQueryType(),e=n.getMutationType(),n=n.getSubscriptionType(),this.rootFields={query:r=r?r.name:"Query",mutation:e=e?e.name:"Mutation",subscription:n=n?n.name:"Subscription"},this.rootNames=((a={})[r]="query",a[e]="mutation",a[n]="subscription",a)):(this.rootFields={query:"Query",mutation:"Mutation",subscription:"Subscription"},this.rootNames={Query:"query",Mutation:"mutation",Subscription:"subscription"}),this.data=function(e){return{persistenceScheduled:!1,persistenceBatch:d(),gcScheduled:!1,queryRootKey:e,gcBatch:new Set,refCount:d(),refLock:d(),links:M(),records:M(),commutativeKeys:new Set,optimisticOrder:[],storage:null}}(this.getRootKey("query"))};he.prototype.getRootKey=function(e){return this.rootFields[e]},he.prototype.keyOfEntity=function(e){var t,n=e.__typename,r=e.id,i=e._id;return n?void 0!==this.rootNames[n]?n:(this.keys[n]?t=this.keys[n](e):null!=r?t=""+r:null!=i&&(t=""+i),t?n+":"+t:null):null},he.prototype.resolveFieldByKey=function(e,t){if(null===(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e))return null;var n=J(e,t);return void 0!==n?n:(t=H(e,t))?t:null},he.prototype.resolve=function(e,t,n){return this.resolveFieldByKey(e,N(t,n))},he.prototype.invalidateQuery=function(e,t){!function(e,t){var n=g(t.query);e={variables:y(n,t.variables),fragments:b(t.query),store:e},me(e,e.store.getRootKey("query"),u(n))}(this,n.createRequest(e,t))},he.prototype.invalidate=function(e){v(e="string"==typeof e?e:this.keyOfEntity(e),"",19);for(var t=0,n=this.inspectFields(e);t<n.length;t+=1){var r=n[t];H(e,r.fieldKey)?Y(e,r.fieldKey,void 0):X(e,r.fieldKey,void 0)}},he.prototype.inspectFields=function(e){return null!==(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e)?function(e){var t=F.links,n=F.records,r=[],i=new Set;return W(e),z(r,i,e,t),z(r,i,e,n),r}(e):[]},he.prototype.updateQuery=function(e,t){e=n.createRequest(e.query,e.variables),null!==(t=t(this.readQuery(e)))&&ce(this,e,t)},he.prototype.readQuery=function(e){return ke(this,n.createRequest(e.query,e.variables)).data},he.prototype.readFragment=function(e,t,n){return _e(this,e,t,n)},he.prototype.writeFragment=function(e,t,n){fe(this,e,t,n)};var ge=function(e,t,n){return B(e.data,null),e=ke(e,t,n),Q(),e},ke=function(e,t,n){var r=g(t.query),i=e.getRootKey(r.operation),o=u(r);return e={parentTypeName:i,parentKey:i,parentFieldKey:"",fieldName:"",store:e,variables:y(r,t.variables),fragments:b(t.query),partial:!1},n=n||d(),n=i!==e.store.getRootKey("query")?be(e,i,o,n):Se(e,i,o,n),{dependencies:j(),partial:void 0!==n&&e.partial,data:void 0===n?null:n}},be=function(e,t,n,r){if("string"!=typeof r.__typename)return r;t=new ae(t,t,n,e),(n=d()).__typename=r.__typename;for(var i;void 0!==(i=t.next());){var o=s(i),a=r[o];void 0!==i.selectionSet&&null!==a?(a=se(a),n[o]=xe(e,u(i),a)):n[o]=a}return n},xe=function(e,t,n){if(Array.isArray(n)){for(var r=Array(n.length),i=0,o=n.length;i<o;i++)r[i]=xe(e,t,n[i]);return r}return null===n?null:null!==(r=e.store.keyOfEntity(n))?void 0===(e=Se(e,r,t,d()))?null:e:be(e,n.__typename,t,n)},_e=function(t,n,r,i){n=b(n);var o=Object.keys(n);if(void 0===(o=n[o[0]]))return null;var s=a(o);return"string"==typeof r||r.__typename||(r.__typename=s),(r="string"!=typeof r?t.keyOfEntity(e._extends({},{__typename:s},r)):r)&&Se({parentTypeName:s,parentKey:r,parentFieldKey:"",fieldName:"",variables:i||{},fragments:n,partial:!1,store:t},r,u(o),d())||null},Se=function(e,t,n,r){var i=e.store,a=t===i.getRootKey("query"),c=a?t:J(t,"__typename");if("string"==typeof c){r.__typename=c,n=new ae(c,t,n,e);for(var l,f=!1,y=!1;void 0!==(l=n.next());){var v=o(l),m=p(l,e.variables),h=s(l),g=N(v,m),k=J(t,g),b=T(t,g),x=void 0,S=i.resolvers[c];if(void 0!==S&&"function"==typeof S[v]){if(e.parentTypeName=c,e.parentKey=t,e.parentFieldKey=b,e.fieldName=v,void 0!==k&&(r[h]=k),x=S[v](r,m||d(),i,e),void 0!==l.selectionSet&&(x=Ke(e,c,v,b,u(l),r[h]||d(),x)),i.schema&&null===x&&!_(i.schema,c,v))return}else void 0===l.selectionSet?x=k:void 0!==(m=H(t,g))?x=Oe(e,m,c,v,u(l),r[h]):"object"==typeof k&&null!==k&&(x=k);if(void 0===x&&i.schema&&_(i.schema,c,v))y=!0,r[h]=null;else{if(void 0===x)return;f=!0,r[h]=x}}return y&&(e.partial=!0),a&&y&&!f?void 0:r}},Ke=function(e,t,n,r,i,a,c){if(Array.isArray(c)){var l=e.store;l=!l.schema||S(l.schema,t,n);for(var f=Array(c.length),y=0,v=c.length;y<v;y++){var m=Ke(e,t,n,T(r,""+y),i,void 0!==a?a[y]:void 0,c[y]);if(void 0===m&&!l)return;f[y]=void 0!==m?m:null}return f}return null==c?c:qe(c)?(t=void 0===a?d():a,"string"==typeof c?Se(e,c,i,t):function(e,t,n,r,i){var a=e.store;t=a.keyOfEntity(i)||t;var c=i.__typename,l=J(t,"__typename")||c;if(!("string"!=typeof l||c&&l!==c)){r.__typename=l,n=new ae(l,t,n,e);for(var f=!1,d=!1;void 0!==(c=n.next());){var y=o(c),v=s(c),m=N(y,p(c,e.variables)),h=T(t,m),g=J(t,m),k=i[y],b=void 0;if(void 0!==k&&void 0===c.selectionSet?b=k:void 0===c.selectionSet?b=g:void 0!==k?b=Ke(e,l,y,h,u(c),r[v],k):void 0!==(m=H(t,m))?b=Oe(e,m,l,y,u(c),r[v]):"object"==typeof g&&null!==g&&(b=g),void 0===b&&void 0!==a.schema&&_(a.schema,l,y))d=!0,r[v]=null;else{if(void 0===b)return;f=!0,r[v]=b}}return d&&(e.partial=!0),f?r:void 0}}(e,r,i,t,c)):void 0},Oe=function(e,t,n,r,i,o){if(Array.isArray(t)){var a=e.store;a=a.schema&&S(a.schema,n,r);for(var s=Array(t.length),u=0,c=t.length;u<c;u++){var l=Oe(e,t[u],n,r,i,void 0!==o?o[u]:void 0);if(void 0===l&&!a)return;s[u]=void 0!==l?l:null}return s}return null===t?null:Se(e,t,i,void 0===o?d():o)},qe=function(e){return"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename},Ne=function(t,n){return e._extends({},t,{context:e._extends({},t.context,{meta:e._extends({},t.context.meta,{cacheOutcome:n})})})},we=function(t){return e._extends({},t,{query:n.formatDocument(t.query)})},Te=function(e){return e.context.requestPolicy},Ee=function(e){return"query"===e.operationName},Ae=function(e){return"mutation"===e.operationName},Fe=function(e){return Ee(e)&&"network-only"!==Te(e)},Re=function(t,n){return e._extends({},t,{context:e._extends({},t.context,{requestPolicy:n})})};function Le(e){return Fe(e)}function Me(e){return Ne(e.operation,e.outcome)}function Be(e){return"miss"===e.outcome}function Qe(e){return"miss"!==e.outcome}function Ie(e){return"cache-only"!==e.context.requestPolicy}function je(e){return!Fe(e)}exports.populateExchange=i.populateExchange,exports.Store=he,exports.cacheExchange=function(e){return function(t){function n(e){var t=e.operation,n=e.outcome,r=Te(t);return e={operation:Ne(t,n),data:e.data,error:e.error,extensions:e.extensions},("cache-and-network"===r||"cache-first"===r&&"partial"===n)&&(e.stale=!0,o.reexecuteOperation(Re(t,"network-only"))),e}var i=t.forward,o=t.client;e||(e={});var a=new he(e.schema,e.resolvers,e.updates,e.optimistic,e.keys);if(e.storage)var s=e.storage,u=s.read().then((function(e){!function(e,t,n){for(var r in B(e,null),n){var i=r.indexOf("."),o=r.slice(2,i);switch(i=r.slice(i+1),r.charCodeAt(0)){case 108:Y(o,i,n[r]);break;case 114:X(o,i,n[r])}}Q(),e.storage=t}(a.data,s,e)}));var c=new Map,l=new Map,f=d(),p=function(e,t){void 0!==t&&t.forEach((function(t){var n=f[t];if(void 0!==n){f[t]=[],t=0;for(var r=n.length;t<r;t++)e.add(n[t])}}))},y=function(e,t){t.forEach((function(t){if(t!==e.key){var n=l.get(t);void 0!==n&&(l.delete(t),o.reexecuteOperation(Re(n,"cache-first")))}}))},v=function(e){Ee(e)?Z(a.data,e.key):"teardown"===e.operationName&&I(a.data,e.key)},m=function(e){var t=e.key;if(function(e){return Ae(e)&&"network-only"!==Te(e)}(e)){var n=le(a,e,t).dependencies;0!==n.size&&(c.set(t,n),t=new Set,p(t,n),y(e,t))}else I(a.data,t,!0)},h=function(e,t){t.forEach((function(t){(f[t]||(f[t]=[])).push(e.key),l.has(e.key)||l.set(e.key,"network-only"===Te(e)?Re(e,"cache-and-network"):e)}))},g=function(e){var t=ge(a,e),n=t.data,r=t.dependencies;return t=t.partial,null===n?r="miss":(h(e,r),r=t&&"cache-only"!==Te(e)?"partial":"hit"),{outcome:r,operation:e,data:n}},k=function(e){var t=e.operation,n=e.error,r=e.extensions,i=Ee(t),o=e.data,s=t.key,u=new Set;if(Ae(t)?(p(u,c.get(s)),c.delete(s)):function(e){return"subscription"===e.operationName}(t)&&Z(a.data,t.key),null!=o){var l=ue(a,t,o,s).dependencies;if(i){o=(s=ge(a,t)).data;var f=s.dependencies}else o=ge(a,t,o).data}else I(a.data,t.key);return p(u,l),i&&p(u,f),y(e.operation,u),i&&void 0!==f&&h(e.operation,f),{data:o,error:n,extensions:r,operation:t}};return function(e){e=r.share(e);var t=u?r.mergeMap(r.fromArray)(r.take(1)(r.buffer(r.fromPromise(u))(e))):r.empty;e=r.share(r.tap(m)(r.map(we)(r.concat([t,e]))));var o=r.share(r.map(g)(r.filter(Le)(e)));return t=r.map(Me)(r.filter(Be)(o)),o=r.map(n)(r.filter(Qe)(o)),e=r.map(k)(i(r.tap(v)(r.filter(Ie)(r.merge([r.filter(je)(e),t]))))),r.merge([e,o])}}},exports.clearDataState=Q,exports.initDataState=B,exports.query=ge,exports.read=ke,exports.write=ue,exports.writeFragment=fe,exports.writeOptimistic=le;
//# sourceMappingURL=urql-exchange-graphcache.cjs.min.js.map

@@ -9,3 +9,3 @@ {

"dependencies": {
"@urql/core": ">=1.9.2",
"@urql/core": ">=1.10.0",
"@urql/exchange-populate": ">=0.1.1",

@@ -12,0 +12,0 @@ "wonka": "^3.2.1 || ^4.0.0"

{
"name": "@urql/exchange-graphcache",
"version": "2.2.2",
"version": "2.2.3",
"description": "A normalized and configurable cache exchange for urql",
"sideEffects": false,
"homepage": "https://formidable.com/open-source/urql/docs/",
"homepage": "https://formidable.com/open-source/urql/docs/graphcache",
"bugs": "https://github.com/FormidableLabs/urql/issues",

@@ -61,3 +61,3 @@ "license": "MIT",

"wonka": "^3.2.1 || ^4.0.0",
"@urql/core": ">=1.9.2",
"@urql/core": ">=1.10.0",
"@urql/exchange-populate": ">=0.1.1"

@@ -71,3 +71,6 @@ },

"graphql-tag": "^2.10.1"
},
"publishConfig": {
"access": "public"
}
}

@@ -28,11 +28,6 @@ <h2 align="center">@urql/exchange-graphcache</h2>

desirable to have data update across the entirety of an app when a response updates some
known pieces of data. This cache also provides configurable APIs to:
known pieces of data.
- resolve Query data from the offline cache
- update Query data after mutations/subscriptions responses
- provide optimistic Mutation responses
[Learn more about Graphcache and normalized caching on our docs!](https://formidable.com/open-source/urql/docs/graphcache/)
> ⚠️ Note: Documentation for some parts of `@urql/exchange-graphcache` are still being worked on!
> For help or features requests, please join our [Spectrum](https://spectrum.chat/urql).
## Quick Start Guide

@@ -53,3 +48,2 @@

import { createClient, dedupExchange, fetchExchange } from 'urql';
import { cacheExchange } from '@urql/exchange-graphcache';

@@ -63,3 +57,3 @@

cacheExchange({
/* config */
/* optional config */
}),

@@ -81,82 +75,4 @@ fetchExchange,

This cache defaults to **delivering safe results** by marking results as incomplete
when any field is missing, triggering a `network-only` operation (a request), when
it encounters uncached fields.
Furthermore there's one case in caching where only having the `__typename` field
leads to potentially unsafe behaviour: **interfaces**. When the cache encounters a
fragment that tries to get data for an interface, it can't tell whether the
cached type matches the interface. In this case we resort to a heuristic
by default. When all fields of the fragment are on the target type, then the
fragment matches successfully and we log a warning.
Schema awareness has been introduced to the cache to improve this behaviour.
When you pass your API's GraphQL schema to the cache, it becomes able to
deliver **partial results**. When the cache has enough information so that
only **optional fields** in a given query are missing, then it delivers
a partial result from the cached data. Subsequently it still issues a network
request (like with `cache-and-network`) to ensure that all information will
still be delivered eventually.
With a schema the cache can also match fragments that refer to interfaces
**deterministically**, since it can look at the schema to match fragments
against types.
Schema awareness is also an important stepping stone for offline support.
Without partial results it becomes difficult to deliver an offline UI
safely, when just some bits of information are missing.
Read more about the [architecture](../../docs/graphcache/architecture.md)
## Usage
You can currently configure:
- `resolvers`: A nested `['__typename'][fieldName]` map to resolve results from cache
- `updates`: A Mutation/Subscription field map to apply side-effect updates to the cache
- `optimistic`: A mutation field map to supply optimistic mutation responses
- `keys`: A `__typename` map of functions to generate keys with
- `schema`: An introspected GraphQL schema in JSON format. When it's passed the cache will
deliver partial results and enable deterministic fragment matching.
> Note that you don't need any of these options to get started
### Keys
Keys are used when you need a slight alteration to the value of your identifier or
when the identifier is a non-traditional property.
[Read more](../../docs/graphcache/keys.md)
### Resolvers
Resolvers are needed when you want to do additional resolving, for example do some
custom date formatting.
[Read more](../../docs/graphcache/resolvers.md)
### Updates
The graph cache will automatically handle updates but some things are quite hard to
incorporate. Let's say you delete/add an item, it's hard for us to know you wanted to
delete or where to add an item in a list.
[Read more](../../docs/graphcache/updates.md)
### Optimistic
Here you can configure optimistic responses, this means that we don't wait for the server
to respond but offer the user to instantly replace the data with the variables from the
mutation.
[Read more](../../docs/graphcache/optimistic.md)
### Schema
Our way to see what your backend schema looks like, this offers additional functionality.
[Read more](../../docs/graphcache/schema.md)
## Maintenance Status
**Active:** Formidable is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc