Socket
Socket
Sign inDemoInstall

@urql/exchange-graphcache

Package Overview
Dependencies
Maintainers
33
Versions
296
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 3.1.4 to 3.1.5

6

CHANGELOG.md
# @urql/exchange-graphcache
## 3.1.5
### Patch Changes
- Changes some internals of how selections are iterated over and remove some private exports. This will have no effect or fixes on how Graphcache functions, but may improve some minor performance characteristics of large queries, by [@kitten](https://github.com/kitten) (See [#1060](https://github.com/FormidableLabs/urql/pull/1060))
## 3.1.4

@@ -4,0 +10,0 @@

4

dist/types/index.d.ts
export * from './types';
export { query, write, writeOptimistic } from './operations';
export { Store, noopDataState, reserveLayer } from './store';
export { query, write } from './operations';
export { Store } from './store';
export { cacheExchange } from './cacheExchange';
export { offlineExchange } from './offlineExchange';

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

import { FieldNode } from 'graphql';
import { SelectionSet } from '../ast';

@@ -17,5 +18,7 @@ import { Store } from '../store';

export declare const updateContext: (ctx: Context, typename: string, entityKey: string, fieldKey: string, fieldName: string) => void;
export declare const makeSelectionIterator: (typename: void | string, entityKey: string, select: SelectionSet, ctx: Context) => {
next(): import("graphql").FieldNode | undefined;
};
interface SelectionIterator {
(): FieldNode | undefined;
}
export declare const makeSelectionIterator: (typename: void | string, entityKey: string, select: SelectionSet, ctx: Context) => SelectionIterator;
export declare const ensureData: (x: DataField) => Data | NullArray<Data> | null;
export {};

@@ -14,7 +14,2 @@ "use strict";

function _ref(a, b) {
a[getName(b)] = b;
return a;
}
function expectObjectType(a, b) {

@@ -29,8 +24,8 @@ invariant(a instanceof definition.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 _ref2(a, b, c) {
var e, d;
var d, e;
if (0 < (currentData.refCount[a] || 0)) {
c.delete(a);
} else {
for (e in currentData.refLock) {
if (0 < ((b = currentData.refLock[e])[a] || 0)) {
for (d in currentData.refLock) {
if (0 < ((b = currentData.refLock[d])[a] || 0)) {
return;

@@ -43,6 +38,6 @@ }

currentData.records.base.delete(a);
if (e = currentData.links.base.get(a)) {
if (d = currentData.links.base.get(a)) {
currentData.links.base.delete(a);
for (d in e) {
updateRCForLink(c, currentData.refCount, e[d], -1);
for (e in d) {
updateRCForLink(c, currentData.refCount, d[e], -1);
}

@@ -100,15 +95,15 @@ }

}, getFieldArguments = function(a, b) {
var d, f, g, h, c = {}, e = 0;
var e, f, g, h, c = {}, d = 0;
if (a.arguments && a.arguments.length) {
for (d = 0, f = a.arguments.length; d < f; d++) {
null != (h = valueFromASTUntyped.valueFromASTUntyped((g = a.arguments[d]).value, b)) && (c[getName(g)] = h,
e++);
for (e = 0, f = a.arguments.length; e < f; e++) {
null != (h = valueFromASTUntyped.valueFromASTUntyped((g = a.arguments[e]).value, b)) && (c[getName(g)] = h,
d++);
}
}
return 0 < e ? c : null;
return 0 < d ? c : null;
}, filterVariables = function(a, b) {
var c, e, d, f;
var c, d, e, f;
if (b && a.variableDefinitions) {
for (c = {}, e = 0, d = a.variableDefinitions.length; e < d; e++) {
c[f = getName(a.variableDefinitions[e].variable)] = b[f];
for (c = {}, d = 0, e = a.variableDefinitions.length; d < e; d++) {
c[f = getName(a.variableDefinitions[d].variable)] = b[f];
}

@@ -118,3 +113,3 @@ return c;

}, normalizeVariables = function(a, b) {
var e, d, f, g, h, c = {};
var d, e, f, g, h, c = {};
if (!b) {

@@ -124,4 +119,4 @@ return c;

if (a.variableDefinitions) {
for (e = 0, d = a.variableDefinitions.length; e < d; e++) {
c[g = getName((f = a.variableDefinitions[e]).variable)] = void 0 === b[g] && f.defaultValue ? valueFromASTUntyped.valueFromASTUntyped(f.defaultValue, b) : b[g];
for (d = 0, e = a.variableDefinitions.length; d < e; d++) {
c[g = getName((f = a.variableDefinitions[d]).variable)] = void 0 === b[g] && f.defaultValue ? valueFromASTUntyped.valueFromASTUntyped(f.defaultValue, b) : b[g];
}

@@ -141,4 +136,2 @@ }

return currentDebugStack.length ? "\n(Caused At: " + currentDebugStack.join(", ") + ")" : "";
}, isFragmentNode = function(a) {
return a.kind === kinds.Kind.FRAGMENT_DEFINITION;
}, getMainOperation = function(a) {

@@ -152,10 +145,14 @@ for (var b = 0; b < a.definitions.length; b++) {

}, getFragments = function(a) {
return a.definitions.filter(isFragmentNode).reduce(_ref, {});
var b, c, d;
for (b = {}, c = 0; c < a.definitions.length; c++) {
(d = a.definitions[c]).kind === kinds.Kind.FRAGMENT_DEFINITION && (b[getName(d)] = d);
}
return b;
}, shouldInclude = function(a, b) {
var e, d, f, c = a.directives;
var d, e, f, c = a.directives;
if (!c) {
return !0;
}
for (e = 0, d = c.length; e < d; e++) {
if (("include" === (a = getName(f = c[e])) || "skip" === a) && f.arguments && f.arguments[0] && "if" === getName(f.arguments[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 = valueFromASTUntyped.valueFromASTUntyped(f.arguments[0].value, b), "include" === a ? !!b : !b;

@@ -185,11 +182,11 @@ }

}
var e = a.getType(b), d = a.getType(c);
if (e instanceof definition.GraphQLObjectType) {
return e === d;
var d = a.getType(b), e = a.getType(c);
if (d instanceof definition.GraphQLObjectType) {
return d === e;
}
!function expectAbstractType(a, b) {
invariant(a instanceof definition.GraphQLInterfaceType || a instanceof definition.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);
}(e, b);
expectObjectType(d, c);
return a.isPossibleType(e, d);
}(d, b);
expectObjectType(e, c);
return a.isPossibleType(d, e);
}, getField = function(a, b, c) {

@@ -235,9 +232,9 @@ expectObjectType(a = a.getType(b), b);

};
}, initDataState = function(a, b, c, e) {
}, initDataState = function(a, b, c, d) {
currentOperation = a;
currentData = b;
currentDependencies = makeDict();
currentIgnoreOptimistic = !!e;
currentIgnoreOptimistic = !!d;
"production" !== process.env.NODE_ENV && (currentDebugStack.length = 0);
c ? e || 0 < b.optimisticOrder.length ? (e || b.commutativeKeys.has(c) ? e && b.commutativeKeys.delete(c) : reserveLayer(b, c),
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;

@@ -286,25 +283,25 @@ }, clearDataState = function() {

};
}, setNode = function(a, b, c, e) {
var d = (a = currentOptimisticKey ? a.optimistic[currentOptimisticKey] : a.base).get(b);
void 0 === d && a.set(b, d = makeDict());
void 0 !== e || currentOptimisticKey ? d[c] = e : delete d[c];
}, 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 e, d, f, g, h;
for (d = 0, f = currentData.optimisticOrder.length; d < f; d++) {
if ((h = a.optimistic[g = currentData.optimisticOrder[d]]) && (!currentIgnoreOptimistic || currentData.commutativeKeys.has(g)) && void 0 !== (e = h.get(b)) && c in e) {
return e[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]]) && (!currentIgnoreOptimistic || currentData.commutativeKeys.has(g)) && void 0 !== (d = h.get(b)) && c in d) {
return d[c];
}
}
return void 0 !== (e = a.base.get(b)) ? e[c] : void 0;
}, updateRCForEntity = function(a, b, c, e) {
var d = void 0 !== b[c] ? b[c] : 0;
b = b[c] = d + e | 0;
void 0 !== a && (0 >= b ? a.add(c) : 0 >= d && 0 < b && a.delete(c));
}, updateRCForLink = function(a, b, c, e) {
var d, f, g;
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, e);
updateRCForEntity(a, b, c, d);
} else if (Array.isArray(c)) {
for (d = 0, f = c.length; d < f; d++) {
(g = c[d]) && updateRCForEntity(a, b, g, e);
for (e = 0, f = c.length; e < f; e++) {
(g = c[e]) && updateRCForEntity(a, b, g, d);
}

@@ -314,11 +311,11 @@ }

if (void 0 !== c) {
for (var e in c) {
b.has(e) || (a.push(fieldInfoOfKey(e)), b.add(e));
for (var d in c) {
b.has(d) || (a.push(fieldInfoOfKey(d)), b.add(d));
}
}
}, extractNodeMapFields = function(a, b, c, e) {
var d, f, g;
extractNodeFields(a, b, e.base.get(c));
for (d = 0, f = currentData.optimisticOrder.length; d < f; d++) {
void 0 !== (g = e.optimistic[currentData.optimisticOrder[d]]) && extractNodeFields(a, b, g.get(c));
}, 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));
}

@@ -344,10 +341,10 @@ }, gc = function() {

}, writeLink = function(a, b, c) {
var d, f, g, e = currentData;
var e, f, g, d = currentData;
if (currentOptimisticKey) {
d = e.refLock[currentOptimisticKey] || (e.refLock[currentOptimisticKey] = makeDict());
f = e.links.optimistic[currentOptimisticKey];
e = d.refLock[currentOptimisticKey] || (d.refLock[currentOptimisticKey] = makeDict());
f = d.links.optimistic[currentOptimisticKey];
} else {
d = e.refCount;
f = e.links.base;
g = e.gc;
e = d.refCount;
f = d.links.base;
g = d.gc;
}

@@ -357,5 +354,5 @@ f = (f = f && f.get(a)) && f[b];

updatePersist(a, b);
setNode(e.links, a, b, c);
updateRCForLink(g, d, f, -1);
updateRCForLink(g, d, c, 1);
setNode(d.links, a, b, c);
updateRCForLink(g, e, f, -1);
updateRCForLink(g, e, c, 1);
}, reserveLayer = function(a, b) {

@@ -383,7 +380,7 @@ var c = a.optimisticOrder.indexOf(b);

}, inspectFields = function(a) {
var b = currentData.links, c = currentData.records, e = [], d = new Set;
var b = currentData.links, c = currentData.records, d = [], e = new Set;
updateDependencies(a);
extractNodeMapFields(e, d, a, b);
extractNodeMapFields(e, d, a, c);
return e;
extractNodeMapFields(d, e, a, b);
extractNodeMapFields(d, e, a, c);
return d;
}, persistData = function() {

@@ -394,4 +391,4 @@ if (currentData.storage) {

currentData.persist.forEach((function a(a) {
var f, c = deserializeKeyInfo(a), d = c.entityKey;
void 0 !== (f = readLink(d, c = c.fieldKey)) ? b[a] = ":" + core.stringifyVariables(f) : void 0 !== (f = readRecord(d, c)) ? b[a] = core.stringifyVariables(f) : b[a] = void 0;
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;
}));

@@ -403,9 +400,9 @@ currentIgnoreOptimistic = !1;

}, hydrateData = function(a, b, c) {
var e, d, f, g;
var d, e, f, g;
initDataState("read", a, null);
for (e in c) {
if (void 0 !== (d = c[e])) {
g = (f = deserializeKeyInfo(e)).entityKey;
for (d in c) {
if (void 0 !== (e = c[d])) {
g = (f = deserializeKeyInfo(d)).entityKey;
f = f.fieldKey;
":" === d[0] ? writeLink(g, f, JSON.parse(d.slice(1))) : writeRecord(g, f, JSON.parse(d));
":" === e[0] ? writeLink(g, f, JSON.parse(e.slice(1))) : writeRecord(g, f, JSON.parse(e));
}

@@ -415,3 +412,3 @@ }

a.storage = b;
}, makeContext = function(a, b, c, e, d, f) {
}, makeContext = function(a, b, c, d, e, f) {
return {

@@ -421,4 +418,4 @@ store: a,

fragments: c,
parentTypeName: e,
parentKey: d,
parentTypeName: d,
parentKey: e,
parentFieldKey: "",

@@ -429,16 +426,16 @@ fieldName: "",

};
}, updateContext = function(a, b, c, e, d) {
}, updateContext = function(a, b, c, d, e) {
a.parentTypeName = b;
a.parentKey = c;
a.parentFieldKey = e;
a.fieldName = d;
}, isFragmentHeuristicallyMatching = function(a, b, c, e) {
a.parentFieldKey = d;
a.fieldName = e;
}, isFragmentHeuristicallyMatching = function(a, b, c, d) {
if (!b) {
return !1;
}
var d = getTypeCondition(a);
if (!d || b === d) {
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 `" + d + "`. Since GraphQL allows for interfaces `" + d + "` may be aninterface.\nA schema needs to be defined for this match to be deterministic, otherwise the fragment will be matched heuristically!", 16);
"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) {

@@ -448,22 +445,24 @@ if (!isFieldNode(a)) {

}
a = keyOfField(getName(a), getFieldArguments(a, e));
a = keyOfField(getName(a), getFieldArguments(a, d));
return !hasField(c, a);
}));
}, makeSelectionIterator = function(a, b, c, e) {
var d = [ 0 ], f = [ c ];
return {
next: function() {
for (;0 !== d.length; ) {
var c = d[d.length - 1]++, h = f[f.length - 1];
if (c >= h.length) {
d.pop(), f.pop(), "production" !== process.env.NODE_ENV && popDebugNode();
} else if (shouldInclude(c = h[c], e.variables)) {
if (isFieldNode(c)) {
if ("__typename" !== getName(c)) {
return c;
}
} else if (void 0 !== (c = isInlineFragment(c) ? c : e.fragments[getName(c)]) && ("production" !== process.env.NODE_ENV && pushDebugNode(a, c),
e.store.schema ? isInterfaceOfType(e.store.schema, c, a) : isFragmentHeuristicallyMatching(c, a, b, e.variables))) {
d.push(0), f.push(getSelectionSet(c));
}, 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;
}

@@ -475,4 +474,4 @@ }

return void 0 === a ? null : a;
}, write = function(a, b, c, e) {
initDataState("write", a.data, e || null);
}, write = function(a, b, c, d) {
initDataState("write", a.data, d || null);
a = startWrite(a, b, c);

@@ -482,31 +481,31 @@ clearDataState();

}, startWrite = function(a, b, c) {
var e = getMainOperation(b.query), d = {
var d = getMainOperation(b.query), e = {
data: c,
dependencies: getCurrentDependencies()
}, f = a.rootFields[e.operation];
a = makeContext(a, normalizeVariables(e, b.variables), getFragments(b.query), f, f);
"production" !== process.env.NODE_ENV && pushDebugNode(f, e);
writeSelection(a, f, getSelectionSet(e), c);
}, 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 d;
return e;
}, writeOptimistic = function(a, b, c) {
initDataState("write", a.data, c, !0);
c = getMainOperation(b.query);
var e = {
var d = {
data: {},
dependencies: getCurrentDependencies()
}, d = a.rootFields[c.operation];
invariant(d === 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(d, c);
a = makeContext(a, normalizeVariables(c, b.variables), getFragments(b.query), d, d, !0);
writeSelection(a, d, getSelectionSet(c), e.data);
}, 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 e;
}, writeFragment = function(a, b, c, e) {
var d, f, g;
if (void 0 === (d = (b = getFragments(b))[(d = Object.keys(b))[0]])) {
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(d);
f = getFragmentTypeName(e);
c = _rollupPluginBabelHelpers._extends({}, {

@@ -518,15 +517,15 @@ __typename: f

}
"production" !== process.env.NODE_ENV && pushDebugNode(f, d);
a = makeContext(a, e || {}, b, f, g);
writeSelection(a, g, getSelectionSet(d), c);
"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, e) {
var h, k, m, n, l, d = b === a.store.rootFields.query, f = !d && !!a.store.rootNames[b], g = f || d ? b : e.__typename;
}, writeSelection = function(a, b, c, d) {
var h, k, m, n, l, e = b === a.store.rootFields.query, f = !e && !!a.store.rootNames[b], g = f || e ? b : d.__typename;
if (g) {
f || d || !b || writeRecord(b, "__typename", g);
f || e || !b || writeRecord(b, "__typename", g);
c = makeSelectionIterator(g, b || g, c, a);
for (;h = c.next(); ) {
for (;h = c(); ) {
k = getName(h), m = getFieldArguments(h, a.variables);
d = keyOfField(k, m);
l = e[n = getFieldAlias(h)];
e = keyOfField(k, m);
l = d[n = getFieldAlias(h)];
if ("production" !== process.env.NODE_ENV) {

@@ -538,3 +537,3 @@ if (f || void 0 !== l) {

m = void 0 === h.selectionSet ? "scalar (number, boolean, etc)" : "selection set";
"production" !== process.env.NODE_ENV && warn("Invalid undefined: The field at `" + d + "` is `undefined`, but the GraphQL query expects a " + m + " for this field." + k, 13);
"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;

@@ -547,20 +546,20 @@ }

}
updateContext(a, g, g, d, k);
l = e[n] = ensureData(l(m || {}, a.store, a));
updateContext(a, g, g, e, k);
l = d[n] = ensureData(l(m || {}, a.store, a));
}
h.selectionSet ? b && !f ? (n = joinKeys(b, d), h = writeField(a, getSelectionSet(h), ensureData(l), n),
writeLink(b || g, d, h)) : writeField(a, getSelectionSet(h), ensureData(l)) : b && !f && writeRecord(b || g, d, l);
f && (updateContext(a, g, g, joinKeys(g, d), k), d = a.store.updates[g][k]) && (e[k] = l,
d(e, m || {}, a.store, a));
h.selectionSet ? b && !f ? (n = joinKeys(b, e), h = writeField(a, getSelectionSet(h), ensureData(l), n),
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, e) {
var d, f, g, h, k;
}, KEYLESS_TYPE_RE = /^__|PageInfo|(Connection|Edge)$/, writeField = function(a, b, c, d) {
var e, f, g, h, k;
if (Array.isArray(c)) {
for (d = Array(c.length), f = 0, g = c.length; f < g; f++) {
h = c[f], k = e ? joinKeys(e, "" + f) : void 0;
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);
d[f] = h;
e[f] = h;
}
return d;
return e;
}

@@ -570,9 +569,9 @@ if (null === c) {

}
d = a.store.keyOfEntity(c);
e = a.store.keyOfEntity(c);
f = c.__typename;
"production" !== process.env.NODE_ENV && e && void 0 === a.store.keys[c.__typename] && null === d && "string" == typeof f && !KEYLESS_TYPE_RE.test(f) && warn("Invalid key: The GraphQL query at the field at `" + e + "` 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, e = d || e, b, c);
return e || null;
"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 e, d;
var d, e;
b = b ? [ {

@@ -582,7 +581,7 @@ fieldKey: keyOfField(b, c)

c = 0;
for (e = b.length; c < e; c++) {
void 0 !== readLink(a, d = b[c].fieldKey) ? writeLink(a, d, void 0) : writeRecord(a, d, void 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, e, d, f, g, h, k;
var b, c, d, e, f, g, h, k;
this.keyOfField = keyOfField;

@@ -593,3 +592,3 @@ a || (a = {});

this.keys = a.keys || {};
e = "Query", d = "Mutation", f = "Subscription";
d = "Query", e = "Mutation", f = "Subscription";
if (a.schema) {

@@ -599,16 +598,16 @@ h = (g = this.schema = buildClientSchema.buildClientSchema(a.schema)).getQueryType(),

g = g.getSubscriptionType();
e = h ? h.name : e;
d = k ? k.name : d;
d = h ? h.name : d;
e = k ? k.name : e;
f = g ? g.name : f;
}
this.updates = ((b = {})[d] = a.updates && a.updates.Mutation || {}, b[f] = a.updates && a.updates.Subscription || {},
this.updates = ((b = {})[e] = a.updates && a.updates.Mutation || {}, b[f] = a.updates && a.updates.Subscription || {},
b);
this.rootFields = {
query: e,
mutation: d,
query: d,
mutation: e,
subscription: f
};
this.rootNames = ((c = {})[e] = "query", c[d] = "mutation", c[f] = "subscription",
this.rootNames = ((c = {})[d] = "query", c[e] = "mutation", c[f] = "subscription",
c);
this.data = make(e);
this.data = make(d);
this.schema && "production" !== process.env.NODE_ENV && (function expectValidKeyingConfig(a, b) {

@@ -622,9 +621,9 @@ if ("production" !== process.env.NODE_ENV) {

}(this.schema, this.keys), function expectValidUpdatesConfig(a, b) {
var c, e, d, f, g;
var c, d, e, f, g;
if ("production" !== process.env.NODE_ENV) {
c = a.getMutationType(), e = a.getSubscriptionType();
c = a.getMutationType(), d = a.getSubscriptionType();
a = c ? c.getFields() : {};
d = e ? e.getFields() : {};
e = d ? d.getFields() : {};
c = c && b[c.name] || {};
b = e && b[e.name] || {};
b = d && b[d.name] || {};
for (f in c) {

@@ -634,15 +633,15 @@ "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 === d[g] && warn("Invalid subscription field: `" + g + "` is not in the defined schema, but the `updates.Subscription` option is referencing it.", 22);
"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, e, d, f, g;
var c, d, e, f, g;
if ("production" !== process.env.NODE_ENV) {
c = a.getTypeMap();
for (e in b) {
if ("Query" === e) {
if (d = a.getQueryType()) {
d = d.getFields();
for (d in b) {
if ("Query" === d) {
if (e = a.getQueryType()) {
e = e.getFields();
for (f in b.Query) {
d[f] || warnAboutResolver("Query." + f);
e[f] || warnAboutResolver("Query." + f);
}

@@ -652,9 +651,9 @@ } else {

}
} else if (c[e]) {
d = a.getType(e).getFields();
for (g in b[e]) {
d[g] || warnAboutResolver(e + "." + g);
} else if (c[d]) {
e = a.getType(d).getFields();
for (g in b[d]) {
e[g] || warnAboutResolver(d + "." + g);
}
} else {
warnAboutResolver(e);
warnAboutResolver(d);
}

@@ -674,3 +673,3 @@ }

Store.prototype.keyOfEntity = function(a) {
var d, b = a.__typename, c = a.id, e = a._id;
var e, b = a.__typename, c = a.id, d = a._id;
if (!b) {

@@ -682,4 +681,4 @@ return null;

}
this.keys[b] ? d = this.keys[b](a) : null != c ? d = "" + c : null != e && (d = "" + e);
return d ? b + ":" + d : null;
this.keys[b] ? e = this.keys[b](a) : null != c ? e = "" + c : null != d && (e = "" + d);
return e ? b + ":" + e : null;
};

@@ -700,5 +699,5 @@

Store.prototype.invalidate = function(a, b, c) {
var e = "string" == typeof a ? a : this.keyOfEntity(a);
invariant(e, "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(e, 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);
};

@@ -733,7 +732,7 @@

}, read = function(a, b, c) {
var e = getMainOperation(b.query), d = a.rootFields[e.operation], f = getSelectionSet(e);
a = makeContext(a, normalizeVariables(e, b.variables), getFragments(b.query), d, d);
"production" !== process.env.NODE_ENV && pushDebugNode(d, e);
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 = d !== a.store.rootFields.query ? readRoot(a, d, f, c) : readSelection(a, d, f, c);
c = e !== a.store.rootFields.query ? readRoot(a, e, f, c) : readSelection(a, e, f, c);
"production" !== process.env.NODE_ENV && popDebugNode();

@@ -745,12 +744,12 @@ return {

};
}, readRoot = function(a, b, c, e) {
var d, f, g;
if ("string" != typeof e.__typename) {
return e;
}, 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 = e.__typename;
for (;void 0 !== (d = b.next()); ) {
g = e[f = getFieldAlias(d)];
void 0 !== d.selectionSet && null !== g ? (g = ensureData(g), c[f] = readRootField(a, getSelectionSet(d), g)) : c[f] = g;
(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;
}

@@ -760,6 +759,6 @@ return c;

if (Array.isArray(c)) {
for (var e = Array(c.length), d = 0, f = c.length; d < f; d++) {
e[d] = readRootField(a, b, c[d]);
for (var d = Array(c.length), e = 0, f = c.length; e < f; e++) {
d[e] = readRootField(a, b, c[e]);
}
return e;
return d;
}

@@ -769,10 +768,10 @@ if (null === c) {

}
return null !== (e = a.store.keyOfEntity(c)) ? void 0 === (a = readSelection(a, e, b, {})) ? null : a : readRoot(a, c.__typename, b, c);
}, readFragment = function(a, b, c, e) {
var d, f;
if (void 0 === (d = (b = getFragments(b))[(d = Object.keys(b))[0]])) {
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(d);
f = getFragmentTypeName(e);
"string" == typeof c || c.__typename || (c.__typename = f);

@@ -785,19 +784,19 @@ if (!(c = "string" != typeof c ? a.keyOfEntity(_rollupPluginBabelHelpers._extends({}, {

}
"production" !== process.env.NODE_ENV && pushDebugNode(f, d);
a = makeContext(a, e || {}, b, f, c);
a = readSelection(a, c, getSelectionSet(d), {}) || 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, e, d) {
var k, m, n, l, r, p, v, t, u, w, x, q, f = a.store, g = b === f.rootFields.query, h = d && f.keyOfEntity(d) || b;
}, readSelection = function(a, b, c, d, e) {
var k, m, n, l, r, p, v, t, u, w, x, 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") || d && d.__typename)) {
if (d && b !== d.__typename) {
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 {
e.__typename = b;
d.__typename = b;
c = makeSelectionIterator(b, h, c, a);
for (m = !1, n = !1; void 0 !== (k = c.next()); ) {
for (m = !1, n = !1; void 0 !== (k = c()); ) {
l = getName(k), r = getFieldArguments(k, a.variables), p = getFieldAlias(k), v = keyOfField(l, r),
t = joinKeys(h, v), u = readRecord(h, v), w = d ? d[l] : void 0, x = f.resolvers[b];
t = joinKeys(h, v), u = readRecord(h, v), w = e ? e[l] : void 0, x = f.resolvers[b];
"production" !== process.env.NODE_ENV && f.schema && b && isFieldAvailableOnType(f.schema, b, l);

@@ -808,4 +807,4 @@ q = void 0;

} else if ("read" === getCurrentOperation() && x && "function" == typeof x[l]) {
if (updateContext(a, b, h, t, l), void 0 !== u && (e[p] = u), q = x[l](e, r || {}, f, a),
void 0 !== k.selectionSet && (q = resolveResolverResult(a, b, l, t, getSelectionSet(k), e[p] || {}, q)),
if (updateContext(a, b, h, t, l), void 0 !== u && (d[p] = u), q = x[l](d, r || {}, 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)) {

@@ -815,6 +814,6 @@ return;

} else {
void 0 === k.selectionSet ? q = u : void 0 !== w ? q = resolveResolverResult(a, b, l, t, getSelectionSet(k), e[p], w) : void 0 !== (r = readLink(h, v)) ? q = resolveLink(a, r, b, l, getSelectionSet(k), e[p]) : "object" == typeof u && null !== u && (q = u);
void 0 === k.selectionSet ? q = u : void 0 !== w ? q = resolveResolverResult(a, b, l, t, getSelectionSet(k), d[p], w) : void 0 !== (r = readLink(h, v)) ? q = resolveLink(a, r, b, l, getSelectionSet(k), d[p]) : "object" == typeof u && null !== u && (q = u);
}
if (void 0 === q && f.schema && isFieldNullable(f.schema, b, l)) {
n = !0, e[p] = null;
n = !0, d[p] = null;
} else {

@@ -825,10 +824,10 @@ if (void 0 === q) {

m = !0;
e[p] = q;
d[p] = q;
}
}
n && (a.partial = !0);
return g && n && !m ? void 0 : e;
return g && n && !m ? void 0 : d;
}
}
}, resolveResolverResult = function(a, b, c, e, d, f, g) {
}, resolveResolverResult = function(a, b, c, d, e, f, g) {
var h, k, m, n, l;

@@ -838,3 +837,3 @@ if (Array.isArray(g)) {

for (k = Array(g.length), m = 0, n = g.length; m < n; m++) {
if (void 0 !== (l = resolveResolverResult(a, b, c, joinKeys(e, "" + m), d, null != f ? f[m] : void 0, g[m])) || h) {
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;

@@ -854,11 +853,11 @@ } else {

if (isDataOrKey(g)) {
return b = f || {}, "string" == typeof g ? readSelection(a, g, d, b) : readSelection(a, e, d, b, 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 `" + e + "` is a scalar (number, boolean, etc), but the GraphQL query expects a selection set for this field.", 9);
}, resolveLink = function(a, b, c, e, d, f) {
"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, n;
if (Array.isArray(b)) {
g = (g = a.store).schema && isListNullable(g.schema, c, e);
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 !== (n = resolveLink(a, b[k], c, e, d, null != f ? f[k] : void 0)) || g) {
if (void 0 !== (n = resolveLink(a, b[k], c, d, e, null != f ? f[k] : void 0)) || g) {
h[k] = void 0 !== n ? n : null;

@@ -871,3 +870,3 @@ } else {

}
return null === b || null === f ? null : readSelection(a, b, d, f || {});
return null === b || null === f ? null : readSelection(a, b, e, f || {});
}, isDataOrKey = function(a) {

@@ -893,3 +892,3 @@ return "string" == typeof a || "object" == typeof a && "string" == typeof a.__typename;

return function(b) {
function e(a) {
function d(a) {
"production" !== process.env.NODE_ENV && r({

@@ -903,3 +902,3 @@ type: "cacheMiss",

}
function d(a) {
function e(a) {
return "miss" === a.outcome && "cache-only" !== a.operation.context.requestPolicy && !B(a.dependencies);

@@ -1060,3 +1059,3 @@ }

b = wonka.filter(_ref5)(b);
c = wonka.map(e)(wonka.filter(d)(a));
c = wonka.map(d)(wonka.filter(e)(a));
a = wonka.map(f)(wonka.filter(_ref9)(a));

@@ -1070,9 +1069,9 @@ c = wonka.share(n(wonka.map(E)(wonka.merge([ b, c ]))));

}, isOptimisticMutation = function(a, b) {
var d, c = b.variables || makeDict(), e = getFragments(b.query);
var e, c = b.variables || makeDict(), d = getFragments(b.query);
b = [].concat(getSelectionSet(getMainOperation(b.query)));
for (;d = b.pop(); ) {
if (shouldInclude(d, c)) {
if (!isFieldNode(d)) {
(d = isInlineFragment(d) ? d : e[getName(d)]) && b.push.apply(b, getSelectionSet(d));
} else if (a[getName(d)]) {
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;

@@ -1087,3 +1086,3 @@ }

return function(b) {
function d(a) {
function e(a) {
return "mutation" === a.operation.operationName && isOfflineError(a.error) && isOptimisticMutation(l, a.operation) ? (r.push(a.operation),

@@ -1106,3 +1105,3 @@ p(), !1) : !0;

}, v = !1;
k.onOnline(t = function e() {
k.onOnline(t = function d() {
if (!v) {

@@ -1129,3 +1128,3 @@ v = !0;

forward: function f(a) {
return wonka.filter(d)(m(a));
return wonka.filter(e)(m(a));
}

@@ -1151,4 +1150,2 @@ });

exports.noopDataState = noopDataState;
exports.offlineExchange = offlineExchange;

@@ -1158,7 +1155,3 @@

exports.reserveLayer = reserveLayer;
exports.write = write;
exports.writeOptimistic = writeOptimistic;
//# sourceMappingURL=urql-exchange-graphcache.js.map

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

"use strict";var e=require("./1cc90026.min.js"),t=require("graphql/utilities/valueFromASTUntyped"),r=require("graphql/language/kinds"),n=require("graphql/type/definition"),i=require("@urql/core"),o=require("graphql/utilities/buildClientSchema"),a=require("wonka"),u=require("graphql/language/printer"),s=function(e){return e.name.value},f=function(e){return e.typeCondition.name.value},c=function(e){return e.alias?e.alias.value:s(e)},l=function(e){return e.selectionSet?e.selectionSet.selections:[]},d=function(e){return e.typeCondition?s(e.typeCondition):null},p=function(e){return e.kind===r.Kind.FIELD},v=function(e){return e.kind===r.Kind.INLINE_FRAGMENT},y=function(e,r){var n={},i=0;if(e.arguments&&e.arguments.length)for(var o=0,a=e.arguments.length;o<a;o++){var u=e.arguments[o],f=t.valueFromASTUntyped(u.value,r);null!=f&&(n[s(u)]=f,i++)}return 0<i?n:null},m=function(e,t){if(t&&e.variableDefinitions){for(var r={},n=0,i=e.variableDefinitions.length;n<i;n++){var o=s(e.variableDefinitions[n].variable);r[o]=t[o]}return r}},h=function(e,r){var n={};if(!r)return n;if(e.variableDefinitions)for(var i=0,o=e.variableDefinitions.length;i<o;i++){var a=e.variableDefinitions[i],u=s(a.variable);n[u]=void 0===r[u]&&a.defaultValue?t.valueFromASTUntyped(a.defaultValue,r):r[u]}for(var f in r)f in n||(n[f]=r[f]);return n};function g(e,t,r){if(!e)throw(e=Error((t||"Minfied Error #"+r+"\n")+"\nhttps://bit.ly/2XbVrpR#"+r)).name="Graphcache Error",e}var k=function(e){return e.kind===r.Kind.FRAGMENT_DEFINITION},b=function(e){for(var t=0;t<e.definitions.length;t++)if(e.definitions[t].kind===r.Kind.OPERATION_DEFINITION)return e.definitions[t];g(!1,"",1)};function q(e,t){return e[s(t)]=t,e}var O=function(e){return e.definitions.filter(k).reduce(q,{})},_=function(e,r){var n=e.directives;if(!n)return!0;for(var i=0,o=n.length;i<o;i++){var a=n[i];if(("include"===(e=s(a))||"skip"===e)&&a.arguments&&a.arguments[0]&&"if"===s(a.arguments[0]))return r=t.valueFromASTUntyped(a.arguments[0].value,r),"include"===e?!!r:!r}return!0},x=/^__/,w=function(e,t,r){return!!x.test(r)||!!(e=S(e,t,r))&&n.isNullableType(e.type)},N=function(e,t,r){return!!(e=S(e,t,r))&&(e=n.isNonNullType(e.type)?e.type.ofType:e.type,n.isListType(e)&&n.isNullableType(e.ofType))},K=function(e,t,r){return!!r&&(!(t=d(t))||r===t||(t=e.getType(t),r=e.getType(r),t instanceof n.GraphQLObjectType?t===r:(function(e,t){g(e instanceof n.GraphQLInterfaceType||e instanceof n.GraphQLUnionType,"",5)}(t),E(r),e.isPossibleType(t,r))))},S=function(e,t,r){return E(e=e.getType(t)),e.getFields()[r]};function E(e,t){g(e instanceof n.GraphQLObjectType,"",3)}var T=function(e,t){return t?e+"("+i.stringifyVariables(t)+")":e},F=function(e,t){return e+"."+t},A=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}},L=function(e){var t=e.indexOf(".");return{entityKey:e.slice(0,t).replace(/%2e/g,"."),fieldKey:e=e.slice(t+1)}},M=function(){return Object.create(null)},D=null,P=null,I=null,C=null,R=!1,j=function(){return{optimistic:M(),base:new Map}},Q=function(e,t,r,n){D=e,P=t,I=M(),R=!!n,r?n||0<t.optimisticOrder.length?(n||t.commutativeKeys.has(r)?n&&t.commutativeKeys.delete(r):oe(t,r),C=r,ae(t,r)):(C=null,se(t,r)):C=null},G=function(){var e=P,t=C;if(R=!1,C=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]);)le(e.optimisticOrder[t]);I=P=D=null,e.defer||(e.defer=!0,Promise.resolve().then((function(){Q("write",e,null),Z(),pe(),G(),e.defer=!1})))},V=function(e,t,r){Q("read",e,t,r),G()},U=function(){return g(null!==I,"",2),I},J=function(e,t,r,n){var i=(e=C?e.optimistic[C]:e.base).get(t);void 0===i&&e.set(t,i=M()),void 0!==n||C?i[r]=n:delete i[r]},B=function(e,t,r){for(var n,i=0,o=P.optimisticOrder.length;i<o;i++){var a=P.optimisticOrder[i],u=e.optimistic[a];if(u&&(!R||P.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},z=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))},X=function(e,t,r,n){if("string"==typeof r)z(e,t,r,n);else if(Array.isArray(r))for(var i=0,o=r.length;i<o;i++){var a=r[i];a&&z(e,t,a,n)}},H=function(e,t,r){if(void 0!==r)for(var n in r)t.has(n)||(e.push(A(n)),t.add(n))},W=function(e,t,r,n){H(e,t,n.base.get(r));for(var i=0,o=P.optimisticOrder.length;i<o;i++){var a=n.optimistic[P.optimisticOrder[i]];void 0!==a&&H(e,t,a.get(r))}};function Y(e,t,r){if(0<(P.refCount[e]||0))r.delete(e);else{for(var n in P.refLock){if(0<((t=P.refLock[n])[e]||0))return;delete t[e]}if(delete P.refCount[e],r.delete(e),P.records.base.delete(e),n=P.links.base.get(e))for(var i in P.links.base.delete(e),n)X(r,P.refCount,n[i],-1)}}var Z=function(){P.gc.forEach(Y)},$=function(e,t){"__typename"!==t&&(e!==P.queryRootKey?I[e]=!0:void 0!==t&&(I[F(e,t)]=!0))},ee=function(e,t){!R&&P.storage&&P.persist.add(function(e,t){return e.replace(/\./g,"%2e")+"."+t}(e,t))},te=function(e,t){return $(e,t),B(P.records,e,t)},re=function(e,t){return $(e,t),B(P.links,e,t)},ne=function(e,t,r){$(e,t),ee(e,t),J(P.records,e,t,r)},ie=function(e,t,r){var n=P;if(C)var i=n.refLock[C]||(n.refLock[C]=M()),o=n.links.optimistic[C];else{i=n.refCount,o=n.links.base;var a=n.gc}o=(o=o&&o.get(e))&&o[t],$(e,t),ee(e,t),J(n.links,e,t,r),X(a,i,o,-1),X(a,i,r,1)},oe=function(e,t){var r=e.optimisticOrder.indexOf(t);-1===r?e.optimisticOrder.unshift(t):e.commutativeKeys.has(t)||(ue(e,t),e.optimisticOrder.splice(r,1),e.optimisticOrder.unshift(t)),e.commutativeKeys.add(t)},ae=function(e,t){-1===e.optimisticOrder.indexOf(t)&&e.optimisticOrder.unshift(t),e.refLock[t]||(e.refLock[t]=M(),e.links.optimistic[t]=new Map,e.records.optimistic[t]=new Map)},ue=function(e,t){e.refLock[t]&&(delete e.refLock[t],delete e.records.optimistic[t],delete e.links.optimistic[t])},se=function(e,t){var r=e.optimisticOrder.indexOf(t);-1<r&&(e.optimisticOrder.splice(r,1),e.commutativeKeys.delete(t)),ue(e,t)};function fe(e,t){for(var r in e)ie(t,r,e[r])}function ce(e,t){for(var r in e)ne(t,r,e[r])}var le=function(e){var t=I;I=M();var r=P.links.optimistic[e];r&&r.forEach(fe),(r=P.records.optimistic[e])&&r.forEach(ce),I=t,se(P,e)},de=function(e){var t=P.links,r=P.records,n=[],i=new Set;return $(e),W(n,i,e,t),W(n,i,e,r),n},pe=function(){if(P.storage){R=!0;var e=M();P.persist.forEach((function(t){var r,n=L(t),o=n.entityKey;e[t]=void 0!==(r=re(o,n=n.fieldKey))?":"+i.stringifyVariables(r):void 0!==(r=te(o,n))?i.stringifyVariables(r):void 0})),R=!1,P.storage.writeData(e),P.persist.clear()}},ve=function(e,t,r,n,i,o){return{store:e,variables:t,fragments:r,parentTypeName:n,parentKey:i,parentFieldKey:"",fieldName:"",partial:!1,optimistic:!!o}},ye=function(e,t,r,n,i){e.parentTypeName=t,e.parentKey=r,e.parentFieldKey=n,e.fieldName=i},me=function(e,t,r,n){if(!t)return!1;var i=d(e);return!i||t===i||!l(e).some((function(e){return!!p(e)&&(e=T(s(e),y(e,n)),!function(e,t){return void 0!==te(e,t)||void 0!==re(e,t)}(r,e))}))},he=function(e,t,r,n){var i=[0],o=[r];return{next:function(){for(;0!==i.length;){var r=i[i.length-1]++,a=o[o.length-1];if(r>=a.length)i.pop(),o.pop();else if(_(r=a[r],n.variables))if(p(r)){if("__typename"!==s(r))return r}else void 0!==(r=v(r)?r:n.fragments[s(r)])&&(n.store.schema?K(n.store.schema,r,e):me(r,e,t,n.variables))&&(i.push(0),o.push(l(r)))}}}},ge=function(e){return void 0===e?null:e},ke=function(e,t,r,n){return Q("write",e.data,n||null),e=be(e,t,r),G(),e},be=function(e,t,r){var n=b(t.query),i={data:r,dependencies:U()},o=e.rootFields[n.operation];return e=ve(e,h(n,t.variables),O(t.query),o,o),Oe(e,o,l(n),r),i},qe=function(e,t,r){Q("write",e.data,r,!0),r=b(t.query);var n={data:{},dependencies:U()},i=e.rootFields[r.operation];return g(i===e.rootFields.mutation,"",10),e=ve(e,h(r,t.variables),O(t.query),i,i,!0),Oe(e,i,l(r),n.data),G(),n},Oe=function(e,t,r,n){var i=t===e.store.rootFields.query,o=!i&&!!e.store.rootNames[t],a=o||i?t:n.__typename;if(a){o||i||!t||ne(t,"__typename",a),r=he(a,t||a,r,e);for(var u;u=r.next();){i=s(u);var f=y(u,e.variables),d=T(i,f),p=c(u),v=n[p];if(e.optimistic&&o){if(!(v=e.store.optimisticMutations[i]))continue;ye(e,a,a,d,i),v=n[p]=ge(v(f||{},e.store,e))}u.selectionSet?t&&!o?(p=F(t,d),u=_e(e,l(u),ge(v),p),ie(t||a,d,u)):_e(e,l(u),ge(v)):t&&!o&&ne(t||a,d,v),o&&(ye(e,a,a,F(a,d),i),d=e.store.updates[a][i])&&(n[i]=v,d(n,f||{},e.store,e))}}},_e=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?F(n,""+o):void 0;u=_e(e,t,u,s),i[o]=u}return i}return null===r?null:(n=e.store.keyOfEntity(r)||n,Oe(e,n,t,r),n||null)},xe=function(e){var t,r;this.keyOfField=T,e||(e={}),this.resolvers=e.resolvers||{},this.optimisticMutations=e.optimistic||{},this.keys=e.keys||{};var n="Query",i="Mutation",a="Subscription";if(e.schema){var u=this.schema=o.buildClientSchema(e.schema),s=u.getQueryType(),f=u.getMutationType();u=u.getSubscriptionType(),n=s?s.name:n,i=f?f.name:i,a=u?u.name:a}this.updates=((t={})[i]=e.updates&&e.updates.Mutation||{},t[a]=e.updates&&e.updates.Subscription||{},t),this.rootFields={query:n,mutation:i,subscription:a},this.rootNames=((r={})[n]="query",r[i]="mutation",r[a]="subscription",r),this.data=function(e){return{defer:!1,gc:new Set,persist:new Set,queryRootKey:e,refCount:M(),refLock:M(),links:j(),records:j(),commutativeKeys:new Set,optimisticOrder:[],storage:null}}(n)};xe.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},xe.prototype.resolveFieldByKey=function(e,t){if(null===(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e))return null;var r=te(e,t);return void 0!==r?r:(t=re(e,t))?t:null},xe.prototype.resolve=function(e,t,r){return this.resolveFieldByKey(e,T(t,r))},xe.prototype.invalidate=function(e,t,r){g(e="string"==typeof e?e:this.keyOfEntity(e),"",19),function(e,t,r){t=t?[{fieldKey:T(t,r)}]:de(e),r=0;for(var n=t.length;r<n;r++){var i=t[r].fieldKey;void 0!==re(e,i)?ie(e,i,void 0):ne(e,i,void 0)}}(e,t,r)},xe.prototype.inspectFields=function(e){return null!==(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e)?de(e):[]},xe.prototype.updateQuery=function(e,t){e=i.createRequest(e.query,e.variables),null!==(t=t(this.readQuery(e)))&&be(this,e,t)},xe.prototype.readQuery=function(e){return Ne(this,i.createRequest(e.query,e.variables)).data},xe.prototype.readFragment=function(e,t,r){return Ee(this,e,t,r)},xe.prototype.writeFragment=function(t,r,n){!function(t,r,n,i){r=O(r);var o=Object.keys(r);if(void 0!==(o=r[o[0]])){var a=f(o);n=e._extends({},{__typename:a},n);var u=t.keyOfEntity(n);u&&(t=ve(t,i||{},r,a,u),Oe(t,u,l(o),n))}}(this,t,r,n)};var we=function(e,t,r){return Q("read",e.data,null),e=Ne(e,t,r),G(),e},Ne=function(e,t,r){var n=b(t.query),i=e.rootFields[n.operation],o=l(n);return r=r||{},r=i!==(e=ve(e,h(n,t.variables),O(t.query),i,i)).store.rootFields.query?Ke(e,i,o,r):Te(e,i,o,r),{dependencies:U(),partial:void 0!==r&&e.partial,data:void 0===r?null:r}},Ke=function(e,t,r,n){if("string"!=typeof n.__typename)return n;t=he(t,t,r,e),(r={}).__typename=n.__typename;for(var i;void 0!==(i=t.next());){var o=c(i),a=n[o];void 0!==i.selectionSet&&null!==a?(a=ge(a),r[o]=Se(e,l(i),a)):r[o]=a}return r},Se=function(e,t,r){if(Array.isArray(r)){for(var n=Array(r.length),i=0,o=r.length;i<o;i++)n[i]=Se(e,t,r[i]);return n}return null===r?null:null!==(n=e.store.keyOfEntity(r))?void 0===(e=Te(e,n,t,{}))?null:e:Ke(e,r.__typename,t,r)},Ee=function(t,r,n,i){r=O(r);var o=Object.keys(r);if(void 0===(o=r[o[0]]))return null;var a=f(o);return"string"==typeof n||n.__typename||(n.__typename=a),(n="string"!=typeof n?t.keyOfEntity(e._extends({},{__typename:a},n)):n)?(t=ve(t,i||{},r,a,n),Te(t,n,l(o),{})||null):null},Te=function(e,t,r,n,i){var o=e.store,a=t===o.rootFields.query,u=i&&o.keyOfEntity(i)||t;if("string"==typeof(t=a?t:te(u,"__typename")||i&&i.__typename)&&(!i||t===i.__typename)){n.__typename=t,r=he(t,u,r,e);for(var f,d=!1,p=!1;void 0!==(f=r.next());){var v=s(f),m=y(f,e.variables),h=c(f),k=T(v,m),b=F(u,k),q=te(u,k),O=i?i[v]:void 0,_=o.resolvers[t],x=void 0;if(void 0!==O&&void 0===f.selectionSet)x=O;else if("read"===(g(null!==D,"",2),D)&&_&&"function"==typeof _[v]){if(ye(e,t,u,b,v),void 0!==q&&(n[h]=q),x=_[v](n,m||{},o,e),void 0!==f.selectionSet&&(x=Fe(e,t,v,b,l(f),n[h]||{},x)),o.schema&&null===x&&!w(o.schema,t,v))return}else void 0===f.selectionSet?x=q:void 0!==O?x=Fe(e,t,v,b,l(f),n[h],O):void 0!==(m=re(u,k))?x=Ae(e,m,t,v,l(f),n[h]):"object"==typeof q&&null!==q&&(x=q);if(void 0===x&&o.schema&&w(o.schema,t,v))p=!0,n[h]=null;else{if(void 0===x)return;d=!0,n[h]=x}}return p&&(e.partial=!0),a&&p&&!d?void 0:n}},Fe=function(e,t,r,n,i,o,a){if(Array.isArray(a)){var u=e.store;u=!u.schema||N(u.schema,t,r);for(var s=Array(a.length),f=0,c=a.length;f<c;f++){var l=Fe(e,t,r,F(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:Le(a)?(t=o||{},"string"==typeof a?Te(e,a,i,t):Te(e,n,i,t,a)):void 0},Ae=function(e,t,r,n,i,o){if(Array.isArray(t)){var a=e.store;a=a.schema&&N(a.schema,r,n);for(var u=Array(t.length),s=0,f=t.length;s<f;s++){var c=Ae(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:Te(e,t,i,o||{})},Le=function(e){return"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename},Me=function(t,r){return e._extends({},t,{context:e._extends({},t.context,{meta:e._extends({},t.context.meta,{cacheOutcome:r})})})},De=function(t,r){return e._extends({},t,{context:e._extends({},t.context,{requestPolicy:r})})};function Pe(e){return a.fromArray(e[0])}function Ie(e,t){return e.push(t),e}function Ce(e){return"query"===e.operationName&&"network-only"!==e.context.requestPolicy}function Re(e){return"query"!==e.operationName||"network-only"===e.context.requestPolicy}function je(e){return"miss"!==e.outcome||"cache-only"===e.operation.context.requestPolicy}var Qe=function(t){return function(r){function n(e){return Me(e.operation,"miss")}function o(e){return"miss"===e.outcome&&"cache-only"!==e.operation.context.requestPolicy&&!x(e.dependencies)}function u(e){var t=e.operation,r=e.outcome,n=e.dependencies;return e={operation:Me(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,x(n)?"cache-and-network"===t.context.requestPolicy&&O.add(t.key):v.reexecuteOperation(De(t,"network-only"))),e}function s(e){var t=new Set,r=T(e,t);return N(e.operation,t),r}function f(e){return!h.has(e.operation.key)}function c(e){if(g.push(e)<h.size)return a.empty;for(var t=0;t<g.length;t++)oe(y.data,g[t].operation.key);for(var r in q)delete q[r];t=[],r=new Set;for(var n;n=g.shift();)t.push(T(n,r));return N(e.operation,r),a.fromArray(t)}function l(e){return h.has(e.operation.key)}var d,p=r.forward,v=r.client,y=new xe(t);t&&t.storage&&(d=t.storage.readData().then((function(e){!function(e,t,r){for(var n in Q("read",e,null),r){var i=r[n];if(void 0!==i){var o=L(n),a=o.entityKey;o=o.fieldKey,":"===i[0]?ie(a,o,JSON.parse(i.slice(1))):ne(a,o,JSON.parse(i))}}G(),e.storage=t}(y.data,t.storage,e)})));var h=new Map,g=[],k=new Map,q=M(),O=new Set,_=M(),x=function(e){for(var t in e)if(q[t])return!0;return!1},w=function(e,t){if(t)for(var r in t)if(t=_[r]){_[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=k.get(t);if(r){k.delete(t);var n="cache-first";O.has(t)&&(O.delete(t),n="cache-and-network"),v.reexecuteOperation(De(r,n))}}}))},K=function(t){if("query"===t.operationName)oe(y.data,t.key);else if("teardown"===t.operationName)k.delete(t.key),V(y.data,t.key);else if("mutation"===t.operationName&&"network-only"!==t.context.requestPolicy){var r=qe(y,t,t.key).dependencies;if(!function(e){for(var t in e)return!1;return!0}(r)){for(var n in r)q[n]=!0;h.set(t.key,r),n=new Set,w(n,r),N(t,n)}}return e._extends({},t,{variables:t.variables?m(b(t.query),t.variables):t.variables,query:i.formatDocument(t.query)})},S=function(e,t){for(var r in t)(_[r]||(_[r]=[])).push(e.key),k.set(e.key,e)},E=function(e){var t=we(y,e),r=t.data?t.partial?"partial":"hit":"miss";return S(e,t.dependencies),{outcome:r,operation:e,data:t.data,dependencies:t.dependencies}},T=function(e,t){var r=e.operation,n=e.error,i=e.extensions,o=r.key;if("mutation"===r.operationName){var a=h.get(o);w(t,a),h.delete(o)}else oe(y.data,r.key);if(e.data){if(o=ke(y,r,e.data,o).dependencies,w(t,o),o=we(y,r,e.data),e.data=o.data,"query"===r.operationName){var u=o.dependencies;w(t,u)}}else V(y.data,r.key);return u&&S(e.operation,u),{data:e.data,error:n,extensions:i,operation:r}};return function(e){e=a.share(e);var t=d?a.mergeMap(Pe)(a.take(1)(a.combine(a.scan(Ie,[])(e),a.fromPromise(d)))):a.empty;t=a.share(a.concat([t,e])),e=a.share(a.map(E)(a.filter(Ce)(t))),t=a.filter(Re)(t);var r=a.map(n)(a.filter(o)(e));return e=a.map(u)(a.filter(je)(e)),r=a.share(p(a.map(K)(a.merge([t,r])))),t=a.map(s)(a.filter(f)(r)),r=a.mergeMap(c)(a.filter(l)(r)),a.merge([t,r,e])}}},Ge=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=xe,exports.cacheExchange=Qe,exports.noopDataState=V,exports.offlineExchange=function(e){return function(t){function r(e){return"mutation"!==e.operation.operationName||!Ge(e.error)||!function(e,t){var r,n=t.variables||M(),i=O(t.query);for(t=[].concat(l(b(t.query)));r=t.pop();)if(_(r,n))if(p(r)){if(e[s(r)])return!0}else(r=v(r)?r:i[s(r)])&&t.push.apply(t,l(r));return!1}(c,e.operation)||(d.push(e.operation),y(),!1)}var n=e.storage;if(n&&n.onOnline&&n.readMetadata&&n.writeMetadata){var o=t.forward,f=t.client;t=t.dispatchDebug;var c=e.optimistic||{},d=[],y=function(){for(var e=[],t=0;t<d.length;t++){var r=d[t];"mutation"===r.operationName&&e.push({query:u.print(r.query),variables:r.variables})}n.writeMetadata(e)},m=!1,h=function(){if(!m){m=!0;for(var e;e=d.shift();)f.reexecuteOperation(e);y(),m=!1}};n.onOnline(h),n.readMetadata().then((function(e){if(e){for(var t=0;t<e.length;t++)d.push(f.createRequestOperation("mutation",i.createRequest(e[t].query,e[t].variables)));h()}}));var g=Qe(e)({client:f,dispatchDebug:t,forward:function(e){return a.filter(r)(o(e))}});return function(e){e=a.share(e);var t=a.makeSubject(),r=t.next;return e=a.merge([t.source,e]),a.filter((function(e){return"query"!==e.operation.operationName||!Ge(e.error)||(r(De(e.operation,"cache-only")),d.push(e.operation),!1)}))(g(e))}}return Qe(e)(t)}},exports.query=we,exports.reserveLayer=oe,exports.write=ke,exports.writeOptimistic=qe;
"use strict";var e=require("./1cc90026.min.js"),t=require("graphql/utilities/valueFromASTUntyped"),r=require("graphql/language/kinds"),n=require("graphql/type/definition"),i=require("@urql/core"),o=require("graphql/utilities/buildClientSchema"),a=require("wonka"),u=require("graphql/language/printer"),s=function(e){return e.name.value},f=function(e){return e.typeCondition.name.value},c=function(e){return e.alias?e.alias.value:s(e)},l=function(e){return e.selectionSet?e.selectionSet.selections:[]},d=function(e){return e.typeCondition?s(e.typeCondition):null},p=function(e){return e.kind===r.Kind.FIELD},v=function(e){return e.kind===r.Kind.INLINE_FRAGMENT},y=function(e,r){var n={},i=0;if(e.arguments&&e.arguments.length)for(var o=0,a=e.arguments.length;o<a;o++){var u=e.arguments[o],f=t.valueFromASTUntyped(u.value,r);null!=f&&(n[s(u)]=f,i++)}return 0<i?n:null},m=function(e,t){if(t&&e.variableDefinitions){for(var r={},n=0,i=e.variableDefinitions.length;n<i;n++){var o=s(e.variableDefinitions[n].variable);r[o]=t[o]}return r}},h=function(e,r){var n={};if(!r)return n;if(e.variableDefinitions)for(var i=0,o=e.variableDefinitions.length;i<o;i++){var a=e.variableDefinitions[i],u=s(a.variable);n[u]=void 0===r[u]&&a.defaultValue?t.valueFromASTUntyped(a.defaultValue,r):r[u]}for(var f in r)f in n||(n[f]=r[f]);return n};function g(e,t,r){if(!e)throw(e=Error((t||"Minfied Error #"+r+"\n")+"\nhttps://bit.ly/2XbVrpR#"+r)).name="Graphcache Error",e}var k=function(e){for(var t=0;t<e.definitions.length;t++)if(e.definitions[t].kind===r.Kind.OPERATION_DEFINITION)return e.definitions[t];g(!1,"",1)},b=function(e){for(var t={},n=0;n<e.definitions.length;n++){var i=e.definitions[n];i.kind===r.Kind.FRAGMENT_DEFINITION&&(t[s(i)]=i)}return t},q=function(e,r){var n=e.directives;if(!n)return!0;for(var i=0,o=n.length;i<o;i++){var a=n[i];if(("include"===(e=s(a))||"skip"===e)&&a.arguments&&a.arguments[0]&&"if"===s(a.arguments[0]))return r=t.valueFromASTUntyped(a.arguments[0].value,r),"include"===e?!!r:!r}return!0},O=/^__/,_=function(e,t,r){return!!O.test(r)||!!(e=N(e,t,r))&&n.isNullableType(e.type)},x=function(e,t,r){return!!(e=N(e,t,r))&&(e=n.isNonNullType(e.type)?e.type.ofType:e.type,n.isListType(e)&&n.isNullableType(e.ofType))},w=function(e,t,r){return!!r&&(!(t=d(t))||r===t||(t=e.getType(t),r=e.getType(r),t instanceof n.GraphQLObjectType?t===r:(function(e,t){g(e instanceof n.GraphQLInterfaceType||e instanceof n.GraphQLUnionType,"",5)}(t),K(r),e.isPossibleType(t,r))))},N=function(e,t,r){return K(e=e.getType(t)),e.getFields()[r]};function K(e,t){g(e instanceof n.GraphQLObjectType,"",3)}var S=function(e,t){return t?e+"("+i.stringifyVariables(t)+")":e},E=function(e,t){return e+"."+t},T=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}},F=function(e){var t=e.indexOf(".");return{entityKey:e.slice(0,t).replace(/%2e/g,"."),fieldKey:e=e.slice(t+1)}},A=function(){return Object.create(null)},M=null,L=null,D=null,P=null,I=!1,C=function(){return{optimistic:A(),base:new Map}},R=function(e,t,r,n){M=e,L=t,D=A(),I=!!n,r?n||0<t.optimisticOrder.length?(n||t.commutativeKeys.has(r)?n&&t.commutativeKeys.delete(r):ne(t,r),P=r,ie(t,r)):(P=null,ae(t,r)):P=null},j=function(){var e=L,t=P;if(I=!1,P=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]);)fe(e.optimisticOrder[t]);D=L=M=null,e.defer||(e.defer=!0,Promise.resolve().then((function(){R("write",e,null),W(),le(),j(),e.defer=!1})))},Q=function(e,t,r){R("read",e,t,r),j()},G=function(){return g(null!==D,"",2),D},V=function(e,t,r,n){var i=(e=P?e.optimistic[P]:e.base).get(t);void 0===i&&e.set(t,i=A()),void 0!==n||P?i[r]=n:delete i[r]},U=function(e,t,r){for(var n,i=0,o=L.optimisticOrder.length;i<o;i++){var a=L.optimisticOrder[i],u=e.optimistic[a];if(u&&(!I||L.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},J=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))},B=function(e,t,r,n){if("string"==typeof r)J(e,t,r,n);else if(Array.isArray(r))for(var i=0,o=r.length;i<o;i++){var a=r[i];a&&J(e,t,a,n)}},z=function(e,t,r){if(void 0!==r)for(var n in r)t.has(n)||(e.push(T(n)),t.add(n))},X=function(e,t,r,n){z(e,t,n.base.get(r));for(var i=0,o=L.optimisticOrder.length;i<o;i++){var a=n.optimistic[L.optimisticOrder[i]];void 0!==a&&z(e,t,a.get(r))}};function H(e,t,r){if(0<(L.refCount[e]||0))r.delete(e);else{for(var n in L.refLock){if(0<((t=L.refLock[n])[e]||0))return;delete t[e]}if(delete L.refCount[e],r.delete(e),L.records.base.delete(e),n=L.links.base.get(e))for(var i in L.links.base.delete(e),n)B(r,L.refCount,n[i],-1)}}var W=function(){L.gc.forEach(H)},Y=function(e,t){"__typename"!==t&&(e!==L.queryRootKey?D[e]=!0:void 0!==t&&(D[E(e,t)]=!0))},Z=function(e,t){!I&&L.storage&&L.persist.add(function(e,t){return e.replace(/\./g,"%2e")+"."+t}(e,t))},$=function(e,t){return Y(e,t),U(L.records,e,t)},ee=function(e,t){return Y(e,t),U(L.links,e,t)},te=function(e,t,r){Y(e,t),Z(e,t),V(L.records,e,t,r)},re=function(e,t,r){var n=L;if(P)var i=n.refLock[P]||(n.refLock[P]=A()),o=n.links.optimistic[P];else{i=n.refCount,o=n.links.base;var a=n.gc}o=(o=o&&o.get(e))&&o[t],Y(e,t),Z(e,t),V(n.links,e,t,r),B(a,i,o,-1),B(a,i,r,1)},ne=function(e,t){var r=e.optimisticOrder.indexOf(t);-1===r?e.optimisticOrder.unshift(t):e.commutativeKeys.has(t)||(oe(e,t),e.optimisticOrder.splice(r,1),e.optimisticOrder.unshift(t)),e.commutativeKeys.add(t)},ie=function(e,t){-1===e.optimisticOrder.indexOf(t)&&e.optimisticOrder.unshift(t),e.refLock[t]||(e.refLock[t]=A(),e.links.optimistic[t]=new Map,e.records.optimistic[t]=new Map)},oe=function(e,t){e.refLock[t]&&(delete e.refLock[t],delete e.records.optimistic[t],delete e.links.optimistic[t])},ae=function(e,t){var r=e.optimisticOrder.indexOf(t);-1<r&&(e.optimisticOrder.splice(r,1),e.commutativeKeys.delete(t)),oe(e,t)};function ue(e,t){for(var r in e)re(t,r,e[r])}function se(e,t){for(var r in e)te(t,r,e[r])}var fe=function(e){var t=D;D=A();var r=L.links.optimistic[e];r&&r.forEach(ue),(r=L.records.optimistic[e])&&r.forEach(se),D=t,ae(L,e)},ce=function(e){var t=L.links,r=L.records,n=[],i=new Set;return Y(e),X(n,i,e,t),X(n,i,e,r),n},le=function(){if(L.storage){I=!0;var e=A();L.persist.forEach((function(t){var r,n=F(t),o=n.entityKey;e[t]=void 0!==(r=ee(o,n=n.fieldKey))?":"+i.stringifyVariables(r):void 0!==(r=$(o,n))?i.stringifyVariables(r):void 0})),I=!1,L.storage.writeData(e),L.persist.clear()}},de=function(e,t,r,n,i,o){return{store:e,variables:t,fragments:r,parentTypeName:n,parentKey:i,parentFieldKey:"",fieldName:"",partial:!1,optimistic:!!o}},pe=function(e,t,r,n,i){e.parentTypeName=t,e.parentKey=r,e.parentFieldKey=n,e.fieldName=i},ve=function(e,t,r,n){if(!t)return!1;var i=d(e);return!i||t===i||!l(e).some((function(e){return!!p(e)&&(e=S(s(e),y(e,n)),!function(e,t){return void 0!==$(e,t)||void 0!==ee(e,t)}(r,e))}))},ye=function(e,t,r,n){var i,o=0;return function(){if(void 0!==i){var a=i();if(void 0!==a)return a;i=void 0}for(;o<r.length;)if(a=r[o++],q(a,n.variables))if(p(a)){if("__typename"!==s(a))return a}else if(void 0!==(a=v(a)?a:n.fragments[s(a)])&&(n.store.schema?w(n.store.schema,a,e):ve(a,e,t,n.variables)))return(i=ye(e,t,l(a),n))()}},me=function(e){return void 0===e?null:e},he=function(e,t,r,n){return R("write",e.data,n||null),e=ge(e,t,r),j(),e},ge=function(e,t,r){var n=k(t.query),i={data:r,dependencies:G()},o=e.rootFields[n.operation];return e=de(e,h(n,t.variables),b(t.query),o,o),ke(e,o,l(n),r),i},ke=function(e,t,r,n){var i=t===e.store.rootFields.query,o=!i&&!!e.store.rootNames[t],a=o||i?t:n.__typename;if(a){o||i||!t||te(t,"__typename",a),r=ye(a,t||a,r,e);for(var u;u=r();){i=s(u);var f=y(u,e.variables),d=S(i,f),p=c(u),v=n[p];if(e.optimistic&&o){if(!(v=e.store.optimisticMutations[i]))continue;pe(e,a,a,d,i),v=n[p]=me(v(f||{},e.store,e))}u.selectionSet?t&&!o?(p=E(t,d),u=be(e,l(u),me(v),p),re(t||a,d,u)):be(e,l(u),me(v)):t&&!o&&te(t||a,d,v),o&&(pe(e,a,a,E(a,d),i),d=e.store.updates[a][i])&&(n[i]=v,d(n,f||{},e.store,e))}}},be=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?E(n,""+o):void 0;u=be(e,t,u,s),i[o]=u}return i}return null===r?null:(n=e.store.keyOfEntity(r)||n,ke(e,n,t,r),n||null)},qe=function(e){var t,r;this.keyOfField=S,e||(e={}),this.resolvers=e.resolvers||{},this.optimisticMutations=e.optimistic||{},this.keys=e.keys||{};var n="Query",i="Mutation",a="Subscription";if(e.schema){var u=this.schema=o.buildClientSchema(e.schema),s=u.getQueryType(),f=u.getMutationType();u=u.getSubscriptionType(),n=s?s.name:n,i=f?f.name:i,a=u?u.name:a}this.updates=((t={})[i]=e.updates&&e.updates.Mutation||{},t[a]=e.updates&&e.updates.Subscription||{},t),this.rootFields={query:n,mutation:i,subscription:a},this.rootNames=((r={})[n]="query",r[i]="mutation",r[a]="subscription",r),this.data=function(e){return{defer:!1,gc:new Set,persist:new Set,queryRootKey:e,refCount:A(),refLock:A(),links:C(),records:C(),commutativeKeys:new Set,optimisticOrder:[],storage:null}}(n)};qe.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},qe.prototype.resolveFieldByKey=function(e,t){if(null===(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e))return null;var r=$(e,t);return void 0!==r?r:(t=ee(e,t))?t:null},qe.prototype.resolve=function(e,t,r){return this.resolveFieldByKey(e,S(t,r))},qe.prototype.invalidate=function(e,t,r){g(e="string"==typeof e?e:this.keyOfEntity(e),"",19),function(e,t,r){t=t?[{fieldKey:S(t,r)}]:ce(e),r=0;for(var n=t.length;r<n;r++){var i=t[r].fieldKey;void 0!==ee(e,i)?re(e,i,void 0):te(e,i,void 0)}}(e,t,r)},qe.prototype.inspectFields=function(e){return null!==(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e)?ce(e):[]},qe.prototype.updateQuery=function(e,t){e=i.createRequest(e.query,e.variables),null!==(t=t(this.readQuery(e)))&&ge(this,e,t)},qe.prototype.readQuery=function(e){return _e(this,i.createRequest(e.query,e.variables)).data},qe.prototype.readFragment=function(e,t,r){return Ne(this,e,t,r)},qe.prototype.writeFragment=function(t,r,n){!function(t,r,n,i){r=b(r);var o=Object.keys(r);if(void 0!==(o=r[o[0]])){var a=f(o);n=e._extends({},{__typename:a},n);var u=t.keyOfEntity(n);u&&(t=de(t,i||{},r,a,u),ke(t,u,l(o),n))}}(this,t,r,n)};var Oe=function(e,t,r){return R("read",e.data,null),e=_e(e,t,r),j(),e},_e=function(e,t,r){var n=k(t.query),i=e.rootFields[n.operation],o=l(n);return r=r||{},r=i!==(e=de(e,h(n,t.variables),b(t.query),i,i)).store.rootFields.query?xe(e,i,o,r):Ke(e,i,o,r),{dependencies:G(),partial:void 0!==r&&e.partial,data:void 0===r?null:r}},xe=function(e,t,r,n){if("string"!=typeof n.__typename)return n;t=ye(t,t,r,e),(r={}).__typename=n.__typename;for(var i;void 0!==(i=t());){var o=c(i),a=n[o];void 0!==i.selectionSet&&null!==a?(a=me(a),r[o]=we(e,l(i),a)):r[o]=a}return r},we=function(e,t,r){if(Array.isArray(r)){for(var n=Array(r.length),i=0,o=r.length;i<o;i++)n[i]=we(e,t,r[i]);return n}return null===r?null:null!==(n=e.store.keyOfEntity(r))?void 0===(e=Ke(e,n,t,{}))?null:e:xe(e,r.__typename,t,r)},Ne=function(t,r,n,i){r=b(r);var o=Object.keys(r);if(void 0===(o=r[o[0]]))return null;var a=f(o);return"string"==typeof n||n.__typename||(n.__typename=a),(n="string"!=typeof n?t.keyOfEntity(e._extends({},{__typename:a},n)):n)?(t=de(t,i||{},r,a,n),Ke(t,n,l(o),{})||null):null},Ke=function(e,t,r,n,i){var o=e.store,a=t===o.rootFields.query,u=i&&o.keyOfEntity(i)||t;if("string"==typeof(t=a?t:$(u,"__typename")||i&&i.__typename)&&(!i||t===i.__typename)){n.__typename=t,r=ye(t,u,r,e);for(var f,d=!1,p=!1;void 0!==(f=r());){var v=s(f),m=y(f,e.variables),h=c(f),k=S(v,m),b=E(u,k),q=$(u,k),O=i?i[v]:void 0,x=o.resolvers[t],w=void 0;if(void 0!==O&&void 0===f.selectionSet)w=O;else if("read"===(g(null!==M,"",2),M)&&x&&"function"==typeof x[v]){if(pe(e,t,u,b,v),void 0!==q&&(n[h]=q),w=x[v](n,m||{},o,e),void 0!==f.selectionSet&&(w=Se(e,t,v,b,l(f),n[h]||{},w)),o.schema&&null===w&&!_(o.schema,t,v))return}else void 0===f.selectionSet?w=q:void 0!==O?w=Se(e,t,v,b,l(f),n[h],O):void 0!==(m=ee(u,k))?w=Ee(e,m,t,v,l(f),n[h]):"object"==typeof q&&null!==q&&(w=q);if(void 0===w&&o.schema&&_(o.schema,t,v))p=!0,n[h]=null;else{if(void 0===w)return;d=!0,n[h]=w}}return p&&(e.partial=!0),a&&p&&!d?void 0:n}},Se=function(e,t,r,n,i,o,a){if(Array.isArray(a)){var u=e.store;u=!u.schema||x(u.schema,t,r);for(var s=Array(a.length),f=0,c=a.length;f<c;f++){var l=Se(e,t,r,E(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:Te(a)?(t=o||{},"string"==typeof a?Ke(e,a,i,t):Ke(e,n,i,t,a)):void 0},Ee=function(e,t,r,n,i,o){if(Array.isArray(t)){var a=e.store;a=a.schema&&x(a.schema,r,n);for(var u=Array(t.length),s=0,f=t.length;s<f;s++){var c=Ee(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:Ke(e,t,i,o||{})},Te=function(e){return"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename},Fe=function(t,r){return e._extends({},t,{context:e._extends({},t.context,{meta:e._extends({},t.context.meta,{cacheOutcome:r})})})},Ae=function(t,r){return e._extends({},t,{context:e._extends({},t.context,{requestPolicy:r})})};function Me(e){return a.fromArray(e[0])}function Le(e,t){return e.push(t),e}function De(e){return"query"===e.operationName&&"network-only"!==e.context.requestPolicy}function Pe(e){return"query"!==e.operationName||"network-only"===e.context.requestPolicy}function Ie(e){return"miss"!==e.outcome||"cache-only"===e.operation.context.requestPolicy}var Ce=function(t){return function(r){function n(e){return Fe(e.operation,"miss")}function o(e){return"miss"===e.outcome&&"cache-only"!==e.operation.context.requestPolicy&&!S(e.dependencies)}function u(e){var t=e.operation,r=e.outcome,n=e.dependencies;return e={operation:Fe(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,S(n)?"cache-and-network"===t.context.requestPolicy&&N.add(t.key):y.reexecuteOperation(Ae(t,"network-only"))),e}function s(e){var t=new Set,r=P(e,t);return T(e.operation,t),r}function f(e){return!O.has(e.operation.key)}function c(e){if(_.push(e)<O.size)return a.empty;for(var t=0;t<_.length;t++)ne(q.data,_[t].operation.key);for(var r in w)delete w[r];t=[],r=new Set;for(var n;n=_.shift();)t.push(P(n,r));return T(e.operation,r),a.fromArray(t)}function d(e){return O.has(e.operation.key)}var p,v=r.forward,y=r.client,q=new qe(t);t&&t.storage&&(p=t.storage.readData().then((function(e){!function(e,t,r){for(var n in R("read",e,null),r){var i=r[n];if(void 0!==i){var o=F(n),a=o.entityKey;o=o.fieldKey,":"===i[0]?re(a,o,JSON.parse(i.slice(1))):te(a,o,JSON.parse(i))}}j(),e.storage=t}(q.data,t.storage,e)})));var O=new Map,_=[],x=new Map,w=A(),N=new Set,K=A(),S=function(e){for(var t in e)if(w[t])return!0;return!1},E=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])}},T=function(e,t){t.forEach((function(t){if(t!==e.key){var r=x.get(t);if(r){x.delete(t);var n="cache-first";N.has(t)&&(N.delete(t),n="cache-and-network"),y.reexecuteOperation(Ae(r,n))}}}))},M=function(t){if("query"===t.operationName)ne(q.data,t.key);else if("teardown"===t.operationName)x.delete(t.key),Q(q.data,t.key);else if("mutation"===t.operationName&&"network-only"!==t.context.requestPolicy){var r=function(e,t,r){R("write",e.data,r,!0),r=k(t.query);var n={data:{},dependencies:G()},i=e.rootFields[r.operation];return g(i===e.rootFields.mutation,"",10),e=de(e,h(r,t.variables),b(t.query),i,i,!0),ke(e,i,l(r),n.data),j(),n}(q,t,t.key).dependencies;if(!function(e){for(var t in e)return!1;return!0}(r)){for(var n in r)w[n]=!0;O.set(t.key,r),n=new Set,E(n,r),T(t,n)}}return e._extends({},t,{variables:t.variables?m(k(t.query),t.variables):t.variables,query:i.formatDocument(t.query)})},L=function(e,t){for(var r in t)(K[r]||(K[r]=[])).push(e.key),x.set(e.key,e)},D=function(e){var t=Oe(q,e),r=t.data?t.partial?"partial":"hit":"miss";return L(e,t.dependencies),{outcome:r,operation:e,data:t.data,dependencies:t.dependencies}},P=function(e,t){var r=e.operation,n=e.error,i=e.extensions,o=r.key;if("mutation"===r.operationName){var a=O.get(o);E(t,a),O.delete(o)}else ne(q.data,r.key);if(e.data){if(o=he(q,r,e.data,o).dependencies,E(t,o),o=Oe(q,r,e.data),e.data=o.data,"query"===r.operationName){var u=o.dependencies;E(t,u)}}else Q(q.data,r.key);return u&&L(e.operation,u),{data:e.data,error:n,extensions:i,operation:r}};return function(e){e=a.share(e);var t=p?a.mergeMap(Me)(a.take(1)(a.combine(a.scan(Le,[])(e),a.fromPromise(p)))):a.empty;t=a.share(a.concat([t,e])),e=a.share(a.map(D)(a.filter(De)(t))),t=a.filter(Pe)(t);var r=a.map(n)(a.filter(o)(e));return e=a.map(u)(a.filter(Ie)(e)),r=a.share(v(a.map(M)(a.merge([t,r])))),t=a.map(s)(a.filter(f)(r)),r=a.mergeMap(c)(a.filter(d)(r)),a.merge([t,r,e])}}},Re=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=qe,exports.cacheExchange=Ce,exports.offlineExchange=function(e){return function(t){function r(e){return"mutation"!==e.operation.operationName||!Re(e.error)||!function(e,t){var r,n=t.variables||A(),i=b(t.query);for(t=[].concat(l(k(t.query)));r=t.pop();)if(q(r,n))if(p(r)){if(e[s(r)])return!0}else(r=v(r)?r:i[s(r)])&&t.push.apply(t,l(r));return!1}(c,e.operation)||(d.push(e.operation),y(),!1)}var n=e.storage;if(n&&n.onOnline&&n.readMetadata&&n.writeMetadata){var o=t.forward,f=t.client;t=t.dispatchDebug;var c=e.optimistic||{},d=[],y=function(){for(var e=[],t=0;t<d.length;t++){var r=d[t];"mutation"===r.operationName&&e.push({query:u.print(r.query),variables:r.variables})}n.writeMetadata(e)},m=!1,h=function(){if(!m){m=!0;for(var e;e=d.shift();)f.reexecuteOperation(e);y(),m=!1}};n.onOnline(h),n.readMetadata().then((function(e){if(e){for(var t=0;t<e.length;t++)d.push(f.createRequestOperation("mutation",i.createRequest(e[t].query,e[t].variables)));h()}}));var g=Ce(e)({client:f,dispatchDebug:t,forward:function(e){return a.filter(r)(o(e))}});return function(e){e=a.share(e);var t=a.makeSubject(),r=t.next;return e=a.merge([t.source,e]),a.filter((function(e){return"query"!==e.operation.operationName||!Re(e.error)||(r(Ae(e.operation,"cache-only")),d.push(e.operation),!1)}))(g(e))}}return Ce(e)(t)}},exports.query=Oe,exports.write=he;
//# sourceMappingURL=urql-exchange-graphcache.min.js.map
{
"name": "@urql/exchange-graphcache",
"version": "3.1.4",
"version": "3.1.5",
"description": "A normalized and configurable cache exchange for urql",

@@ -5,0 +5,0 @@ "sideEffects": false,

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