Socket
Socket
Sign inDemoInstall

@urql/exchange-graphcache

Package Overview
Dependencies
Maintainers
4
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 2.1.1 to 2.2.0

dist/types/graphcache/src/types.d.ts

13

CHANGELOG.md
# @urql/exchange-graphcache
## 2.2.0
### Minor Changes
- Add `cache.invalidate` to invalidate an entity directly to remove it from the cache and all subsequent cache results, e.g. `cache.invalidate({ __typename: 'Todo', id: 1 })`, by [@JoviDeCroock](https://github.com/JoviDeCroock) (See [#566](https://github.com/FormidableLabs/urql/pull/566))
### Patch Changes
- ⚠️ Fix `cache-only` operations being forwarded and triggering fetch requests, by [@JoviDeCroock](https://github.com/JoviDeCroock) (See [#551](https://github.com/FormidableLabs/urql/pull/551))
- Apply Query results in-order and commutatively even when results arrive out-of-order, by [@kitten](https://github.com/kitten) (See [#565](https://github.com/FormidableLabs/urql/pull/565))
- Updated dependencies (See [#551](https://github.com/FormidableLabs/urql/pull/551), [#542](https://github.com/FormidableLabs/urql/pull/542), and [#544](https://github.com/FormidableLabs/urql/pull/544))
- @urql/core@1.9.1
## 2.1.1

@@ -4,0 +17,0 @@

1

dist/types/ast/index.d.ts
export { getFieldArguments, normalizeVariables } from './variables';
export * from './traversal';
export * from './node';
export * from './schemaPredicates';

@@ -5,2 +5,2 @@ export * from './operations';

export { cacheExchange } from './cacheExchange';
export { populateExchange } from './populateExchange';
export { populateExchange } from '@urql/exchange-populate';

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

import { OperationRequest, Variables, Fragments, SelectionSet } from '../types';
import { SelectionSet } from 'shared';
import { OperationRequest, Variables, Fragments } from '../types';
import { Store } from '../store';

@@ -3,0 +4,0 @@ interface Context {

import { FieldNode } from 'graphql';
import { SelectionSet } from 'shared';
import { Store } from '../store';
import { Fragments, Variables, SelectionSet, DataField, NullArray, Data } from '../types';
import { Fragments, Variables, DataField, NullArray, Data } from '../types';
interface Context {

@@ -5,0 +6,0 @@ store: Store;

@@ -8,5 +8,5 @@ import { DocumentNode } from 'graphql';

/** Writes a request given its response to the store */
export declare const write: (store: Store, request: OperationRequest, data: Data) => WriteResult;
export declare const write: (store: Store, request: OperationRequest, data: Data, key?: number | undefined) => WriteResult;
export declare const startWrite: (store: Store, request: OperationRequest, data: Data) => WriteResult;
export declare const writeOptimistic: (store: Store, request: OperationRequest, optimisticKey: number) => WriteResult;
export declare const writeOptimistic: (store: Store, request: OperationRequest, key: number) => WriteResult;
export declare const writeFragment: (store: Store, query: DocumentNode, data: Data, variables?: Variables | undefined) => void;

@@ -8,18 +8,31 @@ import { Link, EntityField, FieldInfo, StorageAdapter, SerializedEntries } from '../types';

base: KeyMap<Dict<T>>;
keys: number[];
}
export interface InMemoryData {
/** Ensure persistence is never scheduled twice at a time */
persistenceScheduled: boolean;
/** Batches changes to the data layer that'll be written to `storage` */
persistenceBatch: SerializedEntries;
/** Ensure garbage collection is never scheduled twice at a time */
gcScheduled: boolean;
/** A list of entities that have been flagged for gargabe collection since no references to them are left */
gcBatch: Set<string>;
/** The API's "Query" typename which is needed to filter dependencies */
queryRootKey: string;
/** Number of references to each entity (except "Query") */
refCount: Dict<number>;
/** Number of references to each entity on optimistic layers */
refLock: OptimisticMap<Dict<number>>;
/** A map of entity fields (key-value entries per entity) */
records: NodeMap<EntityField>;
/** A map of entity links which are connections from one entity to another (key-value entries per entity) */
links: NodeMap<Link>;
/** A set of Query operation keys that are in-flight and awaiting a result */
commutativeKeys: Set<number>;
/** The order of optimistic layers */
optimisticOrder: number[];
/** This may be a persistence adapter that will receive changes in a batch */
storage: StorageAdapter | null;
}
/** Before reading or writing the global state needs to be initialised */
export declare const initDataState: (data: InMemoryData, optimisticKey: number | null) => void;
export declare const initDataState: (data: InMemoryData, layerKey: number | null, forceOptimistic?: boolean | undefined) => void;
/** Reset the data state after read/write is complete */

@@ -41,4 +54,6 @@ export declare const clearDataState: () => void;

export declare const writeLink: (entityKey: string, fieldKey: string, link: string | import("../types").NullArray<string> | null | undefined) => void;
/** Reserves an optimistic layer and preorders it */
export declare const reserveLayer: (data: InMemoryData, layerKey: number) => void;
/** Removes an optimistic layer of links and records */
export declare const clearOptimistic: (data: InMemoryData, optimisticKey: number) => void;
export declare const clearLayer: (data: InMemoryData, layerKey: number) => void;
/** Return an array of FieldInfo (info on all the fields and their arguments) for a given entity */

@@ -45,0 +60,0 @@ export declare const inspectFields: (entityKey: string) => FieldInfo[];

@@ -1,3 +0,3 @@

export { initDataState, clearDataState, clearOptimistic, getCurrentDependencies, } from './data';
export { initDataState, clearDataState, reserveLayer, clearLayer, getCurrentDependencies, } from './data';
export * from './keys';
export * from './store';

@@ -29,2 +29,3 @@ import { DocumentNode, IntrospectionQuery, GraphQLSchema } from 'graphql';

invalidateQuery(query: string | DocumentNode, variables?: Variables): void;
invalidate(entity: Data | string): void;
inspectFields(entity: Data | string | null): FieldInfo[];

@@ -31,0 +32,0 @@ updateQuery(input: QueryInput, updater: (data: Data | null) => DataFields | null): void;

@@ -17,5 +17,22 @@ "use strict";

return a.kind === graphql.Kind.INLINE_FRAGMENT;
}, unwrapType = function(a) {
return graphql.isWrappingType(a) ? unwrapType(a.ofType) : a || null;
}, makeDict = function() {
}, helpUrl = "\nhttps://github.com/FormidableLabs/urql/tree/master/exchanges/graphcache/help.md#", cache = new Set, currentDebugStack = [], pushDebugNode = function(a, b) {
var c = "";
b.kind === graphql.Kind.INLINE_FRAGMENT ? c = a ? 'Inline Fragment on "' + a + '"' : "Inline Fragment" : b.kind === graphql.Kind.OPERATION_DEFINITION ? c = (b.name ? '"' + b.name.value + '"' : "Unnamed") + " " + b.operation : b.kind === graphql.Kind.FRAGMENT_DEFINITION && (c = '"' + b.name.value + '" Fragment');
c && currentDebugStack.push(c);
}, getDebugOutput = function() {
return currentDebugStack.length ? "\n(Caused At: " + currentDebugStack.join(", ") + ")" : "";
};
function invariant(a, b, c) {
if (!a) {
throw a = b || "Minfied Error #" + c + "\n", "production" !== process.env.NODE_ENV && (a += getDebugOutput()),
(c = Error(a + helpUrl + c)).name = "Graphcache Error", c;
}
}
function warn(a, b) {
cache.has(a) || (console.warn(a + getDebugOutput() + helpUrl + b), cache.add(a));
}
var makeDict = function() {
return Object.create(null);

@@ -26,7 +43,7 @@ }, getFieldArguments = function(a, b) {

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

@@ -38,6 +55,6 @@ if (void 0 === a.variableDefinitions) {

return a.variableDefinitions.reduce((function(a, b) {
var d = getName(b.variable), e = c[d];
if (void 0 === e) {
var e = getName(b.variable), d = c[e];
if (void 0 === d) {
if (void 0 !== b.defaultValue) {
e = graphql.valueFromASTUntyped(b.defaultValue, c);
d = graphql.valueFromASTUntyped(b.defaultValue, c);
} else {

@@ -47,25 +64,6 @@ return a;

}
a[d] = e;
a[e] = d;
return a;
}), makeDict());
}, helpUrl = "\nhttps://github.com/FormidableLabs/urql-exchange-graphcache/blob/master/docs/help.md#", cache = new Set, currentDebugStack = [], pushDebugNode = function(a, b) {
var c = "";
b.kind === graphql.Kind.INLINE_FRAGMENT ? c = a ? 'Inline Fragment on "' + a + '"' : "Inline Fragment" : b.kind === graphql.Kind.OPERATION_DEFINITION ? c = (b.name ? '"' + b.name.value + '"' : "Unnamed") + " " + b.operation : b.kind === graphql.Kind.FRAGMENT_DEFINITION && (c = '"' + b.name.value + '" Fragment');
c && currentDebugStack.push(c);
}, getDebugOutput = function() {
return currentDebugStack.length ? "\n(Caused At: " + currentDebugStack.join(", ") + ")" : "";
};
function invariant(a, b, c) {
if (!a) {
throw a = b || "Minfied Error #" + c + "\n", "production" !== process.env.NODE_ENV && (a += getDebugOutput()),
(c = Error(a + helpUrl + c)).name = "Graphcache Error", c;
}
}
function warn(a, b) {
cache.has(a) || (console.warn(a + getDebugOutput() + helpUrl + b), cache.add(a));
}
var isFragmentNode = function(a) {
}, isFragmentNode = function(a) {
return a.kind === graphql.Kind.FRAGMENT_DEFINITION;

@@ -94,6 +92,6 @@ };

}
for (var c = 0, e = a.length; c < e; c++) {
var d = a[c], f = getName(d), g = "include" === f;
if ((g || "skip" === f) && (d = d.arguments ? d.arguments[0] : null) && "if" === getName(d) && ("boolean" == typeof (d = graphql.valueFromASTUntyped(d.value, b)) || null === d)) {
return g ? !!d : !d;
for (var c = 0, d = a.length; c < d; c++) {
var e = a[c], f = getName(e), g = "include" === f;
if ((g || "skip" === f) && (e = e.arguments ? e.arguments[0] : null) && "if" === getName(e) && ("boolean" == typeof (e = graphql.valueFromASTUntyped(e.value, b)) || null === e)) {
return g ? !!e : !e;
}

@@ -119,11 +117,11 @@ }

}
var e = a.getType(b), d = a.getType(c);
if (e instanceof graphql.GraphQLObjectType) {
return e === d;
var d = a.getType(b), e = a.getType(c);
if (d instanceof graphql.GraphQLObjectType) {
return d === e;
}
!function expectAbstractType(a, b) {
invariant(a instanceof graphql.GraphQLInterfaceType || a instanceof graphql.GraphQLUnionType, "production" !== process.env.NODE_ENV ? "Invalid Abstract type: The type `" + b + "` is not an Interface or Union type in the defined schema, but a fragment in the GraphQL document is using it as a type condition." : "", 5);
}(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) {

@@ -164,12 +162,32 @@ expectObjectType(a = a.getType(b), b);

optimistic: makeDict(),
base: new Map,
keys: []
base: new Map
};
}, initDataState = function(a, b) {
}, initDataState = function(a, b, c) {
currentData = a;
currentDependencies = new Set;
currentOptimisticKey = b;
"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;
}, clearDataState = function() {
var c = currentData;
var c = currentData, d = currentOptimisticKey;
currentOptimisticKey = null;
if (d && c.commutativeKeys.has(d)) {
var e = c.optimisticOrder.length - c.commutativeKeys.size;
if (c.optimisticOrder[c.optimisticOrder.length - 1] === d) {
d = [];
for (var f = c.optimisticOrder.length; e < f; e++) {
var g = c.optimisticOrder[e];
if (!c.refLock[g]) {
break;
}
d.unshift(g);
}
f = 0;
for (e = d.length; f < e; f++) {
squashLayer(d[f]);
}
}
}
currentDependencies = currentData = null;
"production" !== process.env.NODE_ENV && (currentDebugStack.length = 0);
!c.gcScheduled && 0 < c.gcBatch.size && (c.gcScheduled = !0, defer((function a() {

@@ -183,35 +201,28 @@ gc(c);

})));
currentOptimisticKey = currentDependencies = currentData = null;
"production" !== process.env.NODE_ENV && (currentDebugStack.length = 0);
}, getCurrentDependencies = function() {
invariant(null !== currentDependencies, "production" !== process.env.NODE_ENV ? "Invalid Cache call: The cache may only be accessed or mutated duringoperations like write or query, or as part of its resolvers, updaters, or optimistic configs." : "", 2);
return currentDependencies;
}, setNode = function(a, b, c, e) {
currentOptimisticKey ? (void 0 === a.optimistic[currentOptimisticKey] && (a.optimistic[currentOptimisticKey] = new Map,
a.keys.unshift(currentOptimisticKey)), a = a.optimistic[currentOptimisticKey]) : a = a.base;
var d = a.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) {
for (var e = 0, d = a.keys.length; e < d; e++) {
var f = a.optimistic[a.keys[e]].get(b);
if (void 0 !== f && c in f) {
return f[c];
for (var d, e = 0, f = currentData.optimisticOrder.length; e < f; e++) {
var g = a.optimistic[currentData.optimisticOrder[e]];
if (g && void 0 !== (d = g.get(b)) && c in d) {
return d[c];
}
}
return void 0 !== (a = a.base.get(b)) ? a[c] : void 0;
}, clearOptimisticNodes = function(a, b) {
var c = a.keys.indexOf(b);
-1 < c && (delete a.optimistic[b], a.keys.splice(c, 1));
}, 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) {
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) {
if ("string" == typeof c) {
updateRCForEntity(a, b, c, e);
updateRCForEntity(a, b, c, d);
} else if (Array.isArray(c)) {
for (var d = 0, f = c.length; d < f; d++) {
var g = c[d];
g && updateRCForEntity(a, b, g, e);
for (var e = 0, f = c.length; e < f; e++) {
var g = c[e];
g && updateRCForEntity(a, b, g, d);
}

@@ -221,10 +232,10 @@ }

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) {
extractNodeFields(a, b, e.base.get(c));
for (var d = 0, f = e.keys.length; d < f; d++) {
extractNodeFields(a, b, e.optimistic[e.keys[d]].get(c));
}, extractNodeMapFields = function(a, b, c, d) {
extractNodeFields(a, b, d.base.get(c));
for (var e = 0, f = currentData.optimisticOrder.length; e < f; e++) {
extractNodeFields(a, b, d.optimistic[currentData.optimisticOrder[e]].get(c));
}

@@ -236,7 +247,7 @@ }, gc = function(a) {

for (var c in a.refLock) {
var e = a.refLock[c];
if (0 < (e[b] || 0)) {
var d = a.refLock[c];
if (0 < (d[b] || 0)) {
return;
}
delete e[b];
delete d[b];
}

@@ -246,11 +257,11 @@ delete a.refCount[b];

if (void 0 !== (c = a.records.base.get(b)) && (a.records.base.delete(b), a.storage)) {
for (var d in c) {
c = prefixKey("r", joinKeys(b, d)), a.persistenceBatch[c] = void 0;
for (var e in c) {
c = prefixKey("r", joinKeys(b, e)), a.persistenceBatch[c] = void 0;
}
}
if (void 0 !== (d = a.links.base.get(b))) {
if (void 0 !== (e = a.links.base.get(b))) {
a.links.base.delete(b);
for (var f in d) {
for (var f in e) {
a.storage && (c = prefixKey("l", joinKeys(b, f)), a.persistenceBatch[c] = void 0),
updateRCForLink(a.gcBatch, a.refCount, d[f], -1);
updateRCForLink(a.gcBatch, a.refCount, e[f], -1);
}

@@ -276,26 +287,52 @@ }

}, writeLink = function(a, b, c) {
var e = currentData;
var d = currentData;
if (currentOptimisticKey) {
var d = e.refLock[currentOptimisticKey] || (e.refLock[currentOptimisticKey] = makeDict());
var f = e.links.optimistic[currentOptimisticKey];
var e = d.refLock[currentOptimisticKey] || (d.refLock[currentOptimisticKey] = makeDict());
var f = d.links.optimistic[currentOptimisticKey];
} else {
e.storage && (d = prefixKey("l", joinKeys(a, b)), e.persistenceBatch[d] = c);
d = e.refCount;
f = e.links.base;
var g = e.gcBatch;
d.storage && (e = prefixKey("l", joinKeys(a, b)), d.persistenceBatch[e] = c);
e = d.refCount;
f = d.links.base;
var g = d.gcBatch;
}
f = void 0 !== (f = void 0 !== f ? f.get(a) : void 0) ? f[b] : null;
updateDependencies(a, b);
setNode(e.links, a, b, c);
updateRCForLink(g, d, f, -1);
updateRCForLink(g, d, c, 1);
}, isFragmentHeuristicallyMatching = function(a, b, c, e) {
setNode(d.links, a, b, c);
updateRCForLink(g, e, f, -1);
updateRCForLink(g, e, c, 1);
}, createLayer = function(a, b) {
-1 === a.optimisticOrder.indexOf(b) && a.optimisticOrder.unshift(b);
a.refLock[b] || (a.refLock[b] = makeDict(), a.links.optimistic[b] = new Map, a.records.optimistic[b] = new Map);
}, clearLayer = function(a, b) {
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]);
};
function _ref3(a, b) {
for (var c in a) {
writeLink(b, c, a[c]);
}
}
function _ref4(a, b) {
for (var c in a) {
writeRecord(b, c, a[c]);
}
}
var squashLayer = function(a) {
var b = currentData.links.optimistic[a];
b && b.forEach(_ref3);
(b = currentData.records.optimistic[a]) && b.forEach(_ref4);
clearLayer(currentData, a);
}, isFragmentHeuristicallyMatching = function(a, b, c, d) {
if (!b) {
return !1;
}
var d = getTypeCondition(a);
if (b === d) {
var e = getTypeCondition(a);
if (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) {

@@ -305,3 +342,3 @@ if (!isFieldNode(a)) {

}
a = keyOfField(getName(a), getFieldArguments(a, e));
a = keyOfField(getName(a), getFieldArguments(a, d));
return !function(a, b) {

@@ -311,6 +348,6 @@ return void 0 !== readRecord(a, b) || void 0 !== readLink(a, b);

}));
}, SelectionIterator = function(a, b, c, e) {
}, SelectionIterator = function(a, b, c, d) {
this.typename = a;
this.entityKey = b;
this.context = e;
this.context = d;
this.indexStack = [ 0 ];

@@ -340,4 +377,4 @@ this.selectionStack = [ c ];

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

@@ -347,5 +384,5 @@ clearDataState();

}, startWrite = function(a, b, c) {
var e = getMainOperation(b.query), d = {
var d = getMainOperation(b.query), e = {
dependencies: getCurrentDependencies()
}, f = getSelectionSet(e), g = a.getRootKey(e.operation);
}, f = getSelectionSet(d), g = a.getRootKey(d.operation);
a = {

@@ -357,23 +394,23 @@ parentTypeName: g,

store: a,
variables: normalizeVariables(e, b.variables),
variables: normalizeVariables(d, b.variables),
fragments: getFragments(b.query)
};
"production" !== process.env.NODE_ENV && pushDebugNode(g, e);
"production" !== process.env.NODE_ENV && pushDebugNode(g, d);
g === a.store.getRootKey("query") ? writeSelection(a, g, f, c) : writeRoot(a, g, f, c);
return d;
return e;
}, writeOptimistic = function(a, b, c) {
initDataState(a.data, c);
var e = getMainOperation(b.query);
initDataState(a.data, c, !0);
var d = getMainOperation(b.query);
c = {
dependencies: getCurrentDependencies()
};
var d = a.getRootKey("mutation"), f = a.getRootKey(e.operation);
invariant(f === d, "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(f, e);
var e = a.getRootKey("mutation"), f = a.getRootKey(d.operation);
invariant(f === e, "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(f, d);
a = {
parentTypeName: d,
parentKey: d,
parentTypeName: e,
parentKey: e,
parentFieldKey: "",
fieldName: "",
variables: normalizeVariables(e, b.variables),
variables: normalizeVariables(d, b.variables),
fragments: getFragments(b.query),

@@ -384,13 +421,13 @@ store: a,

b = makeDict();
e = new SelectionIterator(f, f, getSelectionSet(e), a);
for (var g; void 0 !== (g = e.next()); ) {
d = new SelectionIterator(f, f, getSelectionSet(d), a);
for (var g; void 0 !== (g = d.next()); ) {
if (void 0 !== g.selectionSet) {
var h = getName(g), l = a.store.optimisticMutations[h];
if (void 0 !== l) {
var h = getName(g), k = a.store.optimisticMutations[h];
if (void 0 !== k) {
a.fieldName = h;
l = l((f = getFieldArguments(g, a.variables)) || makeDict(), a.store, a);
var m = ensureData(l);
writeRootField(a, m, getSelectionSet(g));
b[h] = l;
void 0 !== (g = a.store.updates[d][h]) && g(b, f || makeDict(), a.store, a);
k = k((f = getFieldArguments(g, a.variables)) || makeDict(), a.store, a);
var n = ensureData(k);
writeRootField(a, n, getSelectionSet(g));
b[h] = k;
void 0 !== (g = a.store.updates[e][h]) && g(b, f || makeDict(), a.store, a);
}

@@ -401,10 +438,10 @@ }

return c;
}, writeFragment = function(a, b, c, e) {
}, writeFragment = function(a, b, c, d) {
b = getFragments(b);
var d = Object.keys(b);
if (void 0 === (d = b[d[0]])) {
var e = Object.keys(b);
if (void 0 === (e = b[e[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;
}
var f = getFragmentTypeName(d);
c = _rollupPluginBabelHelpers._extends({
var f = getFragmentTypeName(e);
c = _rollupPluginBabelHelpers._extends({}, {
__typename: f

@@ -416,3 +453,3 @@ }, c);

}
"production" !== process.env.NODE_ENV && pushDebugNode(f, d);
"production" !== process.env.NODE_ENV && pushDebugNode(f, e);
writeSelection({

@@ -423,17 +460,17 @@ parentTypeName: f,

fieldName: "",
variables: e || {},
variables: d || {},
fragments: b,
store: a
}, g, getSelectionSet(d), c);
}, writeSelection = function(a, b, c, e) {
var d = b === a.store.getRootKey("query") ? b : e.__typename;
if ("string" == typeof d) {
writeRecord(b, "__typename", d);
c = new SelectionIterator(d, b, c, a);
}, g, getSelectionSet(e), c);
}, writeSelection = function(a, b, c, d) {
var e = b === a.store.getRootKey("query") ? b : d.__typename;
if ("string" == typeof e) {
writeRecord(b, "__typename", e);
c = new SelectionIterator(e, b, c, a);
for (var f; void 0 !== (f = c.next()); ) {
var g = getName(f), h = getFieldArguments(f, a.variables);
h = keyOfField(g, h);
var l = e[getFieldAlias(f)], m = joinKeys(b, h);
var k = d[getFieldAlias(f)], n = joinKeys(b, h);
if ("production" !== process.env.NODE_ENV) {
if (void 0 === l) {
if (void 0 === k) {
g = a.optimistic ? "\nYour optimistic result may be missing a field!" : "";

@@ -444,50 +481,50 @@ f = void 0 === f.selectionSet ? "scalar (number, boolean, etc)" : "selection set";

} else {
a.store.schema && d && isFieldAvailableOnType(a.store.schema, d, g);
a.store.schema && e && isFieldAvailableOnType(a.store.schema, e, g);
}
}
void 0 === f.selectionSet ? writeRecord(b, h, l) : (g = ensureData(l), f = writeField(a, m, getSelectionSet(f), g),
void 0 === f.selectionSet ? writeRecord(b, h, k) : (g = ensureData(k), f = writeField(a, n, getSelectionSet(f), g),
writeLink(b, h, f));
}
}
}, writeField = function(a, b, c, e) {
if (Array.isArray(e)) {
for (var d = Array(e.length), f = 0, g = e.length; f < g; f++) {
var h = e[f], l = joinKeys(b, "" + f);
h = writeField(a, l, c, h);
d[f] = h;
}, writeField = function(a, b, c, d) {
if (Array.isArray(d)) {
for (var e = Array(d.length), f = 0, g = d.length; f < g; f++) {
var h = d[f], k = joinKeys(b, "" + f);
h = writeField(a, k, c, h);
e[f] = h;
}
return d;
return e;
}
if (null === e) {
if (null === d) {
return null;
}
f = null !== (d = a.store.keyOfEntity(e)) ? d : b;
g = e.__typename;
void 0 !== a.store.keys[e.__typename] || null !== d || "string" != typeof g || g.endsWith("Connection") || g.endsWith("Edge") || "PageInfo" === g || "production" !== process.env.NODE_ENV && warn("Invalid key: The GraphQL query at the field at `" + b + "` 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 `" + g + "`.\nEntities without keys will be embedded directly on the parent entity. If this is intentional, create a `keys` config for `" + g + "` that always returns null.", 15);
writeSelection(a, f, c, e);
f = null !== (e = a.store.keyOfEntity(d)) ? e : b;
g = d.__typename;
void 0 !== a.store.keys[d.__typename] || null !== e || "string" != typeof g || g.endsWith("Connection") || g.endsWith("Edge") || "PageInfo" === g || "production" !== process.env.NODE_ENV && warn("Invalid key: The GraphQL query at the field at `" + b + "` 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 `" + g + "`.\nEntities without keys will be embedded directly on the parent entity. If this is intentional, create a `keys` config for `" + g + "` that always returns null.", 15);
writeSelection(a, f, c, d);
return f;
}, writeRoot = function(a, b, c, e) {
var d = b === a.store.getRootKey("mutation") || b === a.store.getRootKey("subscription");
}, writeRoot = function(a, b, c, d) {
var e = b === a.store.getRootKey("mutation") || b === a.store.getRootKey("subscription");
c = new SelectionIterator(b, b, c, a);
for (var f; void 0 !== (f = c.next()); ) {
var g = getName(f), h = getFieldArguments(f, a.variables), l = joinKeys(b, keyOfField(g, h));
var g = getName(f), h = getFieldArguments(f, a.variables), k = joinKeys(b, keyOfField(g, h));
if (void 0 !== f.selectionSet) {
var m = ensureData(e[getFieldAlias(f)]);
writeRootField(a, m, getSelectionSet(f));
var n = ensureData(d[getFieldAlias(f)]);
writeRootField(a, n, getSelectionSet(f));
}
d && (a.parentTypeName = b, a.parentKey = b, a.parentFieldKey = l, a.fieldName = g,
void 0 !== (f = a.store.updates[b][g]) && f(e, h || makeDict(), a.store, a));
e && (a.parentTypeName = b, a.parentKey = b, a.parentFieldKey = k, a.fieldName = g,
void 0 !== (f = a.store.updates[b][g]) && f(d, h || makeDict(), a.store, a));
}
}, writeRootField = function(a, b, c) {
if (Array.isArray(b)) {
for (var e = Array(b.length), d = 0, f = b.length; d < f; d++) {
e[d] = writeRootField(a, b[d], c);
for (var d = Array(b.length), e = 0, f = b.length; e < f; e++) {
d[e] = writeRootField(a, b[e], c);
}
return e;
return d;
}
null !== b && (null !== (e = a.store.keyOfEntity(b)) ? writeSelection(a, e, c, b) : writeRoot(a, b.__typename, c, b));
null !== b && (null !== (d = a.store.keyOfEntity(b)) ? writeSelection(a, d, c, b) : writeRoot(a, b.__typename, c, b));
}, invalidateSelection = function(a, b, c) {
if ("Query" !== b) {
var e = readRecord(b, "__typename");
if ("string" != typeof e) {
var d = readRecord(b, "__typename");
if ("string" != typeof d) {
return;

@@ -497,22 +534,22 @@ }

} else {
e = b;
d = b;
}
c = new SelectionIterator(e, b, c, a);
for (var d; void 0 !== (d = c.next()); ) {
var f = getName(d), g = keyOfField(f, getFieldArguments(d, a.variables));
"production" !== process.env.NODE_ENV && a.store.schema && e && isFieldAvailableOnType(a.store.schema, e, f);
if (void 0 === d.selectionSet) {
c = new SelectionIterator(d, b, c, a);
for (var e; void 0 !== (e = c.next()); ) {
var f = getName(e), g = keyOfField(f, getFieldArguments(e, a.variables));
"production" !== process.env.NODE_ENV && a.store.schema && d && isFieldAvailableOnType(a.store.schema, d, f);
if (void 0 === e.selectionSet) {
writeRecord(b, g, void 0);
} else if (d = getSelectionSet(d), f = readLink(b, g), writeLink(b, g, void 0),
} else if (e = getSelectionSet(e), f = readLink(b, g), writeLink(b, g, void 0),
writeRecord(b, g, void 0), Array.isArray(f)) {
g = 0;
for (var h = f.length; g < h; g++) {
var l = f[g];
null !== l && invalidateSelection(a, l, d);
var k = f[g];
null !== k && invalidateSelection(a, k, e);
}
} else {
f && invalidateSelection(a, f, d);
f && invalidateSelection(a, f, e);
}
}
}, Store = function(a, b, c, e, d) {
}, Store = function(a, b, c, d, e) {
var g, f = this;

@@ -526,4 +563,4 @@ this.gcScheduled = !1;

this.resolvers = b || {};
this.optimisticMutations = e || {};
this.keys = d || {};
this.optimisticMutations = d || {};
this.keys = e || {};
this.updates = {

@@ -559,2 +596,4 @@ Mutation: c && c.Mutation || {},

records: makeNodeMap(),
commutativeKeys: new Set,
optimisticOrder: [],
storage: null

@@ -570,3 +609,3 @@ };

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

@@ -578,5 +617,5 @@ return null;

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

@@ -608,9 +647,19 @@

Store.prototype.invalidate = function(a) {
var b = "string" == typeof a ? a : this.keyOfEntity(a);
invariant(b, "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);
a = 0;
for (var c = this.inspectFields(b); a < c.length; a += 1) {
var d = c[a];
readLink(b, d.fieldKey) ? writeLink(b, d.fieldKey, void 0) : writeRecord(b, d.fieldKey, void 0);
}
};
Store.prototype.inspectFields = function(a) {
return null !== (a = null !== a && "string" != typeof a ? this.keyOfEntity(a) : a) ? 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;
}(a) : [];

@@ -637,3 +686,3 @@ };

var query = function(a, b, c) {
initDataState(a.data, 0);
initDataState(a.data, null);
a = read(a, b, c);

@@ -643,16 +692,16 @@ clearDataState();

}, read = function(a, b, c) {
var e = getMainOperation(b.query), d = a.getRootKey(e.operation), f = getSelectionSet(e);
var d = getMainOperation(b.query), e = a.getRootKey(d.operation), f = getSelectionSet(d);
a = {
parentTypeName: d,
parentKey: d,
parentTypeName: e,
parentKey: e,
parentFieldKey: "",
fieldName: "",
store: a,
variables: normalizeVariables(e, b.variables),
variables: normalizeVariables(d, b.variables),
fragments: getFragments(b.query),
partial: !1
};
"production" !== process.env.NODE_ENV && pushDebugNode(d, e);
"production" !== process.env.NODE_ENV && pushDebugNode(e, d);
c = c || makeDict();
c = d !== a.store.getRootKey("query") ? readRoot(a, d, f, c) : readSelection(a, d, f, c);
c = e !== a.store.getRootKey("query") ? readRoot(a, e, f, c) : readSelection(a, e, f, c);
return {

@@ -663,11 +712,11 @@ dependencies: getCurrentDependencies(),

};
}, readRoot = function(a, b, c, e) {
if ("string" != typeof e.__typename) {
return e;
}, readRoot = function(a, b, c, d) {
if ("string" != typeof d.__typename) {
return d;
}
b = new SelectionIterator(b, b, c, a);
(c = makeDict()).__typename = e.__typename;
for (var d; void 0 !== (d = b.next()); ) {
var f = getFieldAlias(d), g = e[f];
void 0 !== d.selectionSet && null !== g ? (g = ensureData(g), c[f] = readRootField(a, getSelectionSet(d), g)) : c[f] = g;
(c = makeDict()).__typename = d.__typename;
for (var e; void 0 !== (e = b.next()); ) {
var f = getFieldAlias(e), g = d[f];
void 0 !== e.selectionSet && null !== g ? (g = ensureData(g), c[f] = readRootField(a, getSelectionSet(e), g)) : c[f] = g;
}

@@ -677,6 +726,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;
}

@@ -686,13 +735,13 @@ if (null === c) {

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

@@ -703,3 +752,3 @@ }, c)) : c)) {

}
"production" !== process.env.NODE_ENV && pushDebugNode(f, d);
"production" !== process.env.NODE_ENV && pushDebugNode(f, e);
return readSelection({

@@ -710,46 +759,46 @@ parentTypeName: f,

fieldName: "",
variables: e || {},
variables: d || {},
fragments: b,
partial: !1,
store: a
}, c, getSelectionSet(d), makeDict()) || null;
}, readSelection = function(a, b, c, e) {
var d = a.store, f = b === d.getRootKey("query"), g = f ? b : readRecord(b, "__typename");
}, c, getSelectionSet(e), makeDict()) || null;
}, readSelection = function(a, b, c, d) {
var e = a.store, f = b === e.getRootKey("query"), g = f ? b : readRecord(b, "__typename");
if ("string" == typeof g) {
e.__typename = g;
d.__typename = g;
c = new SelectionIterator(g, b, c, a);
for (var h, l = !1, m = !1; void 0 !== (h = c.next()); ) {
var k = getName(h), n = getFieldArguments(h, a.variables), q = getFieldAlias(h), u = keyOfField(k, n), r = readRecord(b, u), t = joinKeys(b, u);
"production" !== process.env.NODE_ENV && d.schema && g && isFieldAvailableOnType(d.schema, g, k);
var p = void 0, v = d.resolvers[g];
if (void 0 !== v && "function" == typeof v[k]) {
if (a.parentTypeName = g, a.parentKey = b, a.parentFieldKey = t, a.fieldName = k,
void 0 !== r && (e[q] = r), p = v[k](e, n || makeDict(), d, a), void 0 !== h.selectionSet && (p = resolveResolverResult(a, g, k, t, getSelectionSet(h), e[q] || makeDict(), p)),
d.schema && null === p && !isFieldNullable(d.schema, g, k)) {
for (var h, k = !1, n = !1; void 0 !== (h = c.next()); ) {
var m = getName(h), p = getFieldArguments(h, a.variables), t = getFieldAlias(h), C = keyOfField(m, p), u = readRecord(b, C), B = joinKeys(b, C);
"production" !== process.env.NODE_ENV && e.schema && g && isFieldAvailableOnType(e.schema, g, m);
var q = void 0, G = e.resolvers[g];
if (void 0 !== G && "function" == typeof G[m]) {
if (a.parentTypeName = g, a.parentKey = b, a.parentFieldKey = B, a.fieldName = m,
void 0 !== u && (d[t] = u), q = G[m](d, p || makeDict(), e, a), void 0 !== h.selectionSet && (q = resolveResolverResult(a, g, m, B, getSelectionSet(h), d[t] || makeDict(), q)),
e.schema && null === q && !isFieldNullable(e.schema, g, m)) {
return;
}
} else {
void 0 === h.selectionSet ? p = r : void 0 !== (n = readLink(b, u)) ? p = resolveLink(a, n, g, k, getSelectionSet(h), e[q]) : "object" == typeof r && null !== r && (p = r);
void 0 === h.selectionSet ? q = u : void 0 !== (p = readLink(b, C)) ? q = resolveLink(a, p, g, m, getSelectionSet(h), d[t]) : "object" == typeof u && null !== u && (q = u);
}
if (void 0 === p && d.schema && isFieldNullable(d.schema, g, k)) {
m = !0, e[q] = null;
if (void 0 === q && e.schema && isFieldNullable(e.schema, g, m)) {
n = !0, d[t] = null;
} else {
if (void 0 === p) {
if (void 0 === q) {
return;
}
l = !0;
e[q] = p;
k = !0;
d[t] = q;
}
}
m && (a.partial = !0);
return f && m && !l ? void 0 : e;
n && (a.partial = !0);
return f && n && !k ? void 0 : d;
}
}, resolveResolverResult = function(a, b, c, e, d, f, g) {
}, resolveResolverResult = function(a, b, c, d, e, f, g) {
if (Array.isArray(g)) {
var h = a.store;
h = !h.schema || isListNullable(h.schema, b, c);
for (var l = Array(g.length), m = 0, k = g.length; m < k; m++) {
var n = resolveResolverResult(a, b, c, joinKeys(e, "" + m), d, void 0 !== f ? f[m] : void 0, g[m]);
if (void 0 !== n || h) {
l[m] = void 0 !== n ? n : null;
for (var k = Array(g.length), n = 0, m = g.length; n < m; n++) {
var p = resolveResolverResult(a, b, c, joinKeys(d, "" + n), e, void 0 !== f ? f[n] : void 0, g[n]);
if (void 0 !== p || h) {
k[n] = void 0 !== p ? p : null;
} else {

@@ -759,3 +808,3 @@ return;

}
return l;
return k;
}

@@ -766,40 +815,40 @@ if (null == g) {

if (isDataOrKey(g)) {
return b = void 0 === f ? makeDict() : f, "string" == typeof g ? readSelection(a, g, d, b) : function(a, b, c, e, d) {
return b = void 0 === f ? makeDict() : f, "string" == typeof g ? readSelection(a, g, e, b) : function(a, b, c, d, e) {
var f = a.store;
b = f.keyOfEntity(d) || b;
var g = d.__typename, h = readRecord(b, "__typename") || g;
b = f.keyOfEntity(e) || b;
var g = e.__typename, h = readRecord(b, "__typename") || g;
if ("string" != typeof h || g && h !== g) {
"production" !== process.env.NODE_ENV && warn("Invalid resolver data: The resolver at `" + b + "` returned an invalid typename that could not be reconciled with the cache.", 8);
} else {
e.__typename = h;
d.__typename = h;
c = new SelectionIterator(h, b, c, a);
for (var l = !1, m = !1; void 0 !== (g = c.next()); ) {
var k = getName(g), n = getFieldAlias(g), q = keyOfField(k, getFieldArguments(g, a.variables)), u = joinKeys(b, q), r = readRecord(b, q), t = d[k];
"production" !== process.env.NODE_ENV && f.schema && h && isFieldAvailableOnType(f.schema, h, k);
var p = void 0;
void 0 !== t && void 0 === g.selectionSet ? p = t : void 0 === g.selectionSet ? p = r : void 0 !== t ? p = resolveResolverResult(a, h, k, u, getSelectionSet(g), e[n], t) : void 0 !== (q = readLink(b, q)) ? p = resolveLink(a, q, h, k, getSelectionSet(g), e[n]) : "object" == typeof r && null !== r && (p = r);
if (void 0 === p && void 0 !== f.schema && isFieldNullable(f.schema, h, k)) {
m = !0, e[n] = null;
for (var k = !1, n = !1; void 0 !== (g = c.next()); ) {
var m = getName(g), p = getFieldAlias(g), t = keyOfField(m, getFieldArguments(g, a.variables)), C = joinKeys(b, t), u = readRecord(b, t), B = e[m];
"production" !== process.env.NODE_ENV && f.schema && h && isFieldAvailableOnType(f.schema, h, m);
var q = void 0;
void 0 !== B && void 0 === g.selectionSet ? q = B : void 0 === g.selectionSet ? q = u : void 0 !== B ? q = resolveResolverResult(a, h, m, C, getSelectionSet(g), d[p], B) : void 0 !== (t = readLink(b, t)) ? q = resolveLink(a, t, h, m, getSelectionSet(g), d[p]) : "object" == typeof u && null !== u && (q = u);
if (void 0 === q && void 0 !== f.schema && isFieldNullable(f.schema, h, m)) {
n = !0, d[p] = null;
} else {
if (void 0 === p) {
if (void 0 === q) {
return;
}
l = !0;
e[n] = p;
k = !0;
d[p] = q;
}
}
m && (a.partial = !0);
return l ? e : void 0;
n && (a.partial = !0);
return k ? d : void 0;
}
}(a, e, d, b, g);
}(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) {
if (Array.isArray(b)) {
var g = a.store;
g = g.schema && isListNullable(g.schema, c, e);
for (var h = Array(b.length), l = 0, m = b.length; l < m; l++) {
var k = resolveLink(a, b[l], c, e, d, void 0 !== f ? f[l] : void 0);
if (void 0 !== k || g) {
h[l] = void 0 !== k ? k : null;
g = g.schema && isListNullable(g.schema, c, d);
for (var h = Array(b.length), k = 0, n = b.length; k < n; k++) {
var m = resolveLink(a, b[k], c, d, e, void 0 !== f ? f[k] : void 0);
if (void 0 !== m || g) {
h[k] = void 0 !== m ? m : null;
} else {

@@ -811,9 +860,9 @@ return;

}
return null === b ? null : readSelection(a, b, d, void 0 === f ? makeDict() : f);
return null === b ? null : readSelection(a, b, e, void 0 === f ? makeDict() : f);
}, isDataOrKey = function(a) {
return "string" == typeof a || "object" == typeof a && "string" == typeof a.__typename;
}, addCacheOutcome = function(a, b) {
return _rollupPluginBabelHelpers._extends(_rollupPluginBabelHelpers._extends({}, a), {
context: _rollupPluginBabelHelpers._extends(_rollupPluginBabelHelpers._extends({}, a.context), {
meta: _rollupPluginBabelHelpers._extends(_rollupPluginBabelHelpers._extends({}, a.context.meta), {
return _rollupPluginBabelHelpers._extends({}, a, {
context: _rollupPluginBabelHelpers._extends({}, a.context, {
meta: _rollupPluginBabelHelpers._extends({}, a.context.meta, {
cacheOutcome: b

@@ -824,3 +873,3 @@ })

}, addTypeNames = function(a) {
return _rollupPluginBabelHelpers._extends(_rollupPluginBabelHelpers._extends({}, a), {
return _rollupPluginBabelHelpers._extends({}, a, {
query: core.formatDocument(a.query)

@@ -835,4 +884,4 @@ });

}, toRequestPolicy = function(a, b) {
return _rollupPluginBabelHelpers._extends(_rollupPluginBabelHelpers._extends({}, a), {
context: _rollupPluginBabelHelpers._extends(_rollupPluginBabelHelpers._extends({}, a.context), {
return _rollupPluginBabelHelpers._extends({}, a, {
context: _rollupPluginBabelHelpers._extends({}, a.context, {
requestPolicy: b

@@ -843,7 +892,7 @@ })

function _ref3(a) {
function _ref3$1(a) {
return isCacheableQuery(a);
}
function _ref4(a) {
function _ref4$1(a) {
return addCacheOutcome(a.operation, a.outcome);

@@ -861,34 +910,38 @@ }

function _ref8(a) {
return "cache-only" !== a.context.requestPolicy;
}
function _ref9(a) {
return !isCacheableQuery(a);
}
var extractSelectionsFromQuery = function(a, b) {
var c = [], e = [], d = new graphql.TypeInfo(a);
graphql.visit(b, graphql.visitWithTypeInfo(d, {
Field: function(a) {
if (a.selectionSet) {
var b = getTypeName(d);
e.push({
kind: graphql.Kind.FRAGMENT_DEFINITION,
typeCondition: {
kind: graphql.Kind.NAMED_TYPE,
name: nameNode(b)
},
name: nameNode(b + "_PopulateFragment_"),
selectionSet: a.selectionSet
});
}
},
FragmentDefinition: function(a) {
c.push(a);
function _ref$1(a) {
for (var b = arguments, c = 1; c < arguments.length; c++) {
var d, e = b[c];
for (d in e) {
Object.prototype.hasOwnProperty.call(e, d) && (a[d] = e[d]);
}
}));
return [ c, e ];
};
}
return a;
}
function _ref2$1(a) {
return "populate" !== getName(a);
function l() {
return (l = Object.assign || _ref$1).apply(this, arguments);
}
function _ref4$1(a, b) {
function r(a) {
return graphql.isWrappingType(a) ? r(a.ofType) : a || null;
}
var v = new Set, w = [];
function x() {
return w.length ? "\n(Caused At: " + w.join(", ") + ")" : "";
}
function A(a) {
return "populate" !== a.name.value;
}
function D(a, b) {
"FragmentDefinition" === b.kind && a.add(b.name.value);

@@ -898,16 +951,16 @@ return a;

var addFragmentsToQuery = function(a, b, c, e) {
function d(a, b) {
function E(a, b, c, d) {
function e(a, b) {
if (!(b = c[b.name])) {
return a;
}
for (var d = 0, f = b.length; d < f; d++) {
for (var k = b[d].fragment, m = getName(k), t = getUsedFragments(k), p = 0, v = t.length; p < v; p++) {
var w = t[p];
l.has(w) || (g[w] = e[w]);
for (var e = 0, f = b.length; e < f; e++) {
for (var n = b[e].fragment, m = n.name.value, B = F(n), q = 0, G = B.length; q < G; q++) {
var H = B[q];
k.has(H) || (g[H] = d[H]);
}
h[m] = k;
h[m] = n;
a.push({
kind: graphql.Kind.FRAGMENT_SPREAD,
name: nameNode(m)
name: z(m)
});

@@ -917,3 +970,3 @@ }

}
var f = new graphql.TypeInfo(a), g = makeDict(), h = makeDict(), l = new Set;
var f = new graphql.TypeInfo(a), g = Object.create(null), h = Object.create(null), k = new Set;
return graphql.visit(b, graphql.visitWithTypeInfo(f, {

@@ -923,14 +976,19 @@ Field: {

if (b.directives) {
var c = b.directives.filter(_ref2$1);
var c = b.directives.filter(A);
if (c.length !== b.directives.length) {
var e = getTypes(a, f).reduce(d, []), g = getSelectionSet(b);
e = 0 !== g.length + e.length ? e.concat(g) : [ {
var d = r(f.getType());
graphql.isCompositeType(d) ? d = graphql.isAbstractType(d) ? a.getPossibleTypes(d) : [ d ] : ("production" !== process.env.NODE_ENV && (v.has("Invalid type: The type ` + type + ` is used with @populate but does not exist.") || (console.warn("Invalid type: The type ` + type + ` is used with @populate but does not exist." + x() + "\nhttps://github.com/FormidableLabs/urql/tree/master/exchanges/graphcache/help.md#17"),
v.add("Invalid type: The type ` + type + ` is used with @populate but does not exist."))),
d = []);
d = d.reduce(e, []);
var g = void 0 !== b.selectionSet ? b.selectionSet.selections : [];
d = 0 !== g.length + d.length ? d.concat(g) : [ {
kind: graphql.Kind.FIELD,
name: nameNode("__typename")
name: z("__typename")
} ];
return _rollupPluginBabelHelpers._extends(_rollupPluginBabelHelpers._extends({}, b), {
return l({}, b, {
directives: c,
selectionSet: {
kind: graphql.Kind.SELECTION_SET,
selections: e
selections: d
}

@@ -944,14 +1002,14 @@ });

enter: function(a) {
a.definitions.reduce(_ref4$1, l);
a.definitions.reduce(D, k);
},
leave: function(a) {
var c, b = [].concat(a.definitions);
for (c in h) {
b.push(h[c]);
var b, c = [].concat(a.definitions);
for (b in h) {
c.push(h[b]);
}
for (var d in g) {
b.push(g[d]);
c.push(g[d]);
}
return _rollupPluginBabelHelpers._extends(_rollupPluginBabelHelpers._extends({}, a), {
definitions: b
return l({}, a, {
definitions: c
});

@@ -961,3 +1019,5 @@ }

}));
}, nameNode = function(a) {
}
function z(a) {
return {

@@ -967,18 +1027,13 @@ kind: graphql.Kind.NAME,

};
}, getTypes = function(a, b) {
b = unwrapType(b.getType());
return graphql.isCompositeType(b) ? graphql.isAbstractType(b) ? a.getPossibleTypes(b) : [ b ] : ("production" !== process.env.NODE_ENV && warn("Invalid type: The type ` + type + ` is used with @populate but does not exist.", 17),
[]);
}, getTypeName = function(a) {
invariant((a = unwrapType(a.getType())) && !graphql.isAbstractType(a), "production" !== process.env.NODE_ENV ? "Invalid TypeInfo state: Found no flat schema type when one was expected." : "", 18);
return a.toString();
}, getUsedFragments = function(a) {
}
function F(a) {
var b = [];
graphql.visit(a, {
FragmentSpread: function(a) {
b.push(getName(a));
b.push(a.name.value);
}
});
return b;
};
}

@@ -989,4 +1044,4 @@ exports.Store = Store;

return function(b) {
function e(a) {
var b = a.operation, c = a.outcome, d = getRequestPolicy(b);
function d(a) {
var b = a.operation, c = a.outcome, e = getRequestPolicy(b);
a = {

@@ -998,3 +1053,3 @@ operation: addCacheOutcome(b, c),

};
if ("cache-and-network" === d || "cache-first" === d && "partial" === c) {
if ("cache-and-network" === e || "cache-first" === e && "partial" === c) {
a.stale = !0, f.reexecuteOperation(toRequestPolicy(b, "network-only"));

@@ -1004,3 +1059,3 @@ }

}
var d = b.forward, f = b.client;
var e = b.forward, f = b.client;
a || (a = {});

@@ -1010,15 +1065,15 @@ var g = new Store(a.schema, a.resolvers, a.updates, a.optimistic, a.keys);

var h = a.storage;
var l = h.read().then((function c(a) {
var k = h.read().then((function c(a) {
!function(a, b, c) {
initDataState(a, 0);
for (var e in c) {
var d = e.indexOf("."), f = e.slice(2, d);
d = e.slice(d + 1);
switch (e.charCodeAt(0)) {
initDataState(a, null);
for (var d in c) {
var e = d.indexOf("."), f = d.slice(2, e);
e = d.slice(e + 1);
switch (d.charCodeAt(0)) {
case 108:
writeLink(f, d, c[e]);
writeLink(f, e, c[d]);
break;
case 114:
writeRecord(f, d, c[e]);
writeRecord(f, e, c[d]);
}

@@ -1031,9 +1086,9 @@ }

}
var m = new Map, k = new Map, n = makeDict(), q = function(a, b) {
var n = new Map, m = new Map, p = makeDict(), t = function(a, b) {
void 0 !== b && b.forEach((function c(b) {
var c = n[b];
var c = p[b];
if (void 0 !== c) {
n[b] = [];
p[b] = [];
b = 0;
for (var d = c.length; b < d; b++) {
for (var e = c.length; b < e; b++) {
a.add(c[b]);

@@ -1043,10 +1098,15 @@ }

}));
}, u = function(a, b) {
}, C = function(a, b) {
b.forEach((function(b) {
if (b !== a.key) {
var c = k.get(b);
void 0 !== c && (k.delete(b), f.reexecuteOperation(toRequestPolicy(c, "cache-first")));
var c = m.get(b);
void 0 !== c && (m.delete(b), f.reexecuteOperation(toRequestPolicy(c, "cache-first")));
}
}));
}, r = function(a) {
}, u = 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 && clearLayer(g.data, a.key);
}, B = function(a) {
if (function(a) {

@@ -1058,32 +1118,26 @@ return function(a) {

var b = a.key, c = writeOptimistic(g, a, b).dependencies;
0 !== c.size && (m.set(b, c), b = new Set, q(b, c), u(a, b));
0 !== c.size && (n.set(b, c), b = new Set, t(b, c), C(a, b));
}
}, t = function(a, b) {
}, q = function(a, b) {
b.forEach((function(b) {
(n[b] || (n[b] = [])).push(a.key);
k.has(a.key) || k.set(a.key, "network-only" === getRequestPolicy(a) ? toRequestPolicy(a, "cache-and-network") : a);
(p[b] || (p[b] = [])).push(a.key);
m.has(a.key) || m.set(a.key, "network-only" === getRequestPolicy(a) ? toRequestPolicy(a, "cache-and-network") : a);
}));
}, p = function(a) {
var b = query(g, a), c = b.data, d = b.dependencies;
}, G = function(a) {
var b = query(g, a), c = b.data, e = b.dependencies;
b = b.partial;
null === c ? d = "miss" : (t(a, d), d = b && "cache-only" !== getRequestPolicy(a) ? "partial" : "hit");
null === c ? e = "miss" : (q(a, e), e = b && "cache-only" !== getRequestPolicy(a) ? "partial" : "hit");
return {
outcome: d,
outcome: e,
operation: a,
data: c
};
}, v = function(a) {
var b = a.operation, c = a.error, d = a.extensions, e = isQueryOperation(b), f = a.data, h = b.key, k = new Set;
q(k, m.get(h));
m.delete(h);
!function(a, b) {
delete a.refLock[b];
clearOptimisticNodes(a.records, b);
clearOptimisticNodes(a.links, b);
}(g.data, h);
}, H = function(a) {
var b = a.operation, c = a.error, e = a.extensions, d = isQueryOperation(b), f = a.data, h = b.key, p = new Set;
d || (t(p, n.get(h)), n.delete(h), clearLayer(g.data, h));
if (null != f) {
var l = write(g, b, f).dependencies;
if (e) {
var m = write(g, b, f, h).dependencies;
if (d) {
f = (h = query(g, b)).data;
var n = h.dependencies;
var k = h.dependencies;
} else {

@@ -1093,10 +1147,10 @@ f = query(g, b, f).data;

}
q(k, l);
e && q(k, n);
u(a.operation, k);
e && void 0 !== n && t(a.operation, n);
t(p, m);
d && t(p, k);
C(a.operation, p);
d && void 0 !== k && q(a.operation, k);
return {
data: f,
error: c,
extensions: d,
extensions: e,
operation: b

@@ -1107,8 +1161,8 @@ };

a = wonka.share(a);
var b = l ? wonka.mergeMap(wonka.fromArray)(wonka.take(1)(wonka.buffer(wonka.fromPromise(l))(a))) : wonka.empty;
a = wonka.share(wonka.tap(r)(wonka.map(addTypeNames)(wonka.concat([ b, a ]))));
var c = wonka.share(wonka.map(p)(wonka.filter(_ref3)(a)));
b = wonka.map(_ref4)(wonka.filter(_ref5)(c));
c = wonka.map(e)(wonka.filter(_ref7)(c));
a = wonka.map(v)(d(wonka.merge([ wonka.filter(_ref8)(a), b ])));
var b = k ? wonka.mergeMap(wonka.fromArray)(wonka.take(1)(wonka.buffer(wonka.fromPromise(k))(a))) : wonka.empty;
a = wonka.share(wonka.tap(B)(wonka.map(addTypeNames)(wonka.concat([ b, a ]))));
var c = wonka.share(wonka.map(G)(wonka.filter(_ref3$1)(a)));
b = wonka.map(_ref4$1)(wonka.filter(_ref5)(c));
c = wonka.map(d)(wonka.filter(_ref7)(c));
a = wonka.map(H)(e(wonka.tap(u)(wonka.filter(_ref8)(wonka.merge([ wonka.filter(_ref9)(a), b ])))));
return wonka.merge([ a, c ]);

@@ -1123,33 +1177,50 @@ };

exports.populateExchange = function(a) {
exports.populateExchange = function populateExchange(a) {
var b = a.schema;
return function(a) {
function c(a) {
return h.has(a.key);
"teardown" === a.operationName && m.delete(a.key);
}
var d = a.forward, f = graphql.buildClientSchema(b), g = new Set, h = new Set, l = makeDict(), m = makeDict(), k = function(a) {
if ("mutation" !== a.operationName) {
return a;
}
var d, b = makeDict();
for (d in m) {
b[d] = m[d].filter(c);
}
return _rollupPluginBabelHelpers._extends(_rollupPluginBabelHelpers._extends({}, a), {
query: addFragmentsToQuery(f, a.query, b, l)
});
}, n = function(a) {
function e(a) {
var b = a.key, c = a.query;
if ("query" === a.operationName && (h.add(b), !g.has(b))) {
g.add(b);
c = (a = extractSelectionsFromQuery(f, c))[0];
if ("query" === a.operationName && (m.add(b), !n.has(b))) {
n.add(b);
c = (a = function y(a, b) {
var c = [], d = [], e = new graphql.TypeInfo(a);
graphql.visit(b, graphql.visitWithTypeInfo(e, {
Field: function(a) {
if (a.selectionSet) {
var b = r(e.getType());
if (!b || graphql.isAbstractType(b)) {
throw a = ("production" !== process.env.NODE_ENV ? "Invalid TypeInfo state: Found no flat schema type when one was expected." : "") || "Minfied Error #18\n",
"production" !== process.env.NODE_ENV && (a += x()), (a = Error(a + "\nhttps://github.com/FormidableLabs/urql/tree/master/exchanges/graphcache/help.md#18")).name = "Graphcache Error",
a;
}
b = b.toString();
d.push({
kind: graphql.Kind.FRAGMENT_DEFINITION,
typeCondition: {
kind: graphql.Kind.NAMED_TYPE,
name: z(b)
},
name: z(b + "_PopulateFragment_"),
selectionSet: a.selectionSet
});
}
},
FragmentDefinition: function(a) {
c.push(a);
}
}));
return [ c, d ];
}(k, c))[0];
a = a[1];
for (var d = 0, e = c.length; d < e; d++) {
var k = c[d];
l[getName(k)] = k;
var f = c[d];
p[f.name.value] = f;
}
c = 0;
for (d = a.length; c < d; c++) {
k = getName((e = a[c]).typeCondition), k = m[k] || (m[k] = []), e.name.value += k.length,
k.push({
f = t[f = (e = a[c]).typeCondition.name.value] || (t[f] = []), e.name.value += f.length,
f.push({
key: b,

@@ -1160,7 +1231,21 @@ fragment: e

}
}, q = function(a) {
"teardown" === a.operationName && h.delete(a.key);
};
}
function f(a) {
if ("mutation" !== a.operationName) {
return a;
}
var b, c = Object.create(null);
for (b in t) {
c[b] = t[b].filter(g);
}
return l({}, a, {
query: E(k, a.query, c, p)
});
}
function g(a) {
return m.has(a.key);
}
var h = a.forward, k = graphql.buildClientSchema(b), n = new Set, m = new Set, p = Object.create(null), t = Object.create(null);
return function(a) {
return d(wonka.map(k)(wonka.tap(q)(wonka.tap(n)(a))));
return h(wonka.map(f)(wonka.tap(c)(wonka.tap(e)(a))));
};

@@ -1167,0 +1252,0 @@ };

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

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

@@ -5,3 +5,3 @@ import { share, mergeMap, fromArray, take, buffer, fromPromise, empty, tap, map, concat, filter, merge } from "wonka";

import { Kind, isWrappingType, valueFromASTUntyped, isNullableType, isNonNullType, isListType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, buildClientSchema, visit, visitWithTypeInfo, TypeInfo, isCompositeType, isAbstractType } from "graphql";
import { Kind, valueFromASTUntyped, isNullableType, isNonNullType, isListType, GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, buildClientSchema, visit, visitWithTypeInfo, isWrappingType, isCompositeType, isAbstractType, TypeInfo } from "graphql";

@@ -11,10 +11,6 @@ import { _ as _extends } from "./08a6be1c.esm.js";

function p(a) {
return a.name.value;
return void 0 !== a.alias ? a.alias.value : a.name.value;
}
function r(a) {
return void 0 !== a.alias ? a.alias.value : p(a);
}
function u(a) {
return void 0 !== a.selectionSet ? a.selectionSet.selections : [];

@@ -24,20 +20,41 @@ }

function aa(a) {
return void 0 !== (a = a.typeCondition) ? p(a) : null;
return void 0 !== (a = a.typeCondition) ? a.name.value : null;
}
function ba(a) {
return isWrappingType(a) ? ba(a.ofType) : a || null;
var ba = new Set, w = [];
function x(a, b) {
var c = "";
b.kind === Kind.INLINE_FRAGMENT ? c = a ? 'Inline Fragment on "' + a + '"' : "Inline Fragment" : b.kind === Kind.OPERATION_DEFINITION ? c = (b.name ? '"' + b.name.value + '"' : "Unnamed") + " " + b.operation : b.kind === Kind.FRAGMENT_DEFINITION && (c = '"' + b.name.value + '" Fragment');
c && w.push(c);
}
function x() {
function ca() {
return w.length ? "\n(Caused At: " + w.join(", ") + ")" : "";
}
function y(a, b, c) {
if (!a) {
throw a = b || "Minfied Error #" + c + "\n", "production" !== process.env.NODE_ENV && (a += ca()),
(c = Error(a + "\nhttps://github.com/FormidableLabs/urql/tree/master/exchanges/graphcache/help.md#" + c)).name = "Graphcache Error",
c;
}
}
function z(a, b) {
ba.has(a) || (console.warn(a + ca() + "\nhttps://github.com/FormidableLabs/urql/tree/master/exchanges/graphcache/help.md#" + b),
ba.add(a));
}
function C() {
return Object.create(null);
}
function y(a, b) {
function D(a, b) {
if (void 0 === a.arguments || 0 === a.arguments.length) {
return null;
}
for (var c = x(), d = 0, e = 0, f = a.arguments.length; e < f; e++) {
for (var c = C(), d = 0, e = 0, f = a.arguments.length; e < f; e++) {
var g = a.arguments[e], h = valueFromASTUntyped(g.value, b);
null != h && (c[p(g)] = h, d++);
null != h && (c[g.name.value] = h, d++);
}

@@ -47,3 +64,3 @@ return 0 < d ? c : null;

function z(a, b) {
function E(a, b) {
if (void 0 === a.variableDefinitions) {

@@ -54,3 +71,3 @@ return {};

return a.variableDefinitions.reduce((function(a, b) {
var d = p(b.variable), e = c[d];
var d = b.variable.name.value, e = c[d];
if (void 0 === e) {

@@ -65,57 +82,32 @@ if (void 0 !== b.defaultValue) {

return a;
}), x());
}), C());
}
var ca = new Set, B = [];
function E(a, b) {
var c = "";
b.kind === Kind.INLINE_FRAGMENT ? c = a ? 'Inline Fragment on "' + a + '"' : "Inline Fragment" : b.kind === Kind.OPERATION_DEFINITION ? c = (b.name ? '"' + b.name.value + '"' : "Unnamed") + " " + b.operation : b.kind === Kind.FRAGMENT_DEFINITION && (c = '"' + b.name.value + '" Fragment');
c && B.push(c);
function da(a) {
return a.kind === Kind.FRAGMENT_DEFINITION;
}
function da() {
return B.length ? "\n(Caused At: " + B.join(", ") + ")" : "";
}
function F(a, b, c) {
if (!a) {
throw a = b || "Minfied Error #" + c + "\n", "production" !== process.env.NODE_ENV && (a += da()),
(c = Error(a + "\nhttps://github.com/FormidableLabs/urql-exchange-graphcache/blob/master/docs/help.md#" + c)).name = "Graphcache Error",
c;
}
}
function G(a, b) {
ca.has(a) || (console.warn(a + da() + "\nhttps://github.com/FormidableLabs/urql-exchange-graphcache/blob/master/docs/help.md#" + b),
ca.add(a));
}
function ea(a) {
return a.kind === Kind.FRAGMENT_DEFINITION;
}
function fa(a) {
return a.kind === Kind.OPERATION_DEFINITION;
}
function H(a) {
F(!!(a = a.definitions.find(fa)), "production" !== process.env.NODE_ENV ? "Invalid GraphQL document: All GraphQL documents must contain an OperationDefinitionnode for a query, subscription, or mutation." : "", 1);
function G(a) {
y(!!(a = a.definitions.find(ea)), "production" !== process.env.NODE_ENV ? "Invalid GraphQL document: All GraphQL documents must contain an OperationDefinitionnode for a query, subscription, or mutation." : "", 1);
return a;
}
function ha(a, b) {
a[p(b)] = b;
function fa(a, b) {
a[b.name.value] = b;
return a;
}
function I(a) {
return a.definitions.filter(ea).reduce(ha, {});
function H(a) {
return a.definitions.filter(da).reduce(fa, {});
}
function ia(a, b, c) {
function ha(a, b, c) {
return void 0 === (a = J(a, b, c)) ? !1 : isNullableType(a.type);
}
function ja(a, b, c) {
function ia(a, b, c) {
if (void 0 === (a = J(a, b, c))) {

@@ -129,5 +121,5 @@ return !1;

function J(a, b, c) {
ka(a = a.getType(b), b);
ja(a = a.getType(b), b);
if (void 0 === (a = a.getFields()[c])) {
"production" !== process.env.NODE_ENV && G("Invalid field: The field `" + c + "` does not exist on `" + b + "`, but the GraphQL document expects it to exist.\nTraversal will continue, however this may lead to undefined behavior!", 4);
"production" !== process.env.NODE_ENV && z("Invalid field: The field `" + c + "` does not exist on `" + b + "`, but the GraphQL document expects it to exist.\nTraversal will continue, however this may lead to undefined behavior!", 4);
} else {

@@ -138,4 +130,4 @@ return a;

function ka(a, b) {
F(a instanceof 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 ja(a, b) {
y(a instanceof 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);
}

@@ -147,3 +139,3 @@

function la(a) {
function ka(a) {
var b = a.indexOf("(");

@@ -161,64 +153,69 @@ return -1 < b ? {

var ma = "production" === process.env.NODE_ENV && "undefined" != typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : function(a) {
var la = "production" === process.env.NODE_ENV && "undefined" != typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : function(a) {
return setTimeout(a, 0);
}, L = null, M = null, N = null;
function na() {
return {
optimistic: x(),
base: new Map,
keys: []
};
}
function O(a, b) {
function O(a, b, c) {
L = a;
M = new Set;
N = b;
"production" !== process.env.NODE_ENV && (B.length = 0);
"production" !== process.env.NODE_ENV && (w.length = 0);
b ? c || 1 < a.commutativeKeys.size && a.commutativeKeys.has(b) ? (N = b, -1 === a.optimisticOrder.indexOf(b) && a.optimisticOrder.unshift(b),
a.refLock[b] || (a.refLock[b] = C(), a.links.optimistic[b] = new Map, a.records.optimistic[b] = new Map)) : (N = null,
P(a, b)) : N = null;
}
function P() {
var c = L;
!c.gcScheduled && 0 < c.gcBatch.size && (c.gcScheduled = !0, ma((function a() {
oa(c);
function Q() {
var c = L, d = N;
N = null;
if (d && c.commutativeKeys.has(d)) {
var e = c.optimisticOrder.length - c.commutativeKeys.size;
if (c.optimisticOrder[c.optimisticOrder.length - 1] === d) {
d = [];
for (var f = c.optimisticOrder.length; e < f; e++) {
var g = c.optimisticOrder[e];
if (!c.refLock[g]) {
break;
}
d.unshift(g);
}
f = 0;
for (e = d.length; f < e; f++) {
na(d[f]);
}
}
}
M = L = null;
"production" !== process.env.NODE_ENV && (w.length = 0);
!c.gcScheduled && 0 < c.gcBatch.size && (c.gcScheduled = !0, la((function a() {
ma(c);
})));
c.storage && !c.persistenceScheduled && (c.persistenceScheduled = !0, ma((function b() {
c.storage && !c.persistenceScheduled && (c.persistenceScheduled = !0, la((function b() {
c.storage.write(c.persistenceBatch);
c.persistenceScheduled = !1;
c.persistenceBatch = x();
c.persistenceBatch = C();
})));
N = M = L = null;
"production" !== process.env.NODE_ENV && (B.length = 0);
}
function pa() {
F(null !== M, "production" !== process.env.NODE_ENV ? "Invalid Cache call: The cache may only be accessed or mutated duringoperations like write or query, or as part of its resolvers, updaters, or optimistic configs." : "", 2);
function oa() {
y(null !== M, "production" !== process.env.NODE_ENV ? "Invalid Cache call: The cache may only be accessed or mutated duringoperations like write or query, or as part of its resolvers, updaters, or optimistic configs." : "", 2);
return M;
}
function ra(a, b, c, d) {
N ? (void 0 === a.optimistic[N] && (a.optimistic[N] = new Map, a.keys.unshift(N)),
a = a.optimistic[N]) : a = a.base;
var e = a.get(b);
void 0 === e && a.set(b, e = x());
function qa(a, b, c, d) {
var e = (a = N ? a.optimistic[N] : a.base).get(b);
void 0 === e && a.set(b, e = C());
void 0 !== d || N ? e[c] = d : delete e[c];
}
function sa(a, b, c) {
for (var d = 0, e = a.keys.length; d < e; d++) {
var f = a.optimistic[a.keys[d]].get(b);
if (void 0 !== f && c in f) {
return f[c];
function ra(a, b, c) {
for (var d, e = 0, f = L.optimisticOrder.length; e < f; e++) {
var g = a.optimistic[L.optimisticOrder[e]];
if (g && void 0 !== (d = g.get(b)) && c in d) {
return d[c];
}
}
return void 0 !== (a = a.base.get(b)) ? a[c] : void 0;
return void 0 !== (d = a.base.get(b)) ? d[c] : void 0;
}
function ta(a, b) {
var c = a.keys.indexOf(b);
-1 < c && (delete a.optimistic[b], a.keys.splice(c, 1));
}
function ua(a, b, c, d) {
function sa(a, b, c, d) {
var e = void 0 !== b[c] ? b[c] : 0;

@@ -229,9 +226,9 @@ b = b[c] = e + d | 0;

function va(a, b, c, d) {
function ta(a, b, c, d) {
if ("string" == typeof c) {
ua(a, b, c, d);
sa(a, b, c, d);
} else if (Array.isArray(c)) {
for (var e = 0, f = c.length; e < f; e++) {
var g = c[e];
g && ua(a, b, g, d);
g && sa(a, b, g, d);
}

@@ -241,6 +238,6 @@ }

function wa(a, b, c) {
function ua(a, b, c) {
if (void 0 !== c) {
for (var d in c) {
b.has(d) || (a.push(la(d)), b.add(d));
b.has(d) || (a.push(ka(d)), b.add(d));
}

@@ -250,10 +247,10 @@ }

function xa(a, b, c, d) {
wa(a, b, d.base.get(c));
for (var e = 0, f = d.keys.length; e < f; e++) {
wa(a, b, d.optimistic[d.keys[e]].get(c));
function va(a, b, c, d) {
ua(a, b, d.base.get(c));
for (var e = 0, f = L.optimisticOrder.length; e < f; e++) {
ua(a, b, d.optimistic[L.optimisticOrder[e]].get(c));
}
}
function oa(a) {
function ma(a) {
a.gcScheduled = !1;

@@ -279,3 +276,3 @@ a.gcBatch.forEach((function(b) {

for (var f in e) {
a.storage && (a.persistenceBatch["l|" + b + "." + f] = void 0), va(a.gcBatch, a.refCount, e[f], -1);
a.storage && (a.persistenceBatch["l|" + b + "." + f] = void 0), ta(a.gcBatch, a.refCount, e[f], -1);
}

@@ -289,26 +286,26 @@ }

function Q(a, b) {
function R(a, b) {
"__typename" !== b && (a !== L.queryRootKey ? M.add(a) : void 0 !== b && M.add(a + "." + b));
}
function R(a, b) {
Q(a, b);
return sa(L.records, a, b);
function S(a, b) {
R(a, b);
return ra(L.records, a, b);
}
function S(a, b) {
Q(a, b);
return sa(L.links, a, b);
function T(a, b) {
R(a, b);
return ra(L.links, a, b);
}
function T(a, b, c) {
Q(a, b);
ra(L.records, a, b, c);
function U(a, b, c) {
R(a, b);
qa(L.records, a, b, c);
L.storage && !N && (L.persistenceBatch["r|" + a + "." + b] = c);
}
function ya(a, b, c) {
function V(a, b, c) {
var d = L;
if (N) {
var e = d.refLock[N] || (d.refLock[N] = x());
var e = d.refLock[N] || (d.refLock[N] = C());
var f = d.links.optimistic[N];

@@ -322,9 +319,34 @@ } else {

f = void 0 !== (f = void 0 !== f ? f.get(a) : void 0) ? f[b] : null;
Q(a, b);
ra(d.links, a, b, c);
va(g, e, f, -1);
va(g, e, c, 1);
R(a, b);
qa(d.links, a, b, c);
ta(g, e, f, -1);
ta(g, e, c, 1);
}
function za(a, b, c, d) {
function P(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]);
}
function wa(a, b) {
for (var c in a) {
V(b, c, a[c]);
}
}
function xa(a, b) {
for (var c in a) {
U(b, c, a[c]);
}
}
function na(a) {
var b = L.links.optimistic[a];
b && b.forEach(wa);
(b = L.records.optimistic[a]) && b.forEach(xa);
P(L, a);
}
function ya(a, b, c, d) {
if (!b) {

@@ -337,13 +359,13 @@ return !1;

}
"production" !== process.env.NODE_ENV && G("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 !u(a).some((function(a) {
"production" !== process.env.NODE_ENV && z("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 !r(a).some((function(a) {
if (a.kind !== Kind.FIELD) {
return !1;
}
a = K(p(a), y(a, d));
return !(void 0 !== R(c, a) || void 0 !== S(c, a));
a = K(a.name.value, D(a, d));
return !(void 0 !== S(c, a) || void 0 !== T(c, a));
}));
}
function U(a, b, c, d) {
function W(a, b, c, d) {
this.typename = a;

@@ -356,3 +378,3 @@ this.entityKey = b;

U.prototype.next = function() {
W.prototype.next = function() {
for (;0 !== this.indexStack.length; ) {

@@ -369,4 +391,4 @@ var a = this.indexStack[this.indexStack.length - 1]++, b = this.selectionStack[this.selectionStack.length - 1];

for (var d = 0, e = c.length; d < e; d++) {
var f = c[d], g = p(f), h = "include" === g;
if ((h || "skip" === g) && (f = f.arguments ? f.arguments[0] : null) && "if" === p(f) && ("boolean" == typeof (f = valueFromASTUntyped(f.value, b)) || null === f)) {
var f = c[d], g = f.name.value, h = "include" === g;
if ((h || "skip" === g) && (f = f.arguments ? f.arguments[0] : null) && "if" === f.name.value && ("boolean" == typeof (f = valueFromASTUntyped(f.value, b)) || null === f)) {
b = h ? !!f : !f;

@@ -381,8 +403,8 @@ break a;

if (a.kind !== Kind.FIELD) {
void 0 !== (a = a.kind !== Kind.INLINE_FRAGMENT ? this.context.fragments[p(a)] : a) && ("production" !== process.env.NODE_ENV && E(this.typename, a),
void 0 !== (a = a.kind !== Kind.INLINE_FRAGMENT ? this.context.fragments[a.name.value] : a) && ("production" !== process.env.NODE_ENV && x(this.typename, a),
this.context.store.schema ? (b = this.context.store.schema, c = aa(a), (d = this.typename) && c ? d === c ? b = !0 : (e = b.getType(c),
h = b.getType(d), e instanceof GraphQLObjectType ? b = e === h : (F(e instanceof GraphQLInterfaceType || e instanceof GraphQLUnionType, "production" !== process.env.NODE_ENV ? "Invalid Abstract type: The type `" + c + "` 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),
ka(h, d), b = b.isPossibleType(e, h))) : b = !1) : b = za(a, this.typename, this.entityKey, this.context.variables),
b && (this.indexStack.push(0), this.selectionStack.push(u(a))));
} else if ("__typename" !== p(a)) {
h = b.getType(d), e instanceof GraphQLObjectType ? b = e === h : (y(e instanceof GraphQLInterfaceType || e instanceof GraphQLUnionType, "production" !== process.env.NODE_ENV ? "Invalid Abstract type: The type `" + c + "` 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),
ja(h, d), b = b.isPossibleType(e, h))) : b = !1) : b = ya(a, this.typename, this.entityKey, this.context.variables),
b && (this.indexStack.push(0), this.selectionStack.push(r(a))));
} else if ("__typename" !== a.name.value) {
return a;

@@ -395,17 +417,17 @@ }

function V(a) {
function X(a) {
return void 0 === a ? null : a;
}
function Aa(a, b, c) {
O(a.data, 0);
a = Ba(a, b, c);
P();
function za(a, b, c, d) {
O(a.data, d || null);
a = Aa(a, b, c);
Q();
return a;
}
function Ba(a, b, c) {
var d = H(b.query), e = {
dependencies: pa()
}, f = u(d), g = a.getRootKey(d.operation);
function Aa(a, b, c) {
var d = G(b.query), e = {
dependencies: oa()
}, f = r(d), g = a.getRootKey(d.operation);
a = {

@@ -417,7 +439,7 @@ parentTypeName: g,

store: a,
variables: z(d, b.variables),
fragments: I(b.query)
variables: E(d, b.variables),
fragments: H(b.query)
};
"production" !== process.env.NODE_ENV && E(g, d);
g === a.store.getRootKey("query") ? W(a, g, f, c) : Ca(a, g, f, c);
"production" !== process.env.NODE_ENV && x(g, d);
g === a.store.getRootKey("query") ? Ba(a, g, f, c) : Ca(a, g, f, c);
return e;

@@ -427,10 +449,10 @@ }

function Da(a, b, c) {
O(a.data, c);
var d = H(b.query);
O(a.data, c, !0);
var d = G(b.query);
c = {
dependencies: pa()
dependencies: oa()
};
var e = a.getRootKey("mutation"), f = a.getRootKey(d.operation);
F(f === e, "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 && E(f, d);
y(f === e, "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 && x(f, d);
a = {

@@ -441,21 +463,21 @@ parentTypeName: e,

fieldName: "",
variables: z(d, b.variables),
fragments: I(b.query),
variables: E(d, b.variables),
fragments: H(b.query),
store: a,
optimistic: !0
};
b = x();
d = new U(f, f, u(d), a);
b = C();
d = new W(f, f, r(d), a);
for (var g; void 0 !== (g = d.next()); ) {
if (void 0 !== g.selectionSet) {
var h = p(g), k = a.store.optimisticMutations[h];
var h = g.name.value, k = a.store.optimisticMutations[h];
if (void 0 !== k) {
a.fieldName = h;
Ea(a, V(k = k((f = y(g, a.variables)) || x(), a.store, a)), u(g));
Ea(a, X(k = k((f = D(g, a.variables)) || C(), a.store, a)), r(g));
b[h] = k;
void 0 !== (g = a.store.updates[e][h]) && g(b, f || x(), a.store, a);
void 0 !== (g = a.store.updates[e][h]) && g(b, f || C(), a.store, a);
}
}
}
P();
Q();
return c;

@@ -465,9 +487,9 @@ }

function Fa(a, b, c, d) {
b = I(b);
b = H(b);
var e = Object.keys(b);
if (void 0 === (e = b[e[0]])) {
return "production" !== process.env.NODE_ENV ? G("writeFragment(...) was called with an empty fragment.\nYou have to call it with at least one fragment in your GraphQL document.", 11) : void 0;
return "production" !== process.env.NODE_ENV ? z("writeFragment(...) was called with an empty fragment.\nYou have to call it with at least one fragment in your GraphQL document.", 11) : void 0;
}
var f = e.typeCondition.name.value;
c = _extends({
c = _extends({}, {
__typename: f

@@ -477,6 +499,6 @@ }, c);

if (!g) {
return "production" !== process.env.NODE_ENV ? G("Can't generate a key for writeFragment(...) data.\nYou have to pass an `id` or `_id` field or create a custom `keys` config for `" + f + "`.", 12) : void 0;
return "production" !== process.env.NODE_ENV ? z("Can't generate a key for writeFragment(...) data.\nYou have to pass an `id` or `_id` field or create a custom `keys` config for `" + f + "`.", 12) : void 0;
}
"production" !== process.env.NODE_ENV && E(f, e);
W({
"production" !== process.env.NODE_ENV && x(f, e);
Ba({
parentTypeName: f,

@@ -489,14 +511,14 @@ parentKey: g,

store: a
}, g, u(e), c);
}, g, r(e), c);
}
function W(a, b, c, d) {
function Ba(a, b, c, d) {
var e = b === a.store.getRootKey("query") ? b : d.__typename;
if ("string" == typeof e) {
T(b, "__typename", e);
c = new U(e, b, c, a);
U(b, "__typename", e);
c = new W(e, b, c, a);
for (var f; void 0 !== (f = c.next()); ) {
var g = p(f), h = y(f, a.variables);
var g = f.name.value, h = D(f, a.variables);
h = K(g, h);
var k = d[r(f)], n = b + "." + h;
var k = d[p(f)], m = b + "." + h;
if ("production" !== process.env.NODE_ENV) {

@@ -506,3 +528,3 @@ if (void 0 === k) {

f = void 0 === f.selectionSet ? "scalar (number, boolean, etc)" : "selection set";
"production" !== process.env.NODE_ENV && G("Invalid undefined: The field at `" + h + "` is `undefined`, but the GraphQL query expects a " + f + " for this field." + g, 13);
"production" !== process.env.NODE_ENV && z("Invalid undefined: The field at `" + h + "` is `undefined`, but the GraphQL query expects a " + f + " for this field." + g, 13);
continue;

@@ -513,3 +535,3 @@ } else {

}
void 0 === f.selectionSet ? T(b, h, k) : (g = V(k), ya(b, h, f = Ga(a, n, u(f), g)));
void 0 === f.selectionSet ? U(b, h, k) : (g = X(k), V(b, h, f = Ga(a, m, r(f), g)));
}

@@ -532,4 +554,4 @@ }

g = d.__typename;
void 0 !== a.store.keys[d.__typename] || null !== e || "string" != typeof g || g.endsWith("Connection") || g.endsWith("Edge") || "PageInfo" === g || "production" !== process.env.NODE_ENV && G("Invalid key: The GraphQL query at the field at `" + b + "` 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 `" + g + "`.\nEntities without keys will be embedded directly on the parent entity. If this is intentional, create a `keys` config for `" + g + "` that always returns null.", 15);
W(a, f, c, d);
void 0 !== a.store.keys[d.__typename] || null !== e || "string" != typeof g || g.endsWith("Connection") || g.endsWith("Edge") || "PageInfo" === g || "production" !== process.env.NODE_ENV && z("Invalid key: The GraphQL query at the field at `" + b + "` 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 `" + g + "`.\nEntities without keys will be embedded directly on the parent entity. If this is intentional, create a `keys` config for `" + g + "` that always returns null.", 15);
Ba(a, f, c, d);
return f;

@@ -540,12 +562,12 @@ }

var e = b === a.store.getRootKey("mutation") || b === a.store.getRootKey("subscription");
c = new U(b, b, c, a);
c = new W(b, b, c, a);
for (var f; void 0 !== (f = c.next()); ) {
var g = p(f), h = y(f, a.variables);
var g = f.name.value, h = D(f, a.variables);
var k = K(g, h);
k = b + "." + k;
if (void 0 !== f.selectionSet) {
Ea(a, V(d[r(f)]), u(f));
Ea(a, X(d[p(f)]), r(f));
}
e && (a.parentTypeName = b, a.parentKey = b, a.parentFieldKey = k, a.fieldName = g,
void 0 !== (f = a.store.updates[b][g]) && f(d, h || x(), a.store, a));
void 0 !== (f = a.store.updates[b][g]) && f(d, h || C(), a.store, a));
}

@@ -561,10 +583,10 @@ }

}
null !== b && (null !== (d = a.store.keyOfEntity(b)) ? W(a, d, c, b) : Ca(a, b.__typename, c, b));
null !== b && (null !== (d = a.store.keyOfEntity(b)) ? Ba(a, d, c, b) : Ca(a, b.__typename, c, b));
}
function X(a, b, c, d, e) {
function Y(a, b, c, d, e) {
var g, f = this;
this.gcScheduled = !1;
this.gc = function() {
oa(f.data);
ma(f.data);
f.gcScheduled = !1;

@@ -595,13 +617,21 @@ };

});
this.data = function qa(a) {
this.data = function pa(a) {
return {
persistenceScheduled: !1,
persistenceBatch: x(),
persistenceBatch: C(),
gcScheduled: !1,
queryRootKey: a,
gcBatch: new Set,
refCount: x(),
refLock: x(),
links: na(),
records: na(),
refCount: C(),
refLock: C(),
links: {
optimistic: C(),
base: new Map
},
records: {
optimistic: C(),
base: new Map
},
commutativeKeys: new Set,
optimisticOrder: [],
storage: null

@@ -612,7 +642,7 @@ };

X.prototype.getRootKey = function(a) {
Y.prototype.getRootKey = function(a) {
return this.rootFields[a];
};
X.prototype.keyOfEntity = function(a) {
Y.prototype.keyOfEntity = function(a) {
var b = a.__typename, c = a.id, d = a._id;

@@ -630,32 +660,32 @@ if (!b) {

X.prototype.resolveFieldByKey = function(a, b) {
Y.prototype.resolveFieldByKey = function(a, b) {
if (null === (a = null !== a && "string" != typeof a ? this.keyOfEntity(a) : a)) {
return null;
}
var c = R(a, b);
return void 0 !== c ? c : (b = S(a, b)) ? b : null;
var c = S(a, b);
return void 0 !== c ? c : (b = T(a, b)) ? b : null;
};
X.prototype.resolve = function(a, b, c) {
Y.prototype.resolve = function(a, b, c) {
return this.resolveFieldByKey(a, K(b, c));
};
X.prototype.invalidateQuery = function(a, b) {
Y.prototype.invalidateQuery = function(a, b) {
!function Ha(a, b, c) {
if ("Query" !== b) {
var d = R(b, "__typename");
var d = S(b, "__typename");
if ("string" != typeof d) {
return;
}
T(b, "__typename", void 0);
U(b, "__typename", void 0);
} else {
d = b;
}
c = new U(d, b, c, a);
c = new W(d, b, c, a);
for (var e; void 0 !== (e = c.next()); ) {
var f = p(e), g = K(f, y(e, a.variables));
var f = e.name.value, g = K(f, D(e, a.variables));
"production" !== process.env.NODE_ENV && a.store.schema && d && J(a.store.schema, d, f);
if (void 0 === e.selectionSet) {
T(b, g, void 0);
} else if (e = u(e), f = S(b, g), ya(b, g, void 0), T(b, g, void 0), Array.isArray(f)) {
U(b, g, void 0);
} else if (e = r(e), f = T(b, g), V(b, g, void 0), U(b, g, void 0), Array.isArray(f)) {
g = 0;

@@ -671,14 +701,24 @@ for (var h = f.length; g < h; g++) {

}(b = {
variables: z(a = H((b = createRequest(a, b)).query), b.variables),
fragments: I(b.query),
variables: E(a = G((b = createRequest(a, b)).query), b.variables),
fragments: H(b.query),
store: this
}, b.store.getRootKey("query"), u(a));
}, b.store.getRootKey("query"), r(a));
};
X.prototype.inspectFields = function(a) {
Y.prototype.invalidate = function(a) {
var b = "string" == typeof a ? a : this.keyOfEntity(a);
y(b, "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);
a = 0;
for (var c = this.inspectFields(b); a < c.length; a += 1) {
var d = c[a];
T(b, d.fieldKey) ? V(b, d.fieldKey, void 0) : U(b, d.fieldKey, void 0);
}
};
Y.prototype.inspectFields = function(a) {
if (null !== (a = null !== a && "string" != typeof a ? this.keyOfEntity(a) : a)) {
var b = L.links, c = L.records, d = [], e = new Set;
Q(a);
xa(d, e, a, b);
xa(d, e, a, c);
R(a);
va(d, e, a, b);
va(d, e, a, c);
a = d;

@@ -691,16 +731,16 @@ } else {

X.prototype.updateQuery = function(a, b) {
Y.prototype.updateQuery = function(a, b) {
a = createRequest(a.query, a.variables);
null !== (b = b(this.readQuery(a))) && Ba(this, a, b);
null !== (b = b(this.readQuery(a))) && Aa(this, a, b);
};
X.prototype.readQuery = function(a) {
Y.prototype.readQuery = function(a) {
return Ia(this, createRequest(a.query, a.variables)).data;
};
X.prototype.readFragment = function(a, b, c) {
a = I(a);
Y.prototype.readFragment = function(a, b, c) {
a = H(a);
var d = Object.keys(a);
if (void 0 === (d = a[d[0]])) {
"production" !== process.env.NODE_ENV && G("readFragment(...) was called with an empty fragment.\nYou have to call it with at least one fragment in your GraphQL document.", 6),
"production" !== process.env.NODE_ENV && z("readFragment(...) was called with an empty fragment.\nYou have to call it with at least one fragment in your GraphQL document.", 6),
c = null;

@@ -710,5 +750,5 @@ } else {

"string" == typeof b || b.__typename || (b.__typename = e);
(b = "string" != typeof b ? this.keyOfEntity(_extends({
(b = "string" != typeof b ? this.keyOfEntity(_extends({}, {
__typename: e
}, b)) : b) ? ("production" !== process.env.NODE_ENV && E(e, d), c = Y({
}, b)) : b) ? ("production" !== process.env.NODE_ENV && x(e, d), c = Z({
parentTypeName: e,

@@ -722,3 +762,3 @@ parentKey: b,

store: this
}, b, u(d), x()) || null) : ("production" !== process.env.NODE_ENV && G("Can't generate a key for readFragment(...).\nYou have to pass an `id` or `_id` field or create a custom `keys` config for `" + e + "`.", 7),
}, b, r(d), C()) || null) : ("production" !== process.env.NODE_ENV && z("Can't generate a key for readFragment(...).\nYou have to pass an `id` or `_id` field or create a custom `keys` config for `" + e + "`.", 7),
c = null);

@@ -729,10 +769,10 @@ }

X.prototype.writeFragment = function(a, b, c) {
Y.prototype.writeFragment = function(a, b, c) {
Fa(this, a, b, c);
};
function Z(a, b, c) {
O(a.data, 0);
function Ja(a, b, c) {
O(a.data, null);
a = Ia(a, b, c);
P();
Q();
return a;

@@ -742,3 +782,3 @@ }

function Ia(a, b, c) {
var d = H(b.query), e = a.getRootKey(d.operation), f = u(d);
var d = G(b.query), e = a.getRootKey(d.operation), f = r(d);
a = {

@@ -750,11 +790,11 @@ parentTypeName: e,

store: a,
variables: z(d, b.variables),
fragments: I(b.query),
variables: E(d, b.variables),
fragments: H(b.query),
partial: !1
};
"production" !== process.env.NODE_ENV && E(e, d);
c = c || x();
c = e !== a.store.getRootKey("query") ? Ja(a, e, f, c) : Y(a, e, f, c);
"production" !== process.env.NODE_ENV && x(e, d);
c = c || C();
c = e !== a.store.getRootKey("query") ? Ka(a, e, f, c) : Z(a, e, f, c);
return {
dependencies: pa(),
dependencies: oa(),
partial: void 0 === c ? !1 : a.partial,

@@ -765,11 +805,11 @@ data: void 0 === c ? null : c

function Ja(a, b, c, d) {
function Ka(a, b, c, d) {
if ("string" != typeof d.__typename) {
return d;
}
b = new U(b, b, c, a);
(c = x()).__typename = d.__typename;
b = new W(b, b, c, a);
(c = C()).__typename = d.__typename;
for (var e; void 0 !== (e = b.next()); ) {
var f = r(e), g = d[f];
void 0 !== e.selectionSet && null !== g ? (g = V(g), c[f] = Ka(a, u(e), g)) : c[f] = g;
var f = p(e), g = d[f];
void 0 !== e.selectionSet && null !== g ? (g = X(g), c[f] = La(a, r(e), g)) : c[f] = g;
}

@@ -779,6 +819,6 @@ return c;

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

@@ -790,46 +830,46 @@ return d;

}
return null !== (d = a.store.keyOfEntity(c)) ? void 0 === (a = Y(a, d, b, x())) ? null : a : Ja(a, c.__typename, b, c);
return null !== (d = a.store.keyOfEntity(c)) ? void 0 === (a = Z(a, d, b, C())) ? null : a : Ka(a, c.__typename, b, c);
}
function Y(a, b, c, d) {
var e = a.store, f = b === e.getRootKey("query"), g = f ? b : R(b, "__typename");
function Z(a, b, c, d) {
var e = a.store, f = b === e.getRootKey("query"), g = f ? b : S(b, "__typename");
if ("string" == typeof g) {
d.__typename = g;
c = new U(g, b, c, a);
for (var h, k = !1, n = !1; void 0 !== (h = c.next()); ) {
var l = p(h), t = y(h, a.variables), q = r(h), A = K(l, t), v = R(b, A), w = b + "." + A;
c = new W(g, b, c, a);
for (var h, k = !1, m = !1; void 0 !== (h = c.next()); ) {
var l = h.name.value, t = D(h, a.variables), q = p(h), u = K(l, t), v = S(b, u), A = b + "." + u;
"production" !== process.env.NODE_ENV && e.schema && g && J(e.schema, g, l);
var m = void 0, D = e.resolvers[g];
if (void 0 !== D && "function" == typeof D[l]) {
if (a.parentTypeName = g, a.parentKey = b, a.parentFieldKey = w, a.fieldName = l,
void 0 !== v && (d[q] = v), m = D[l](d, t || x(), e, a), void 0 !== h.selectionSet && (m = La(a, g, l, w, u(h), d[q] || x(), m)),
e.schema && null === m && !ia(e.schema, g, l)) {
var n = void 0, B = e.resolvers[g];
if (void 0 !== B && "function" == typeof B[l]) {
if (a.parentTypeName = g, a.parentKey = b, a.parentFieldKey = A, a.fieldName = l,
void 0 !== v && (d[q] = v), n = B[l](d, t || C(), e, a), void 0 !== h.selectionSet && (n = Ma(a, g, l, A, r(h), d[q] || C(), n)),
e.schema && null === n && !ha(e.schema, g, l)) {
return;
}
} else {
void 0 === h.selectionSet ? m = v : void 0 !== (t = S(b, A)) ? m = Ma(a, t, g, l, u(h), d[q]) : "object" == typeof v && null !== v && (m = v);
void 0 === h.selectionSet ? n = v : void 0 !== (t = T(b, u)) ? n = Na(a, t, g, l, r(h), d[q]) : "object" == typeof v && null !== v && (n = v);
}
if (void 0 === m && e.schema && ia(e.schema, g, l)) {
n = !0, d[q] = null;
if (void 0 === n && e.schema && ha(e.schema, g, l)) {
m = !0, d[q] = null;
} else {
if (void 0 === m) {
if (void 0 === n) {
return;
}
k = !0;
d[q] = m;
d[q] = n;
}
}
n && (a.partial = !0);
return f && n && !k ? void 0 : d;
m && (a.partial = !0);
return f && m && !k ? void 0 : d;
}
}
function La(a, b, c, d, e, f, g) {
function Ma(a, b, c, d, e, f, g) {
if (Array.isArray(g)) {
var h = a.store;
h = !h.schema || ja(h.schema, b, c);
for (var k = Array(g.length), n = 0, l = g.length; n < l; n++) {
var t = La(a, b, c, d + "." + n, e, void 0 !== f ? f[n] : void 0, g[n]);
h = !h.schema || ia(h.schema, b, c);
for (var k = Array(g.length), m = 0, l = g.length; m < l; m++) {
var t = Ma(a, b, c, d + "." + m, e, void 0 !== f ? f[m] : void 0, g[m]);
if (void 0 !== t || h) {
k[n] = void 0 !== t ? t : null;
k[m] = void 0 !== t ? t : null;
} else {

@@ -845,29 +885,29 @@ return;

if ("string" == typeof g || "object" == typeof g && "string" == typeof g.__typename) {
b = void 0 === f ? x() : f;
b = void 0 === f ? C() : f;
if ("string" == typeof g) {
a = Y(a, g, e, b);
a = Z(a, g, e, b);
} else {
a: if (d = (c = a.store).keyOfEntity(g) || d, h = g.__typename, "string" != typeof (f = R(d, "__typename") || h) || h && f !== h) {
"production" !== process.env.NODE_ENV && G("Invalid resolver data: The resolver at `" + d + "` returned an invalid typename that could not be reconciled with the cache.", 8),
a: if (d = (c = a.store).keyOfEntity(g) || d, h = g.__typename, "string" != typeof (f = S(d, "__typename") || h) || h && f !== h) {
"production" !== process.env.NODE_ENV && z("Invalid resolver data: The resolver at `" + d + "` returned an invalid typename that could not be reconciled with the cache.", 8),
a = void 0;
} else {
b.__typename = f;
e = new U(f, d, e, a);
for (n = k = !1; void 0 !== (h = e.next()); ) {
l = p(h);
t = r(h);
var q = K(l, y(h, a.variables)), A = d + "." + q, v = R(d, q), w = g[l];
e = new W(f, d, e, a);
for (m = k = !1; void 0 !== (h = e.next()); ) {
l = h.name.value;
t = p(h);
var q = K(l, D(h, a.variables)), u = d + "." + q, v = S(d, q), A = g[l];
"production" !== process.env.NODE_ENV && c.schema && f && J(c.schema, f, l);
var m = void 0;
void 0 !== w && void 0 === h.selectionSet ? m = w : void 0 === h.selectionSet ? m = v : void 0 !== w ? m = La(a, f, l, A, u(h), b[t], w) : void 0 !== (q = S(d, q)) ? m = Ma(a, q, f, l, u(h), b[t]) : "object" == typeof v && null !== v && (m = v);
if (void 0 === m && void 0 !== c.schema && ia(c.schema, f, l)) {
n = !0, b[t] = null;
} else if (void 0 === m) {
var n = void 0;
void 0 !== A && void 0 === h.selectionSet ? n = A : void 0 === h.selectionSet ? n = v : void 0 !== A ? n = Ma(a, f, l, u, r(h), b[t], A) : void 0 !== (q = T(d, q)) ? n = Na(a, q, f, l, r(h), b[t]) : "object" == typeof v && null !== v && (n = v);
if (void 0 === n && void 0 !== c.schema && ha(c.schema, f, l)) {
m = !0, b[t] = null;
} else if (void 0 === n) {
a = void 0;
break a;
} else {
k = !0, b[t] = m;
k = !0, b[t] = n;
}
}
n && (a.partial = !0);
m && (a.partial = !0);
a = k ? b : void 0;

@@ -878,11 +918,11 @@ }

}
"production" !== process.env.NODE_ENV && G("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);
"production" !== process.env.NODE_ENV && z("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);
}
function Ma(a, b, c, d, e, f) {
function Na(a, b, c, d, e, f) {
if (Array.isArray(b)) {
var g = a.store;
g = g.schema && ja(g.schema, c, d);
for (var h = Array(b.length), k = 0, n = b.length; k < n; k++) {
var l = Ma(a, b[k], c, d, e, void 0 !== f ? f[k] : void 0);
g = g.schema && ia(g.schema, c, d);
for (var h = Array(b.length), k = 0, m = b.length; k < m; k++) {
var l = Na(a, b[k], c, d, e, void 0 !== f ? f[k] : void 0);
if (void 0 !== l || g) {

@@ -896,9 +936,9 @@ h[k] = void 0 !== l ? l : null;

}
return null === b ? null : Y(a, b, e, void 0 === f ? x() : f);
return null === b ? null : Z(a, b, e, void 0 === f ? C() : f);
}
function Na(a, b) {
return _extends(_extends({}, a), {
context: _extends(_extends({}, a.context), {
meta: _extends(_extends({}, a.context.meta), {
function Oa(a, b) {
return _extends({}, a, {
context: _extends({}, a.context, {
meta: _extends({}, a.context.meta, {
cacheOutcome: b

@@ -910,4 +950,4 @@ })

function Oa(a) {
return _extends(_extends({}, a), {
function Pa(a) {
return _extends({}, a, {
query: formatDocument(a.query)

@@ -917,9 +957,9 @@ });

function Pa(a) {
function Qa(a) {
return "query" === a.operationName && "network-only" !== a.context.requestPolicy;
}
function Qa(a, b) {
return _extends(_extends({}, a), {
context: _extends(_extends({}, a.context), {
function Ra(a, b) {
return _extends({}, a, {
context: _extends({}, a.context, {
requestPolicy: b

@@ -930,27 +970,55 @@ })

function Ra(a) {
return Pa(a);
}
function Sa(a) {
return Na(a.operation, a.outcome);
return Qa(a);
}
function Ta(a) {
return "miss" === a.outcome;
return Oa(a.operation, a.outcome);
}
function Ua(a) {
return "miss" !== a.outcome;
return "miss" === a.outcome;
}
function Va(a) {
return !Pa(a);
return "miss" !== a.outcome;
}
function Wa(a) {
return "cache-only" !== a.context.requestPolicy;
}
function Xa(a) {
return !Qa(a);
}
function Ya(a) {
return "populate" !== p(a);
for (var b = arguments, c = 1; c < arguments.length; c++) {
var d, e = b[c];
for (d in e) {
Object.prototype.hasOwnProperty.call(e, d) && (a[d] = e[d]);
}
}
return a;
}
function Za(a, b) {
function Za() {
return (Za = Object.assign || Ya).apply(this, arguments);
}
function $a(a) {
return isWrappingType(a) ? $a(a.ofType) : a || null;
}
var ab = new Set, bb = [];
function cb() {
return bb.length ? "\n(Caused At: " + bb.join(", ") + ")" : "";
}
function fb(a) {
return "populate" !== a.name.value;
}
function gb(a, b) {
"FragmentDefinition" === b.kind && a.add(b.name.value);

@@ -960,3 +1028,3 @@ return a;

function $a(a, b, c, d) {
function hb(a, b, c, d) {
function e(a, b) {

@@ -967,10 +1035,10 @@ if (!(b = c[b.name])) {

for (var e = 0, f = b.length; e < f; e++) {
for (var n = b[e].fragment, l = p(n), w = ab(n), m = 0, D = w.length; m < D; m++) {
var C = w[m];
k.has(C) || (g[C] = d[C]);
for (var u = b[e].fragment, m = u.name.value, l = ib(u), n = 0, B = l.length; n < B; n++) {
var F = l[n];
k.has(F) || (g[F] = d[F]);
}
h[l] = n;
h[m] = u;
a.push({
kind: Kind.FRAGMENT_SPREAD,
name: Xa(l)
name: eb(m)
});

@@ -980,3 +1048,3 @@ }

}
var f = new TypeInfo(a), g = x(), h = x(), k = new Set;
var f = new TypeInfo(a), g = Object.create(null), h = Object.create(null), k = new Set;
return visit(b, visitWithTypeInfo(f, {

@@ -986,14 +1054,15 @@ Field: {

if (b.directives) {
var c = b.directives.filter(Ya);
var c = b.directives.filter(fb);
if (c.length !== b.directives.length) {
var d = ba(f.getType());
isCompositeType(d) ? d = isAbstractType(d) ? a.getPossibleTypes(d) : [ d ] : ("production" !== process.env.NODE_ENV && G("Invalid type: The type ` + type + ` is used with @populate but does not exist.", 17),
var d = $a(f.getType());
isCompositeType(d) ? d = isAbstractType(d) ? a.getPossibleTypes(d) : [ d ] : ("production" !== process.env.NODE_ENV && (ab.has("Invalid type: The type ` + type + ` is used with @populate but does not exist.") || (console.warn("Invalid type: The type ` + type + ` is used with @populate but does not exist." + cb() + "\nhttps://github.com/FormidableLabs/urql/tree/master/exchanges/graphcache/help.md#17"),
ab.add("Invalid type: The type ` + type + ` is used with @populate but does not exist."))),
d = []);
d = d.reduce(e, []);
var g = u(b);
var g = void 0 !== b.selectionSet ? b.selectionSet.selections : [];
d = 0 !== g.length + d.length ? d.concat(g) : [ {
kind: Kind.FIELD,
name: Xa("__typename")
name: eb("__typename")
} ];
return _extends(_extends({}, b), {
return Za({}, b, {
directives: c,

@@ -1011,14 +1080,14 @@ selectionSet: {

enter: function(a) {
a.definitions.reduce(Za, k);
a.definitions.reduce(gb, k);
},
leave: function(a) {
var c, b = [].concat(a.definitions);
for (c in h) {
b.push(h[c]);
var b, c = [].concat(a.definitions);
for (b in h) {
c.push(h[b]);
}
for (var d in g) {
b.push(g[d]);
c.push(g[d]);
}
return _extends(_extends({}, a), {
definitions: b
return Za({}, a, {
definitions: c
});

@@ -1030,3 +1099,3 @@ }

function Xa(a) {
function eb(a) {
return {

@@ -1038,7 +1107,7 @@ kind: Kind.NAME,

function ab(a) {
function ib(a) {
var b = [];
visit(a, {
FragmentSpread: function(a) {
b.push(p(a));
b.push(a.name.value);
}

@@ -1052,24 +1121,19 @@ });

function c(a) {
var b = a.operation, c = a.error, d = a.extensions, f = "query" === b.operationName, C = a.data, k = b.key, m = new Set;
h(m, w.get(k));
w.delete(k);
var l = q.data;
delete l.refLock[k];
ta(l.records, k);
ta(l.links, k);
if (null != C) {
var n = Aa(q, b, C).dependencies;
var b = a.operation, c = a.error, d = a.extensions, f = "query" === b.operationName, g = a.data, I = b.key, l = new Set;
f || (k(l, n.get(I)), n.delete(I), P(u.data, I));
if (null != g) {
var m = za(u, b, g, I).dependencies;
if (f) {
C = (k = Z(q, b)).data;
var A = k.dependencies;
g = (I = Ja(u, b)).data;
var v = I.dependencies;
} else {
C = Z(q, b, C).data;
g = Ja(u, b, g).data;
}
}
h(m, n);
f && h(m, A);
g(a.operation, m);
f && void 0 !== A && e(a.operation, A);
k(l, m);
f && k(l, v);
h(a.operation, l);
f && void 0 !== v && e(a.operation, v);
return {
data: C,
data: g,
error: c,

@@ -1081,3 +1145,3 @@ extensions: d,

function d(a) {
var b = Z(q, a), c = b.data, d = b.dependencies;
var b = Ja(u, a), c = b.data, d = b.dependencies;
b = b.partial;

@@ -1093,4 +1157,4 @@ null === c ? d = "miss" : (e(a, d), d = b && "cache-only" !== a.context.requestPolicy ? "partial" : "hit");

b.forEach((function(b) {
(D[b] || (D[b] = [])).push(a.key);
m.has(a.key) || m.set(a.key, "network-only" === a.context.requestPolicy ? Qa(a, "cache-and-network") : a);
(F[b] || (F[b] = [])).push(a.key);
B.has(a.key) || B.set(a.key, "network-only" === a.context.requestPolicy ? Ra(a, "cache-and-network") : a);
}));

@@ -1100,19 +1164,28 @@ }

if ("mutation" === a.operationName && "network-only" !== a.context.requestPolicy) {
var b = a.key, c = Da(q, a, b).dependencies;
0 !== c.size && (w.set(b, c), h(b = new Set, c), g(a, b));
var b = a.key, c = Da(u, a, b).dependencies;
0 !== c.size && (n.set(b, c), k(b = new Set, c), h(a, b));
}
}
function g(a, b) {
function g(a) {
if ("query" === a.operationName) {
var b = u.data;
b.commutativeKeys.has(a = a.key) || (b.optimisticOrder.splice(b.optimisticOrder.length - b.commutativeKeys.size, 0, a),
b.commutativeKeys.add(a));
} else {
"teardown" === a.operationName && P(u.data, a.key);
}
}
function h(a, b) {
b.forEach((function(b) {
if (b !== a.key) {
var c = m.get(b);
void 0 !== c && (m.delete(b), t.reexecuteOperation(Qa(c, "cache-first")));
var c = B.get(b);
void 0 !== c && (B.delete(b), q.reexecuteOperation(Ra(c, "cache-first")));
}
}));
}
function h(a, b) {
function k(a, b) {
void 0 !== b && b.forEach((function c(b) {
var c = D[b];
var c = F[b];
if (void 0 !== c) {
D[b] = [];
F[b] = [];
b = 0;

@@ -1125,6 +1198,6 @@ for (var d = c.length; b < d; b++) {

}
function n(a) {
function l(a) {
var b = a.operation, c = a.outcome, d = b.context.requestPolicy;
a = {
operation: Na(b, c),
operation: Oa(b, c),
data: a.data,

@@ -1135,14 +1208,14 @@ error: a.error,

if ("cache-and-network" === d || "cache-first" === d && "partial" === c) {
a.stale = !0, t.reexecuteOperation(Qa(b, "network-only"));
a.stale = !0, q.reexecuteOperation(Ra(b, "network-only"));
}
return a;
}
var l = b.forward, t = b.client;
var t = b.forward, q = b.client;
a || (a = {});
var q = new X(a.schema, a.resolvers, a.updates, a.optimistic, a.keys);
var u = new Y(a.schema, a.resolvers, a.updates, a.optimistic, a.keys);
if (a.storage) {
var A = a.storage;
var v = A.read().then((function k(a) {
var b = q.data, c = A;
O(b, 0);
var v = a.storage;
var A = v.read().then((function m(a) {
var b = u.data, c = v;
O(b, null);
for (var d in a) {

@@ -1153,22 +1226,22 @@ var e = d.indexOf("."), f = d.slice(2, e);

case 108:
ya(f, e, a[d]);
V(f, e, a[d]);
break;
case 114:
T(f, e, a[d]);
U(f, e, a[d]);
}
}
P();
Q();
b.storage = c;
}));
}
var w = new Map, m = new Map, D = x();
var n = new Map, B = new Map, F = C();
return function(a) {
a = share(a);
var b = v ? mergeMap(fromArray)(take(1)(buffer(fromPromise(v))(a))) : empty;
a = share(tap(f)(map(Oa)(concat([ b, a ]))));
var e = share(map(d)(filter(Ra)(a)));
b = map(Sa)(filter(Ta)(e));
e = map(n)(filter(Ua)(e));
a = map(c)(l(merge([ filter(Va)(a), b ])));
var b = A ? mergeMap(fromArray)(take(1)(buffer(fromPromise(A))(a))) : empty;
a = share(tap(f)(map(Pa)(concat([ b, a ]))));
var e = share(map(d)(filter(Sa)(a)));
b = map(Ta)(filter(Ua)(e));
e = map(l)(filter(Va)(e));
a = map(c)(t(tap(g)(filter(Wa)(merge([ filter(Xa)(a), b ])))));
return merge([ a, e ]);

@@ -1187,5 +1260,5 @@ };

var b = a.key, c = a.query;
if ("query" === a.operationName && (l.add(b), !n.has(b))) {
n.add(b);
a = function Wa(a, b) {
if ("query" === a.operationName && (l.add(b), !m.has(b))) {
m.add(b);
c = (a = function db(a, b) {
var c = [], d = [], e = new TypeInfo(a);

@@ -1195,4 +1268,8 @@ visit(b, visitWithTypeInfo(e, {

if (a.selectionSet) {
var b = ba(e.getType());
F(b && !isAbstractType(b), "production" !== process.env.NODE_ENV ? "Invalid TypeInfo state: Found no flat schema type when one was expected." : "", 18);
var b = $a(e.getType());
if (!b || isAbstractType(b)) {
throw a = ("production" !== process.env.NODE_ENV ? "Invalid TypeInfo state: Found no flat schema type when one was expected." : "") || "Minfied Error #18\n",
"production" !== process.env.NODE_ENV && (a += cb()), (a = Error(a + "\nhttps://github.com/FormidableLabs/urql/tree/master/exchanges/graphcache/help.md#18")).name = "Graphcache Error",
a;
}
b = b.toString();

@@ -1203,5 +1280,5 @@ d.push({

kind: Kind.NAMED_TYPE,
name: Xa(b)
name: eb(b)
},
name: Xa(b + "_PopulateFragment_"),
name: eb(b + "_PopulateFragment_"),
selectionSet: a.selectionSet

@@ -1216,12 +1293,11 @@ });

return [ c, d ];
}(k, c);
c = a[0];
}(k, c))[0];
a = a[1];
for (var d = 0, e = c.length; d < e; d++) {
var f = c[d];
t[p(f)] = f;
t[f.name.value] = f;
}
c = 0;
for (d = a.length; c < d; c++) {
f = p((e = a[c]).typeCondition), f = q[f] || (q[f] = []), e.name.value += f.length,
f = q[f = (e = a[c]).typeCondition.name.value] || (q[f] = []), e.name.value += f.length,
f.push({

@@ -1238,8 +1314,8 @@ key: b,

}
var c, b = x();
for (c in q) {
b[c] = q[c].filter(g);
var b, c = Object.create(null);
for (b in q) {
c[b] = q[b].filter(g);
}
return _extends(_extends({}, a), {
query: $a(k, a.query, b, t)
return Za({}, a, {
query: hb(k, a.query, c, t)
});

@@ -1250,3 +1326,3 @@ }

}
var h = a.forward, k = buildClientSchema(b), n = new Set, l = new Set, t = x(), q = x();
var h = a.forward, k = buildClientSchema(b), m = new Set, l = new Set, t = Object.create(null), q = Object.create(null);
return function(a) {

@@ -1258,3 +1334,3 @@ return h(map(f)(tap(c)(tap(e)(a))));

export { X as Store, cacheExchange, P as clearDataState, O as initDataState, populateExchange, Z as query, Ia as read, Aa as write, Fa as writeFragment, Da as writeOptimistic };
export { Y as Store, cacheExchange, Q as clearDataState, O as initDataState, populateExchange, Ja as query, Ia as read, za as write, Fa as writeFragment, Da as writeOptimistic };
//# sourceMappingURL=urql-exchange-graphcache.esm.js.map

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

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

@@ -9,5 +9,5 @@ {

"dependencies": {
"@urql/core": ">=1.9.0",
"@urql/core": ">=1.9.1",
"wonka": "^3.2.1 || ^4.0.0"
}
}
{
"name": "@urql/exchange-graphcache",
"version": "2.1.1",
"version": "2.2.0",
"description": "A normalized and configurable cache exchange for urql",

@@ -51,2 +51,3 @@ "sideEffects": false,

"check": "tsc --noEmit",
"lint": "eslint --ext=js,jsx,ts,tsx .",
"build": "rollup -c ../../scripts/rollup/config.js",

@@ -61,3 +62,3 @@ "prepare": "../../scripts/prepare/index.js",

"wonka": "^3.2.1 || ^4.0.0",
"@urql/core": ">=1.9.0"
"@urql/core": ">=1.9.1"
},

@@ -64,0 +65,0 @@ "peerDependencies": {

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

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