@urql/exchange-graphcache
Advanced tools
Comparing version 2.2.4 to 2.2.5
# @urql/exchange-graphcache | ||
## 2.2.5 | ||
### Patch Changes | ||
- Refactor parts of Graphcache for a minor performance boost and bundlesize reductions, by [@kitten](https://github.com/kitten) (See [#611](https://github.com/FormidableLabs/urql/pull/611)) | ||
## 2.2.4 | ||
@@ -4,0 +10,0 @@ |
@@ -1,4 +0,3 @@ | ||
import { NamedTypeNode, NameNode, SelectionNode, SelectionSetNode, InlineFragmentNode, FieldNode, FragmentDefinitionNode, GraphQLOutputType, GraphQLWrappingType } from 'graphql'; | ||
import { NamedTypeNode, NameNode, SelectionNode, SelectionSetNode, InlineFragmentNode, FieldNode, FragmentDefinitionNode } from 'graphql'; | ||
export declare type SelectionSet = ReadonlyArray<SelectionNode>; | ||
export declare type GraphQLFlatType = Exclude<GraphQLOutputType, GraphQLWrappingType>; | ||
/** Returns the name of a given node */ | ||
@@ -20,8 +19,1 @@ export declare const getName: (node: { | ||
export declare const isInlineFragment: (node: SelectionNode) => node is InlineFragmentNode; | ||
export declare const unwrapType: (type: import("graphql").GraphQLScalarType | import("graphql").GraphQLObjectType<any, any, { | ||
[key: string]: any; | ||
}> | import("graphql").GraphQLInterfaceType | import("graphql").GraphQLUnionType | import("graphql").GraphQLEnumType | import("graphql").GraphQLList<any> | import("graphql").GraphQLNonNull<import("graphql").GraphQLScalarType | import("graphql").GraphQLInterfaceType | import("graphql").GraphQLUnionType | import("graphql").GraphQLEnumType | import("graphql").GraphQLObjectType<any, any, { | ||
[key: string]: any; | ||
}> | import("graphql").GraphQLList<any>> | null | undefined) => import("graphql").GraphQLScalarType | import("graphql").GraphQLObjectType<any, any, { | ||
[key: string]: any; | ||
}> | import("graphql").GraphQLInterfaceType | import("graphql").GraphQLUnionType | import("graphql").GraphQLEnumType | null; |
@@ -1,5 +0,5 @@ | ||
export * from './operations'; | ||
export * from './types'; | ||
export { Store, initDataState, clearDataState } from './store'; | ||
export { query, write, writeOptimistic } from './operations'; | ||
export { Store, noopDataState, reserveLayer } from './store'; | ||
export { cacheExchange } from './cacheExchange'; | ||
export { populateExchange } from '@urql/exchange-populate'; |
@@ -1,11 +0,3 @@ | ||
import { SelectionSet } from '../ast/node'; | ||
import { OperationRequest, Variables, Fragments } from '../types'; | ||
import { OperationRequest } from '../types'; | ||
import { Store } from '../store'; | ||
interface Context { | ||
store: Store; | ||
variables: Variables; | ||
fragments: Fragments; | ||
} | ||
export declare const invalidate: (store: Store, request: OperationRequest) => void; | ||
export declare const invalidateSelection: (ctx: Context, entityKey: string, select: SelectionSet) => void; | ||
export {}; |
@@ -5,7 +5,15 @@ import { FieldNode } from 'graphql'; | ||
import { Fragments, Variables, DataField, NullArray, Data } from '../types'; | ||
interface Context { | ||
export interface Context { | ||
store: Store; | ||
variables: Variables; | ||
fragments: Fragments; | ||
parentTypeName: string; | ||
parentKey: string; | ||
parentFieldKey: string; | ||
fieldName: string; | ||
partial: boolean; | ||
optimistic: boolean; | ||
} | ||
export declare const makeContext: (store: Store, variables: Variables, fragments: Fragments, typename: string, entityKey: string, optimistic?: boolean | undefined) => Context; | ||
export declare const updateContext: (ctx: Context, typename: string, entityKey: string, fieldKey: string, fieldName: string) => void; | ||
export declare class SelectionIterator { | ||
@@ -21,2 +29,1 @@ typename: void | string; | ||
export declare const ensureData: (x: DataField) => Data | NullArray<Data> | null; | ||
export {}; |
@@ -43,2 +43,4 @@ import { Link, EntityField, FieldInfo, StorageAdapter, SerializedEntries } from '../types'; | ||
export declare const getCurrentDependencies: () => Set<string>; | ||
export declare const forkDependencies: () => Set<string>; | ||
export declare const unforkDependencies: () => void; | ||
export declare const make: (queryRootKey: string) => InMemoryData; | ||
@@ -52,6 +54,6 @@ /** Garbage collects all entities that have been marked as having no references */ | ||
/** Writes an entity's field (a "record") to data */ | ||
export declare const writeRecord: (entityKey: string, fieldKey: string, value: EntityField) => void; | ||
export declare const writeRecord: (entityKey: string, fieldKey: string, value?: EntityField) => void; | ||
export declare const hasField: (entityKey: string, fieldKey: string) => boolean; | ||
/** Writes an entity's link to data */ | ||
export declare const writeLink: (entityKey: string, fieldKey: string, link: string | import("../types").NullArray<string> | null | undefined) => 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 */ | ||
@@ -58,0 +60,0 @@ export declare const reserveLayer: (data: InMemoryData, layerKey: number) => void; |
@@ -21,6 +21,3 @@ import { DocumentNode, IntrospectionQuery, GraphQLSchema } from 'graphql'; | ||
constructor(rawSchema?: IntrospectionQuery, resolvers?: ResolverConfig, updates?: Partial<UpdatesConfig>, optimisticMutations?: OptimisticMutationConfig, keys?: KeyingConfig); | ||
gcScheduled: boolean; | ||
gc: () => void; | ||
keyOfField: (fieldName: string, args?: Variables | null | undefined) => string; | ||
getRootKey(name: RootField): string; | ||
keyOfEntity(data: Data): string | null; | ||
@@ -27,0 +24,0 @@ resolveFieldByKey(entity: Data | string | null, fieldKey: string): DataField; |
@@ -63,3 +63,3 @@ import { DocumentNode, FragmentDefinitionNode } from 'graphql'; | ||
inspectFields(entity: Data | string | null): FieldInfo[]; | ||
/** invalidateQuery() invalidates all data of a given query */ | ||
/** @deprecated Use invalidate() instead */ | ||
invalidateQuery(query: DocumentNode, variables?: Variables): void; | ||
@@ -66,0 +66,0 @@ /** invalidate() invalidates an entity */ |
@@ -8,7 +8,7 @@ "use strict"; | ||
}, getFieldAlias = function(a) { | ||
return void 0 !== a.alias ? a.alias.value : getName(a); | ||
return a.alias ? a.alias.value : getName(a); | ||
}, getSelectionSet = function(a) { | ||
return void 0 !== a.selectionSet ? a.selectionSet.selections : []; | ||
return a.selectionSet ? a.selectionSet.selections : []; | ||
}, getTypeCondition = function(a) { | ||
return void 0 !== (a = a.typeCondition) ? getName(a) : null; | ||
return (a = a.typeCondition) ? getName(a) : null; | ||
}, isFieldNode = function(a) { | ||
@@ -21,27 +21,21 @@ return a.kind === graphql.Kind.FIELD; | ||
}, getFieldArguments = function(a, b) { | ||
if (void 0 === a.arguments || 0 === a.arguments.length) { | ||
return null; | ||
var c = makeDict(), d = 0; | ||
if (a.arguments && a.arguments.length) { | ||
for (var 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++); | ||
} | ||
} | ||
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++); | ||
} | ||
return 0 < e ? c : null; | ||
return 0 < d ? c : null; | ||
}, normalizeVariables = function(a, b) { | ||
if (void 0 === a.variableDefinitions) { | ||
return {}; | ||
b = b || {}; | ||
var c = makeDict(); | ||
if (a.variableDefinitions) { | ||
for (var d = 0, e = a.variableDefinitions.length; d < e; d++) { | ||
var f = a.variableDefinitions[d], g = getName(f.variable), h = b[g]; | ||
void 0 === h && f.defaultValue && (h = graphql.valueFromASTUntyped(f.defaultValue, b)); | ||
c[g] = h; | ||
} | ||
} | ||
var c = b || {}; | ||
return a.variableDefinitions.reduce((function(a, b) { | ||
var d = getName(b.variable), e = c[d]; | ||
if (void 0 === e) { | ||
if (void 0 !== b.defaultValue) { | ||
e = graphql.valueFromASTUntyped(b.defaultValue, c); | ||
} else { | ||
return a; | ||
} | ||
} | ||
a[d] = e; | ||
return a; | ||
}), makeDict()); | ||
return c; | ||
}, helpUrl = "\nhttps://bit.ly/38yWDau#", cache = new Set, currentDebugStack = [], pushDebugNode = function(a, b) { | ||
@@ -87,9 +81,10 @@ var c = ""; | ||
}, shouldInclude = function(a, b) { | ||
if (void 0 === (a = a.directives)) { | ||
var c = a.directives; | ||
if (!c) { | ||
return !0; | ||
} | ||
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 d = 0, e = c.length; d < e; d++) { | ||
var f = c[d]; | ||
if (("include" === (a = getName(f)) || "skip" === a) && f.arguments && f.arguments[0] && "if" === getName(f.arguments[0])) { | ||
return b = graphql.valueFromASTUntyped(f.arguments[0].value, b), "include" === a ? !!b : !b; | ||
} | ||
@@ -99,5 +94,5 @@ } | ||
}, isFieldNullable = function(a, b, c) { | ||
return void 0 === (a = getField(a, b, c)) ? !1 : graphql.isNullableType(a.type); | ||
return !!(a = getField(a, b, c)) && graphql.isNullableType(a.type); | ||
}, isListNullable = function(a, b, c) { | ||
if (void 0 === (a = getField(a, b, c))) { | ||
if (!(a = getField(a, b, c))) { | ||
return !1; | ||
@@ -116,18 +111,15 @@ } | ||
} | ||
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) { | ||
expectObjectType(a = a.getType(b), b); | ||
if (void 0 === (a = a.getFields()[c])) { | ||
"production" !== process.env.NODE_ENV && warn("Invalid field: The field `" + c + "` does not exist on `" + b + "`, but the GraphQL document expects it to exist.\nTraversal will continue, however this may lead to undefined behavior!", 4); | ||
} else { | ||
return a; | ||
} | ||
(a = a.getFields()[c]) || "production" !== process.env.NODE_ENV && warn("Invalid field: The field `" + c + "` does not exist on `" + b + "`, but the GraphQL document expects it to exist.\nTraversal will continue, however this may lead to undefined behavior!", 4); | ||
return a; | ||
}; | ||
@@ -158,3 +150,3 @@ | ||
return setTimeout(a, 0); | ||
}, currentData = null, currentDependencies = null, currentOptimisticKey = null, makeNodeMap = function() { | ||
}, currentData = null, currentDependencies = null, previousDependencies = null, currentOptimisticKey = null, makeNodeMap = function() { | ||
return { | ||
@@ -166,2 +158,3 @@ optimistic: makeDict(), | ||
currentData = a; | ||
previousDependencies = currentDependencies; | ||
currentDependencies = new Set; | ||
@@ -173,7 +166,6 @@ "production" !== process.env.NODE_ENV && (currentDebugStack.length = 0); | ||
}, clearDataState = function() { | ||
var c = currentData, e = currentOptimisticKey; | ||
var c = currentData, d = currentOptimisticKey; | ||
currentOptimisticKey = null; | ||
if (e && -1 < c.optimisticOrder.indexOf(e)) { | ||
e = c.optimisticOrder.length - c.commutativeKeys.size; | ||
for (var d = c.optimisticOrder.length; --d >= e && c.refLock[c.optimisticOrder[d]] && c.commutativeKeys.has(c.optimisticOrder[d]); ) { | ||
if (d && -1 < c.optimisticOrder.indexOf(d)) { | ||
for (d = c.optimisticOrder.length; 0 <= --d && c.refLock[c.optimisticOrder[d]] && c.commutativeKeys.has(c.optimisticOrder[d]); ) { | ||
squashLayer(c.optimisticOrder[d]); | ||
@@ -198,25 +190,31 @@ } | ||
return currentDependencies; | ||
}, setNode = function(a, b, c, e) { | ||
var d = (a = currentOptimisticKey ? a.optimistic[currentOptimisticKey] : a.base).get(b); | ||
void 0 === d && a.set(b, d = makeDict()); | ||
void 0 !== e || currentOptimisticKey ? d[c] = e : delete d[c]; | ||
}, forkDependencies = function() { | ||
previousDependencies = currentDependencies; | ||
return currentDependencies = new Set; | ||
}, unforkDependencies = function() { | ||
currentDependencies = previousDependencies; | ||
previousDependencies = null; | ||
}, setNode = function(a, b, c, d) { | ||
var e = (a = currentOptimisticKey ? a.optimistic[currentOptimisticKey] : a.base).get(b); | ||
void 0 === e && a.set(b, e = makeDict()); | ||
void 0 !== d || currentOptimisticKey ? e[c] = d : delete e[c]; | ||
}, getNode = function(a, b, c) { | ||
for (var e, d = 0, f = currentData.optimisticOrder.length; d < f; d++) { | ||
var g = a.optimistic[currentData.optimisticOrder[d]]; | ||
if (g && void 0 !== (e = g.get(b)) && c in e) { | ||
return e[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 !== (e = a.base.get(b)) ? e[c] : void 0; | ||
}, updateRCForEntity = function(a, b, c, e) { | ||
var d = void 0 !== b[c] ? b[c] : 0; | ||
b = b[c] = d + e | 0; | ||
void 0 !== a && (0 >= b ? a.add(c) : 0 >= d && 0 < b && a.delete(c)); | ||
}, updateRCForLink = function(a, b, c, e) { | ||
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); | ||
} | ||
@@ -226,10 +224,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 = currentData.optimisticOrder.length; d < f; d++) { | ||
extractNodeFields(a, b, e.optimistic[currentData.optimisticOrder[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)); | ||
} | ||
@@ -241,7 +239,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]; | ||
} | ||
@@ -251,11 +249,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); | ||
} | ||
@@ -281,17 +279,17 @@ } | ||
}, 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; | ||
f = (f = f && f.get(a)) && f[b]; | ||
updateDependencies(a, b); | ||
setNode(e.links, a, b, c); | ||
updateRCForLink(g, d, f, -1); | ||
updateRCForLink(g, d, c, 1); | ||
setNode(d.links, a, b, c); | ||
updateRCForLink(g, e, f, -1); | ||
updateRCForLink(g, e, c, 1); | ||
}, reserveLayer = function(a, b) { | ||
@@ -323,18 +321,34 @@ a.commutativeKeys.has(b) || (a.optimisticOrder.unshift(b), a.commutativeKeys.add(b)); | ||
var squashLayer = function(a) { | ||
var b = currentDependencies; | ||
currentDependencies = new Set; | ||
var c = currentData.links.optimistic[a]; | ||
c && c.forEach(_ref3); | ||
(c = currentData.records.optimistic[a]) && c.forEach(_ref4); | ||
currentDependencies = b; | ||
forkDependencies(); | ||
var b = currentData.links.optimistic[a]; | ||
b && b.forEach(_ref3); | ||
(b = currentData.records.optimistic[a]) && b.forEach(_ref4); | ||
unforkDependencies(); | ||
deleteLayer(currentData, a); | ||
}, isFragmentHeuristicallyMatching = function(a, b, c, e) { | ||
}, makeContext = function(a, b, c, d, e, f) { | ||
return { | ||
store: a, | ||
variables: b, | ||
fragments: c, | ||
parentTypeName: d, | ||
parentKey: e, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
partial: !1, | ||
optimistic: !!f | ||
}; | ||
}, updateContext = function(a, b, c, d, e) { | ||
a.parentTypeName = b; | ||
a.parentKey = c; | ||
a.parentFieldKey = d; | ||
a.fieldName = e; | ||
}, isFragmentHeuristicallyMatching = function(a, b, c, d) { | ||
if (!b) { | ||
return !1; | ||
} | ||
var 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) { | ||
@@ -344,3 +358,3 @@ if (!isFieldNode(a)) { | ||
} | ||
a = keyOfField(getName(a), getFieldArguments(a, e)); | ||
a = keyOfField(getName(a), getFieldArguments(a, d)); | ||
return !function(a, b) { | ||
@@ -350,6 +364,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 ]; | ||
@@ -379,4 +393,4 @@ this.selectionStack = [ c ]; | ||
return void 0 === a ? null : a; | ||
}, write = function(a, b, c, e) { | ||
initDataState(a.data, e || null); | ||
}, write = function(a, b, c, d) { | ||
initDataState(a.data, d || null); | ||
a = startWrite(a, b, c); | ||
@@ -386,175 +400,88 @@ 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); | ||
a = { | ||
parentTypeName: g, | ||
parentKey: g, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
store: a, | ||
variables: normalizeVariables(e, b.variables), | ||
fragments: getFragments(b.query) | ||
}; | ||
"production" !== process.env.NODE_ENV && pushDebugNode(g, e); | ||
g === a.store.getRootKey("query") ? writeSelection(a, g, f, c) : writeRoot(a, g, f, c); | ||
return d; | ||
}, f = a.rootFields[d.operation]; | ||
a = makeContext(a, normalizeVariables(d, b.variables), getFragments(b.query), f, f); | ||
"production" !== process.env.NODE_ENV && pushDebugNode(f, d); | ||
writeSelection(a, f, getSelectionSet(d), c); | ||
return e; | ||
}, writeOptimistic = function(a, b, c) { | ||
initDataState(a.data, c, !0); | ||
var e = getMainOperation(b.query); | ||
c = { | ||
c = getMainOperation(b.query); | ||
var d = { | ||
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); | ||
a = { | ||
parentTypeName: d, | ||
parentKey: d, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
variables: normalizeVariables(e, b.variables), | ||
fragments: getFragments(b.query), | ||
store: a, | ||
optimistic: !0 | ||
}; | ||
}, e = a.rootFields[c.operation]; | ||
invariant(e === a.rootFields.mutation, "production" !== process.env.NODE_ENV ? "writeOptimistic(...) was called with an operation that is not a mutation.\nThis case is unsupported and should never occur." : "", 10); | ||
"production" !== process.env.NODE_ENV && pushDebugNode(e, c); | ||
a = makeContext(a, normalizeVariables(c, b.variables), getFragments(b.query), e, e, !0); | ||
b = makeDict(); | ||
e = new SelectionIterator(f, f, getSelectionSet(e), a); | ||
for (var g; void 0 !== (g = e.next()); ) { | ||
if (void 0 !== g.selectionSet) { | ||
var h = getName(g), k = a.store.optimisticMutations[h]; | ||
if (void 0 !== k) { | ||
a.fieldName = h; | ||
k = k((f = getFieldArguments(g, a.variables)) || makeDict(), a.store, a); | ||
var m = ensureData(k); | ||
writeRootField(a, m, getSelectionSet(g)); | ||
b[h] = k; | ||
void 0 !== (g = a.store.updates[d][h]) && g(b, f || makeDict(), a.store, a); | ||
} | ||
} | ||
} | ||
writeSelection(a, e, getSelectionSet(c), b); | ||
clearDataState(); | ||
return c; | ||
}, writeFragment = function(a, b, c, e) { | ||
b = getFragments(b); | ||
var d = Object.keys(b); | ||
if (void 0 === (d = b[d[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({}, { | ||
__typename: f | ||
}, c); | ||
var g = a.keyOfEntity(c); | ||
if (!g) { | ||
return "production" !== process.env.NODE_ENV ? warn("Can't generate a key for writeFragment(...) data.\nYou have to pass an `id` or `_id` field or create a custom `keys` config for `" + f + "`.", 12) : void 0; | ||
} | ||
"production" !== process.env.NODE_ENV && pushDebugNode(f, d); | ||
writeSelection({ | ||
parentTypeName: f, | ||
parentKey: g, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
variables: e || {}, | ||
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); | ||
for (var f; void 0 !== (f = c.next()); ) { | ||
var g = getName(f), h = getFieldArguments(f, a.variables); | ||
h = keyOfField(g, h); | ||
var k = e[getFieldAlias(f)], m = joinKeys(b, h); | ||
return d; | ||
}, writeSelection = function(a, b, c, d) { | ||
var e = b === a.store.rootFields.query, f = !e && !!a.store.rootNames[b], g = f || e ? b : d.__typename; | ||
if (g) { | ||
f || e || !b || writeRecord(b, "__typename", g); | ||
c = new SelectionIterator(g, b || g, c, a); | ||
for (var h; h = c.next(); ) { | ||
var k = getName(h), m = getFieldArguments(h, a.variables); | ||
e = keyOfField(k, m); | ||
var l = d[getFieldAlias(h)]; | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (void 0 === k) { | ||
g = a.optimistic ? "\nYour optimistic result may be missing a field!" : ""; | ||
f = void 0 === f.selectionSet ? "scalar (number, boolean, etc)" : "selection set"; | ||
"production" !== process.env.NODE_ENV && warn("Invalid undefined: The field at `" + h + "` is `undefined`, but the GraphQL query expects a " + f + " for this field." + g, 13); | ||
if (f || void 0 !== l) { | ||
a.store.schema && g && isFieldAvailableOnType(a.store.schema, g, k); | ||
} else { | ||
m = a.optimistic ? "\nYour optimistic result may be missing a field!" : ""; | ||
h = void 0 === h.selectionSet ? "scalar (number, boolean, etc)" : "selection set"; | ||
"production" !== process.env.NODE_ENV && warn("Invalid undefined: The field at `" + e + "` is `undefined`, but the GraphQL query expects a " + h + " for this field." + m, 13); | ||
continue; | ||
} | ||
} | ||
if (h.selectionSet) { | ||
if (a.optimistic && f) { | ||
if (!(l = a.store.optimisticMutations[k])) { | ||
continue; | ||
} | ||
updateContext(a, g, g, e, k); | ||
l = ensureData(l(m || makeDict(), a.store, a)); | ||
d[k] = l; | ||
} else { | ||
a.store.schema && d && isFieldAvailableOnType(a.store.schema, d, g); | ||
l = ensureData(l); | ||
} | ||
if (b && !f) { | ||
var n = joinKeys(b, e); | ||
h = writeField(a, getSelectionSet(h), l, n); | ||
writeLink(b || g, e, h); | ||
} else { | ||
writeField(a, getSelectionSet(h), l); | ||
} | ||
} else { | ||
b && !f && writeRecord(b || g, e, l); | ||
} | ||
void 0 === f.selectionSet ? writeRecord(b, h, k) : (g = ensureData(k), f = writeField(a, m, getSelectionSet(f), g), | ||
writeLink(b, h, f)); | ||
f && (updateContext(a, g, g, joinKeys(g, e), k), (e = a.store.updates[g][k]) && e(d, m || makeDict(), a.store, a)); | ||
} | ||
} | ||
}, 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], k = joinKeys(b, "" + f); | ||
h = writeField(a, k, c, h); | ||
d[f] = h; | ||
}, writeField = function(a, b, c, d) { | ||
if (Array.isArray(c)) { | ||
for (var e = Array(c.length), f = 0, g = c.length; f < g; f++) { | ||
var h = c[f], k = d ? joinKeys(d, "" + f) : void 0; | ||
h = writeField(a, b, h, k); | ||
e[f] = h; | ||
} | ||
return d; | ||
return e; | ||
} | ||
if (null === e) { | ||
if (null === c) { | ||
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); | ||
return f; | ||
}, writeRoot = function(a, b, c, e) { | ||
var d = 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), k = joinKeys(b, keyOfField(g, h)); | ||
if (void 0 !== f.selectionSet) { | ||
var m = ensureData(e[getFieldAlias(f)]); | ||
writeRootField(a, m, getSelectionSet(f)); | ||
} | ||
d && (a.parentTypeName = b, a.parentKey = b, a.parentFieldKey = k, a.fieldName = g, | ||
void 0 !== (f = a.store.updates[b][g]) && f(e, 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); | ||
} | ||
return e; | ||
} | ||
null !== b && (null !== (e = a.store.keyOfEntity(b)) ? writeSelection(a, e, 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) { | ||
return; | ||
} | ||
writeRecord(b, "__typename", void 0); | ||
} else { | ||
e = 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) { | ||
writeRecord(b, g, void 0); | ||
} else if (d = getSelectionSet(d), 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 k = f[g]; | ||
null !== k && invalidateSelection(a, k, d); | ||
} | ||
} else { | ||
f && invalidateSelection(a, f, d); | ||
} | ||
} | ||
}, Store = function(a, b, c, e, d) { | ||
var g, f = this; | ||
this.gcScheduled = !1; | ||
this.gc = function() { | ||
gc(f.data); | ||
f.gcScheduled = !1; | ||
}; | ||
e = a.store.keyOfEntity(c); | ||
f = c.__typename; | ||
!d || void 0 !== a.store.keys[c.__typename] || null !== e || "string" != typeof f || f.endsWith("Connection") || f.endsWith("Edge") || "PageInfo" === f || "production" !== process.env.NODE_ENV && warn("Invalid key: The GraphQL query at the field at `" + d + "` has a selection set, but no key could be generated for the data at this field.\nYou have to request `id` or `_id` fields for all selection sets or create a custom `keys` config for `" + f + "`.\nEntities without keys will be embedded directly on the parent entity. If this is intentional, create a `keys` config for `" + f + "` that always returns null.", 15); | ||
writeSelection(a, d = e || d, b, c); | ||
return d || null; | ||
}, Store = function(a, b, c, d, e) { | ||
var f; | ||
this.keyOfField = keyOfField; | ||
this.resolvers = b || {}; | ||
this.optimisticMutations = e || {}; | ||
this.keys = d || {}; | ||
this.optimisticMutations = d || {}; | ||
this.keys = e || {}; | ||
this.updates = { | ||
@@ -564,17 +491,21 @@ Mutation: c && c.Mutation || {}, | ||
}; | ||
a ? (c = (b = this.schema = graphql.buildClientSchema(a)).getQueryType(), a = b.getMutationType(), | ||
b = b.getSubscriptionType(), this.rootFields = { | ||
query: c = c ? c.name : "Query", | ||
mutation: a = a ? a.name : "Mutation", | ||
subscription: b = b ? b.name : "Subscription" | ||
}, this.rootNames = ((g = {})[c] = "query", g[a] = "mutation", g[b] = "subscription", | ||
g)) : (this.rootFields = { | ||
query: "Query", | ||
mutation: "Mutation", | ||
subscription: "Subscription" | ||
}, this.rootNames = { | ||
Query: "query", | ||
Mutation: "mutation", | ||
Subscription: "subscription" | ||
}); | ||
b = "Query"; | ||
c = "Mutation"; | ||
d = "Subscription"; | ||
if (a) { | ||
var g = this.schema = graphql.buildClientSchema(a); | ||
a = g.getQueryType(); | ||
e = g.getMutationType(); | ||
g = g.getSubscriptionType(); | ||
a && (b = a.name); | ||
e && (c = e.name); | ||
g && (d = g.name); | ||
} | ||
this.rootFields = { | ||
query: b, | ||
mutation: c, | ||
subscription: d | ||
}; | ||
this.rootNames = ((f = {})[b] = "query", f[c] = "mutation", f[d] = "subscription", | ||
f); | ||
this.data = function(a) { | ||
@@ -595,11 +526,7 @@ return { | ||
}; | ||
}(this.getRootKey("query")); | ||
}(b); | ||
}; | ||
Store.prototype.getRootKey = function(a) { | ||
return this.rootFields[a]; | ||
}; | ||
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) { | ||
@@ -611,5 +538,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; | ||
}; | ||
@@ -631,9 +558,10 @@ | ||
!function(a, b) { | ||
var c = getMainOperation(b.query); | ||
a = { | ||
variables: normalizeVariables(c, b.variables), | ||
fragments: getFragments(b.query), | ||
store: a | ||
}; | ||
invalidateSelection(a, a.store.getRootKey("query"), getSelectionSet(c)); | ||
var c = forkDependencies(); | ||
read(a, b); | ||
c.forEach((function(b) { | ||
b.startsWith(a.data.queryRootKey + ".") ? (b = b.slice((a.data.queryRootKey + ".").length), | ||
writeLink(a.data.queryRootKey, b), writeRecord(a.data.queryRootKey, b)) : a.invalidate(b); | ||
})); | ||
unforkDependencies(); | ||
gc(a.data); | ||
}(this, core.createRequest(a, b)); | ||
@@ -647,4 +575,4 @@ }; | ||
for (var c = this.inspectFields(b); a < c.length; a += 1) { | ||
var e = c[a]; | ||
readLink(b, e.fieldKey) ? writeLink(b, e.fieldKey, void 0) : writeRecord(b, e.fieldKey, void 0); | ||
var d = c[a]; | ||
readLink(b, d.fieldKey) ? writeLink(b, d.fieldKey, void 0) : writeRecord(b, d.fieldKey, void 0); | ||
} | ||
@@ -655,7 +583,7 @@ }; | ||
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) : []; | ||
@@ -678,3 +606,20 @@ }; | ||
Store.prototype.writeFragment = function(a, b, c) { | ||
writeFragment(this, a, b, c); | ||
!function(a, b, c, d) { | ||
b = getFragments(b); | ||
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(e); | ||
c = _rollupPluginBabelHelpers._extends({}, { | ||
__typename: f | ||
}, c); | ||
var g = a.keyOfEntity(c); | ||
if (!g) { | ||
return "production" !== process.env.NODE_ENV ? warn("Can't generate a key for writeFragment(...) data.\nYou have to pass an `id` or `_id` field or create a custom `keys` config for `" + f + "`.", 12) : void 0; | ||
} | ||
"production" !== process.env.NODE_ENV && pushDebugNode(f, e); | ||
a = makeContext(a, d || {}, b, f, g); | ||
writeSelection(a, g, getSelectionSet(e), c); | ||
}(this, a, b, c); | ||
}; | ||
@@ -688,16 +633,7 @@ | ||
}, read = function(a, b, c) { | ||
var e = getMainOperation(b.query), d = a.getRootKey(e.operation), f = getSelectionSet(e); | ||
a = { | ||
parentTypeName: d, | ||
parentKey: d, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
store: a, | ||
variables: normalizeVariables(e, b.variables), | ||
fragments: getFragments(b.query), | ||
partial: !1 | ||
}; | ||
"production" !== process.env.NODE_ENV && pushDebugNode(d, e); | ||
var d = getMainOperation(b.query), e = a.rootFields[d.operation], f = getSelectionSet(d); | ||
a = makeContext(a, normalizeVariables(d, b.variables), getFragments(b.query), e, e); | ||
"production" !== process.env.NODE_ENV && pushDebugNode(e, d); | ||
c = c || makeDict(); | ||
c = d !== a.store.getRootKey("query") ? readRoot(a, d, f, c) : readSelection(a, d, f, c); | ||
c = e !== a.store.rootFields.query ? readRoot(a, e, f, c) : readSelection(a, e, f, c); | ||
return { | ||
@@ -708,11 +644,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; | ||
} | ||
@@ -722,6 +658,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; | ||
} | ||
@@ -731,11 +667,11 @@ 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); | ||
@@ -748,33 +684,29 @@ if (!(c = "string" != typeof c ? a.keyOfEntity(_rollupPluginBabelHelpers._extends({}, { | ||
} | ||
"production" !== process.env.NODE_ENV && pushDebugNode(f, d); | ||
return readSelection({ | ||
parentTypeName: f, | ||
parentKey: c, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
variables: e || {}, | ||
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"); | ||
if ("string" == typeof g) { | ||
e.__typename = g; | ||
c = new SelectionIterator(g, b, c, a); | ||
for (var h, k = !1, m = !1; void 0 !== (h = c.next()); ) { | ||
var l = getName(h), n = getFieldArguments(h, a.variables), q = getFieldAlias(h), u = keyOfField(l, n), r = readRecord(b, u), t = joinKeys(b, u); | ||
"production" !== process.env.NODE_ENV && d.schema && g && isFieldAvailableOnType(d.schema, g, l); | ||
var p = void 0, v = d.resolvers[g]; | ||
if (void 0 !== v && "function" == typeof v[l]) { | ||
if (a.parentTypeName = g, a.parentKey = b, a.parentFieldKey = t, a.fieldName = l, | ||
void 0 !== r && (e[q] = r), p = v[l](e, n || makeDict(), d, a), void 0 !== h.selectionSet && (p = resolveResolverResult(a, g, l, t, getSelectionSet(h), e[q] || makeDict(), p)), | ||
d.schema && null === p && !isFieldNullable(d.schema, g, l)) { | ||
"production" !== process.env.NODE_ENV && pushDebugNode(f, e); | ||
a = makeContext(a, d || {}, b, f, c); | ||
return readSelection(a, c, getSelectionSet(e), makeDict()) || null; | ||
}, readSelection = function(a, b, c, d, e) { | ||
var f = a.store, g = b === f.rootFields.query, h = e && f.keyOfEntity(e) || b; | ||
if ("string" != typeof (b = g ? b : readRecord(h, "__typename") || e && e.__typename) || e && b !== e.__typename) { | ||
"production" !== process.env.NODE_ENV && warn("Invalid resolver data: The resolver at `" + h + "` returned an invalid typename that could not be reconciled with the cache.", 8); | ||
} else { | ||
d.__typename = b; | ||
c = new SelectionIterator(b, h, c, a); | ||
for (var k, m = !1, l = !1; void 0 !== (k = c.next()); ) { | ||
var n = getName(k), q = getFieldArguments(k, a.variables), r = getFieldAlias(k), w = keyOfField(n, q), u = joinKeys(h, w), t = readRecord(h, w), v = e ? e[n] : void 0, x = f.resolvers[b]; | ||
"production" !== process.env.NODE_ENV && f.schema && b && isFieldAvailableOnType(f.schema, b, n); | ||
var p = void 0; | ||
if (void 0 !== v && void 0 === k.selectionSet) { | ||
p = v; | ||
} else if (x && "function" == typeof x[n]) { | ||
if (updateContext(a, b, h, u, n), void 0 !== t && (d[r] = t), p = x[n](d, q || makeDict(), f, a), | ||
void 0 !== k.selectionSet && (p = resolveResolverResult(a, b, n, u, getSelectionSet(k), d[r] || makeDict(), p)), | ||
f.schema && null === p && !isFieldNullable(f.schema, b, n)) { | ||
return; | ||
} | ||
} else { | ||
void 0 === h.selectionSet ? p = r : void 0 !== (n = readLink(b, u)) ? p = resolveLink(a, n, g, l, getSelectionSet(h), e[q]) : "object" == typeof r && null !== r && (p = r); | ||
void 0 === k.selectionSet ? p = t : void 0 !== v ? p = resolveResolverResult(a, b, n, u, getSelectionSet(k), d[r], v) : void 0 !== (q = readLink(h, w)) ? p = resolveLink(a, q, b, n, getSelectionSet(k), d[r]) : "object" == typeof t && null !== t && (p = t); | ||
} | ||
if (void 0 === p && d.schema && isFieldNullable(d.schema, g, l)) { | ||
m = !0, e[q] = null; | ||
if (void 0 === p && f.schema && isFieldNullable(f.schema, b, n)) { | ||
l = !0, d[r] = null; | ||
} else { | ||
@@ -784,10 +716,10 @@ if (void 0 === p) { | ||
} | ||
k = !0; | ||
e[q] = p; | ||
m = !0; | ||
d[r] = p; | ||
} | ||
} | ||
m && (a.partial = !0); | ||
return f && m && !k ? void 0 : e; | ||
l && (a.partial = !0); | ||
return g && l && !m ? 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)) { | ||
@@ -797,3 +729,3 @@ var h = a.store; | ||
for (var k = Array(g.length), m = 0, l = g.length; m < l; m++) { | ||
var n = resolveResolverResult(a, b, c, joinKeys(e, "" + m), d, void 0 !== f ? f[m] : void 0, g[m]); | ||
var n = resolveResolverResult(a, b, c, joinKeys(d, "" + m), e, void 0 !== f ? f[m] : void 0, g[m]); | ||
if (void 0 !== n || h) { | ||
@@ -811,38 +743,11 @@ k[m] = void 0 !== n ? n : null; | ||
if (isDataOrKey(g)) { | ||
return b = void 0 === f ? makeDict() : f, "string" == typeof g ? readSelection(a, g, d, b) : function(a, b, c, e, d) { | ||
var f = a.store; | ||
b = f.keyOfEntity(d) || b; | ||
var g = d.__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; | ||
c = new SelectionIterator(h, b, c, a); | ||
for (var k = !1, m = !1; void 0 !== (g = c.next()); ) { | ||
var l = getName(g), n = getFieldAlias(g), q = keyOfField(l, getFieldArguments(g, a.variables)), u = joinKeys(b, q), r = readRecord(b, q), t = d[l]; | ||
"production" !== process.env.NODE_ENV && f.schema && h && isFieldAvailableOnType(f.schema, h, l); | ||
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, l, u, getSelectionSet(g), e[n], t) : void 0 !== (q = readLink(b, q)) ? p = resolveLink(a, q, h, l, getSelectionSet(g), e[n]) : "object" == typeof r && null !== r && (p = r); | ||
if (void 0 === p && void 0 !== f.schema && isFieldNullable(f.schema, h, l)) { | ||
m = !0, e[n] = null; | ||
} else { | ||
if (void 0 === p) { | ||
return; | ||
} | ||
k = !0; | ||
e[n] = p; | ||
} | ||
} | ||
m && (a.partial = !0); | ||
return k ? e : void 0; | ||
} | ||
}(a, e, d, b, g); | ||
return b = void 0 === f ? makeDict() : f, "string" == typeof g ? readSelection(a, g, e, b) : readSelection(a, d, e, b, g); | ||
} | ||
"production" !== process.env.NODE_ENV && warn("Invalid resolver value: The field at `" + e + "` is a scalar (number, boolean, etc), but the GraphQL query expects a selection set for this field.", 9); | ||
}, resolveLink = function(a, b, c, e, d, f) { | ||
"production" !== process.env.NODE_ENV && warn("Invalid resolver value: The field at `" + d + "` is a scalar (number, boolean, etc), but the GraphQL query expects a selection set for this field.", 9); | ||
}, resolveLink = function(a, b, c, d, e, f) { | ||
if (Array.isArray(b)) { | ||
var g = a.store; | ||
g = g.schema && isListNullable(g.schema, c, e); | ||
g = g.schema && isListNullable(g.schema, c, d); | ||
for (var h = Array(b.length), k = 0, m = b.length; k < m; k++) { | ||
var l = resolveLink(a, b[k], c, e, d, void 0 !== f ? f[k] : void 0); | ||
var l = resolveLink(a, b[k], c, d, e, void 0 !== f ? f[k] : void 0); | ||
if (void 0 !== l || g) { | ||
@@ -856,3 +761,3 @@ h[k] = void 0 !== l ? l : null; | ||
} | ||
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) { | ||
@@ -868,14 +773,2 @@ return "string" == typeof a || "object" == typeof a && "string" == typeof a.__typename; | ||
}); | ||
}, addTypeNames = function(a) { | ||
return _rollupPluginBabelHelpers._extends({}, a, { | ||
query: core.formatDocument(a.query) | ||
}); | ||
}, getRequestPolicy = function(a) { | ||
return a.context.requestPolicy; | ||
}, isQueryOperation = function(a) { | ||
return "query" === a.operationName; | ||
}, isMutationOperation = function(a) { | ||
return "mutation" === a.operationName; | ||
}, isCacheableQuery = function(a) { | ||
return isQueryOperation(a) && "network-only" !== getRequestPolicy(a); | ||
}, toRequestPolicy = function(a, b) { | ||
@@ -890,23 +783,29 @@ return _rollupPluginBabelHelpers._extends({}, a, { | ||
function _ref3$1(a) { | ||
return isCacheableQuery(a); | ||
return _rollupPluginBabelHelpers._extends({}, a, { | ||
query: core.formatDocument(a.query) | ||
}); | ||
} | ||
function _ref4$1(a) { | ||
return addCacheOutcome(a.operation, a.outcome); | ||
return "query" === a.operationName && "network-only" !== a.context.requestPolicy; | ||
} | ||
function _ref5(a) { | ||
return addCacheOutcome(a.operation, "miss"); | ||
} | ||
function _ref6(a) { | ||
return "miss" === a.outcome; | ||
} | ||
function _ref7(a) { | ||
function _ref8(a) { | ||
return "miss" !== a.outcome; | ||
} | ||
function _ref8(a) { | ||
function _ref9(a) { | ||
return "cache-only" !== a.context.requestPolicy; | ||
} | ||
function _ref9(a) { | ||
return !isCacheableQuery(a); | ||
function _ref10(a) { | ||
return !("query" === a.operationName && "network-only" !== a.context.requestPolicy); | ||
} | ||
@@ -920,4 +819,4 @@ | ||
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; | ||
a = { | ||
@@ -929,3 +828,3 @@ operation: addCacheOutcome(b, c), | ||
}; | ||
if ("cache-and-network" === d || "cache-first" === d && "partial" === c) { | ||
if ("cache-and-network" === b.context.requestPolicy || "cache-first" === b.context.requestPolicy && "partial" === c) { | ||
a.stale = !0, f.reexecuteOperation(toRequestPolicy(b, "network-only")); | ||
@@ -935,32 +834,29 @@ } | ||
} | ||
var d = b.forward, f = b.client; | ||
var e = b.forward, f = b.client; | ||
a || (a = {}); | ||
var g = new Store(a.schema, a.resolvers, a.updates, a.optimistic, a.keys); | ||
if (a.storage) { | ||
var h = a.storage; | ||
var k = h.read().then((function c(a) { | ||
!function(a, b, c) { | ||
initDataState(a, null); | ||
for (var e in c) { | ||
var d = e.indexOf("."), f = e.slice(2, d); | ||
d = e.slice(d + 1); | ||
switch (e.charCodeAt(0)) { | ||
case 108: | ||
writeLink(f, d, c[e]); | ||
break; | ||
var h, g = new Store(a.schema, a.resolvers, a.updates, a.optimistic, a.keys); | ||
a.storage && (h = a.storage.read().then((function c(b) { | ||
!function(a, b, c) { | ||
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, e, c[d]); | ||
break; | ||
case 114: | ||
writeRecord(f, d, c[e]); | ||
} | ||
case 114: | ||
writeRecord(f, e, c[d]); | ||
} | ||
clearDataState(); | ||
a.storage = b; | ||
}(g.data, h, a); | ||
})); | ||
} | ||
var m = new Map, l = new Map, n = makeDict(), q = function(a, b) { | ||
void 0 !== b && b.forEach((function c(b) { | ||
var c = n[b]; | ||
if (void 0 !== c) { | ||
n[b] = []; | ||
} | ||
clearDataState(); | ||
a.storage = b; | ||
}(g.data, a.storage, b); | ||
}))); | ||
var k = new Map, m = new Map, l = makeDict(), n = function(a, b) { | ||
b && b.forEach((function c(b) { | ||
var c = l[b]; | ||
if (c) { | ||
l[b] = []; | ||
b = 0; | ||
@@ -972,47 +868,40 @@ for (var d = c.length; b < d; b++) { | ||
})); | ||
}, u = function(a, b) { | ||
}, q = function(a, b) { | ||
b.forEach((function(b) { | ||
if (b !== a.key) { | ||
var c = l.get(b); | ||
void 0 !== c && (l.delete(b), f.reexecuteOperation(toRequestPolicy(c, "cache-first"))); | ||
var c = m.get(b); | ||
c && (m.delete(b), f.reexecuteOperation(toRequestPolicy(c, "cache-first"))); | ||
} | ||
})); | ||
}, r = function(a) { | ||
isQueryOperation(a) ? reserveLayer(g.data, a.key) : "teardown" === a.operationName && noopDataState(g.data, a.key); | ||
}, t = function(a) { | ||
"query" === a.operationName ? reserveLayer(g.data, a.key) : "teardown" === a.operationName && noopDataState(g.data, a.key); | ||
}, w = function(a) { | ||
var b = a.key; | ||
if (function(a) { | ||
return isMutationOperation(a) && "network-only" !== getRequestPolicy(a); | ||
}(a)) { | ||
if ("mutation" === a.operationName && "network-only" !== a.context.requestPolicy) { | ||
var 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 && (k.set(b, c), b = new Set, n(b, c), q(a, b)); | ||
} else { | ||
noopDataState(g.data, b, !0); | ||
} | ||
}, p = function(a, b) { | ||
}, u = function(a, b) { | ||
b.forEach((function(b) { | ||
(n[b] || (n[b] = [])).push(a.key); | ||
l.has(a.key) || l.set(a.key, "network-only" === getRequestPolicy(a) ? toRequestPolicy(a, "cache-and-network") : a); | ||
(l[b] || (l[b] = [])).push(a.key); | ||
m.has(a.key) || m.set(a.key, "network-only" === a.context.requestPolicy ? toRequestPolicy(a, "cache-and-network") : a); | ||
})); | ||
}, v = function(a) { | ||
var b = query(g, a), c = b.data, d = b.dependencies; | ||
b = b.partial; | ||
null === c ? d = "miss" : (p(a, d), d = b && "cache-only" !== getRequestPolicy(a) ? "partial" : "hit"); | ||
}, t = function(a) { | ||
var b = query(g, a), c = b.data ? b.partial && "cache-only" !== a.context.requestPolicy ? "partial" : "hit" : "miss"; | ||
b.data && u(a, b.dependencies); | ||
return { | ||
outcome: d, | ||
outcome: c, | ||
operation: a, | ||
data: c | ||
data: b.data | ||
}; | ||
}, w = function(a) { | ||
var b = a.operation, c = a.error, d = a.extensions, e = isQueryOperation(b), f = a.data, h = b.key, k = new Set; | ||
isMutationOperation(b) ? (q(k, m.get(h)), m.delete(h)) : function(a) { | ||
return "subscription" === a.operationName; | ||
}(b) && reserveLayer(g.data, b.key); | ||
if (null != f) { | ||
var l = write(g, b, f, h).dependencies; | ||
if (e) { | ||
f = (h = query(g, b)).data; | ||
var n = h.dependencies; | ||
} else { | ||
f = query(g, b, f).data; | ||
}, v = function(a) { | ||
var b = a.operation, c = a.error, d = a.extensions, e = b.key, f = new Set; | ||
"mutation" === b.operationName ? (n(f, k.get(e)), k.delete(e)) : "subscription" === b.operationName && reserveLayer(g.data, b.key); | ||
if (a.data) { | ||
if (e = write(g, b, a.data, e).dependencies, n(f, e), e = query(g, b, a.data), a.data = e.data, | ||
"query" === b.operationName) { | ||
var h = e.dependencies; | ||
n(f, h); | ||
} | ||
@@ -1022,8 +911,6 @@ } else { | ||
} | ||
q(k, l); | ||
e && q(k, n); | ||
u(a.operation, k); | ||
e && void 0 !== n && p(a.operation, n); | ||
q(a.operation, f); | ||
h && u(a.operation, h); | ||
return { | ||
data: f, | ||
data: a.data, | ||
error: c, | ||
@@ -1036,8 +923,8 @@ extensions: d, | ||
a = wonka.share(a); | ||
var b = k ? wonka.mergeMap(wonka.fromArray)(wonka.take(1)(wonka.buffer(wonka.fromPromise(k))(a))) : wonka.empty; | ||
a = wonka.share(wonka.tap(t)(wonka.map(addTypeNames)(wonka.concat([ b, a ])))); | ||
var c = wonka.share(wonka.map(v)(wonka.filter(_ref3$1)(a))); | ||
b = wonka.map(_ref4$1)(wonka.filter(_ref5)(c)); | ||
c = wonka.map(e)(wonka.filter(_ref7)(c)); | ||
a = wonka.map(w)(d(wonka.tap(r)(wonka.filter(_ref8)(wonka.merge([ wonka.filter(_ref9)(a), b ]))))); | ||
var b = h ? wonka.mergeMap(wonka.fromArray)(wonka.take(1)(wonka.buffer(wonka.fromPromise(h))(a))) : wonka.empty; | ||
a = wonka.share(wonka.tap(w)(wonka.map(_ref3$1)(wonka.concat([ b, a ])))); | ||
var c = wonka.share(wonka.map(t)(wonka.filter(_ref4$1)(a))); | ||
b = wonka.map(_ref5)(wonka.filter(_ref6)(c)); | ||
c = wonka.map(d)(wonka.filter(_ref8)(c)); | ||
a = wonka.map(v)(e(wonka.tap(r)(wonka.filter(_ref9)(wonka.merge([ wonka.filter(_ref10)(a), b ]))))); | ||
return wonka.merge([ a, c ]); | ||
@@ -1048,15 +935,11 @@ }; | ||
exports.clearDataState = clearDataState; | ||
exports.noopDataState = noopDataState; | ||
exports.initDataState = initDataState; | ||
exports.query = query; | ||
exports.read = read; | ||
exports.reserveLayer = reserveLayer; | ||
exports.write = write; | ||
exports.writeFragment = writeFragment; | ||
exports.writeOptimistic = writeOptimistic; | ||
//# sourceMappingURL=urql-exchange-graphcache.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("./5329e1b9.cjs.min.js"),t=require("graphql"),n=require("@urql/core"),r=require("wonka"),i=require("@urql/exchange-populate"),o=function(e){return e.name.value},a=function(e){return e.typeCondition.name.value},s=function(e){return void 0!==e.alias?e.alias.value:o(e)},u=function(e){return void 0!==e.selectionSet?e.selectionSet.selections:[]},c=function(e){return void 0!==(e=e.typeCondition)?o(e):null},l=function(e){return e.kind===t.Kind.FIELD},f=function(e){return e.kind===t.Kind.INLINE_FRAGMENT},d=function(){return Object.create(null)},p=function(e,n){if(void 0===e.arguments||0===e.arguments.length)return null;for(var r=d(),i=0,a=0,s=e.arguments.length;a<s;a++){var u=e.arguments[a],c=t.valueFromASTUntyped(u.value,n);null!=c&&(r[o(u)]=c,i++)}return 0<i?r:null},y=function(e,n){if(void 0===e.variableDefinitions)return{};var r=n||{};return e.variableDefinitions.reduce((function(e,n){var i=o(n.variable),a=r[i];if(void 0===a){if(void 0===n.defaultValue)return e;a=t.valueFromASTUntyped(n.defaultValue,r)}return e[i]=a,e}),d())};function v(e,t,n){if(!e)throw(e=Error((t||"Minfied Error #"+n+"\n")+"\nhttps://bit.ly/38yWDau#"+n)).name="Graphcache Error",e}var m=function(e){return e.kind===t.Kind.FRAGMENT_DEFINITION};function h(e){return e.kind===t.Kind.OPERATION_DEFINITION}var g=function(e){return v(!!(e=e.definitions.find(h)),"",1),e};function k(e,t){return e[o(t)]=t,e}var b=function(e){return e.definitions.filter(m).reduce(k,{})},x=function(e,n){if(void 0===(e=e.directives))return!0;for(var r=0,i=e.length;r<i;r++){var a=e[r],s=o(a),u="include"===s;if((u||"skip"===s)&&(a=a.arguments?a.arguments[0]:null)&&"if"===o(a)&&("boolean"==typeof(a=t.valueFromASTUntyped(a.value,n))||null===a))return u?!!a:!a}return!0},_=function(e,n,r){return void 0!==(e=O(e,n,r))&&t.isNullableType(e.type)},S=function(e,n,r){return void 0!==(e=O(e,n,r))&&(e=t.isNonNullType(e.type)?e.type.ofType:e.type,t.isListType(e)&&t.isNullableType(e.ofType))},K=function(e,n,r){return!(!r||!n)&&(r===n||(n=e.getType(n),r=e.getType(r),n instanceof t.GraphQLObjectType?n===r:(function(e,n){v(e instanceof t.GraphQLInterfaceType||e instanceof t.GraphQLUnionType,"",5)}(n),q(r),e.isPossibleType(n,r))))},O=function(e,t,n){if(q(e=e.getType(t)),void 0!==(n=e.getFields()[n]))return n};function q(e,n){v(e instanceof t.GraphQLObjectType,"",3)}var N=function(e,t){return t?e+"("+n.stringifyVariables(t)+")":e},w=function(e){var t=e.indexOf("(");return-1<t?{fieldKey:e,fieldName:e.slice(0,t),arguments:JSON.parse(e.slice(t+1,-1))}:{fieldKey:e,fieldName:e,arguments:null}},T=function(e,t){return e+"."+t},E=function(e,t){return e+"|"+t},A="undefined"!=typeof Promise?Promise.prototype.then.bind(Promise.resolve()):function(e){return setTimeout(e,0)},F=null,R=null,L=null,M=function(){return{optimistic:d(),base:new Map}},B=function(e,t,n){F=e,R=new Set,t?n||1<e.optimisticOrder.length&&-1<e.optimisticOrder.indexOf(t)?(n||e.commutativeKeys.has(t)||(ee(e,t),e.commutativeKeys.add(t)),L=t,$(e,t)):(L=null,te(e,t)):L=null},Q=function(){var e=F,t=L;if(L=null,t&&-1<e.optimisticOrder.indexOf(t)){t=e.optimisticOrder.length-e.commutativeKeys.size;for(var n=e.optimisticOrder.length;--n>=t&&e.refLock[e.optimisticOrder[n]]&&e.commutativeKeys.has(e.optimisticOrder[n]);)ie(e.optimisticOrder[n])}R=F=null,!e.gcScheduled&&0<e.gcBatch.size&&(e.gcScheduled=!0,A((function(){V(e)}))),e.storage&&!e.persistenceScheduled&&(e.persistenceScheduled=!0,A((function(){e.storage.write(e.persistenceBatch),e.persistenceScheduled=!1,e.persistenceBatch=d()})))},I=function(e,t,n){B(e,t,n),Q()},j=function(){return v(null!==R,"",2),R},C=function(e,t,n,r){var i=(e=L?e.optimistic[L]:e.base).get(t);void 0===i&&e.set(t,i=d()),void 0!==r||L?i[n]=r:delete i[n]},D=function(e,t,n){for(var r,i=0,o=F.optimisticOrder.length;i<o;i++){var a=e.optimistic[F.optimisticOrder[i]];if(a&&void 0!==(r=a.get(t))&&n in r)return r[n]}return void 0!==(r=e.base.get(t))?r[n]:void 0},P=function(e,t,n,r){var i=void 0!==t[n]?t[n]:0;t=t[n]=i+r|0,void 0!==e&&(0>=t?e.add(n):0>=i&&0<t&&e.delete(n))},G=function(e,t,n,r){if("string"==typeof n)P(e,t,n,r);else if(Array.isArray(n))for(var i=0,o=n.length;i<o;i++){var a=n[i];a&&P(e,t,a,r)}},U=function(e,t,n){if(void 0!==n)for(var r in n)t.has(r)||(e.push(w(r)),t.add(r))},z=function(e,t,n,r){U(e,t,r.base.get(n));for(var i=0,o=F.optimisticOrder.length;i<o;i++)U(e,t,r.optimistic[F.optimisticOrder[i]].get(n))},V=function(e){e.gcScheduled=!1,e.gcBatch.forEach((function(t){if(0>=(e.refCount[t]||0)){for(var n in e.refLock){var r=e.refLock[n];if(0<(r[t]||0))return;delete r[t]}if(delete e.refCount[t],e.gcBatch.delete(t),void 0!==(n=e.records.base.get(t))&&(e.records.base.delete(t),e.storage))for(var i in n)n=E("r",T(t,i)),e.persistenceBatch[n]=void 0;if(void 0!==(i=e.links.base.get(t)))for(var o in e.links.base.delete(t),i)e.storage&&(n=E("l",T(t,o)),e.persistenceBatch[n]=void 0),G(e.gcBatch,e.refCount,i[o],-1)}else e.gcBatch.delete(t)}))},W=function(e,t){"__typename"!==t&&(e!==F.queryRootKey?R.add(e):void 0!==t&&R.add(T(e,t)))},J=function(e,t){return W(e,t),D(F.records,e,t)},H=function(e,t){return W(e,t),D(F.links,e,t)},X=function(e,t,n){W(e,t),C(F.records,e,t,n),F.storage&&!L&&(e=E("r",T(e,t)),F.persistenceBatch[e]=n)},Y=function(e,t,n){var r=F;if(L)var i=r.refLock[L]||(r.refLock[L]=d()),o=r.links.optimistic[L];else{r.storage&&(i=E("l",T(e,t)),r.persistenceBatch[i]=n),i=r.refCount,o=r.links.base;var a=r.gcBatch}o=void 0!==(o=void 0!==o?o.get(e):void 0)?o[t]:null,W(e,t),C(r.links,e,t,n),G(a,i,o,-1),G(a,i,n,1)},Z=function(e,t){e.commutativeKeys.has(t)||(e.optimisticOrder.unshift(t),e.commutativeKeys.add(t))},$=function(e,t){-1===e.optimisticOrder.indexOf(t)&&e.optimisticOrder.unshift(t),e.refLock[t]||(e.refLock[t]=d(),e.links.optimistic[t]=new Map,e.records.optimistic[t]=new Map)},ee=function(e,t){e.refLock[t]&&(delete e.refLock[t],delete e.records.optimistic[t],delete e.links.optimistic[t])},te=function(e,t){var n=e.optimisticOrder.indexOf(t);-1<n&&(e.optimisticOrder.splice(n,1),e.commutativeKeys.delete(t)),ee(e,t)};function ne(e,t){for(var n in e)Y(t,n,e[n])}function re(e,t){for(var n in e)X(t,n,e[n])}var ie=function(e){var t=R;R=new Set;var n=F.links.optimistic[e];n&&n.forEach(ne),(n=F.records.optimistic[e])&&n.forEach(re),R=t,te(F,e)},oe=function(e,t,n,r){return!(!t||t!==c(e)&&u(e).some((function(e){return!!l(e)&&(e=N(o(e),p(e,r)),!function(e,t){return void 0!==J(e,t)||void 0!==H(e,t)}(n,e))})))},ae=function(e,t,n,r){this.typename=e,this.entityKey=t,this.context=r,this.indexStack=[0],this.selectionStack=[n]};ae.prototype.next=function(){for(;0!==this.indexStack.length;){var e=this.indexStack[this.indexStack.length-1]++,t=this.selectionStack[this.selectionStack.length-1];if(e>=t.length)this.indexStack.pop(),this.selectionStack.pop();else if(x(e=t[e],this.context.variables))if(l(e)){if("__typename"!==o(e))return e}else void 0!==(e=f(e)?e:this.context.fragments[o(e)])&&(this.context.store.schema?K(this.context.store.schema,c(e),this.typename):oe(e,this.typename,this.entityKey,this.context.variables))&&(this.indexStack.push(0),this.selectionStack.push(u(e)))}};var se=function(e){return void 0===e?null:e},ue=function(e,t,n,r){return B(e.data,r||null),e=ce(e,t,n),Q(),e},ce=function(e,t,n){var r=g(t.query),i={dependencies:j()},o=u(r),a=e.getRootKey(r.operation);return a===(e={parentTypeName:a,parentKey:a,parentFieldKey:"",fieldName:"",store:e,variables:y(r,t.variables),fragments:b(t.query)}).store.getRootKey("query")?de(e,a,o,n):ye(e,a,o,n),i},le=function(e,t,n){B(e.data,n,!0);var r=g(t.query);n={dependencies:j()};var i,a=e.getRootKey("mutation"),s=e.getRootKey(r.operation);for(v(s===a,"",10),e={parentTypeName:a,parentKey:a,parentFieldKey:"",fieldName:"",variables:y(r,t.variables),fragments:b(t.query),store:e,optimistic:!0},t=d(),r=new ae(s,s,u(r),e);void 0!==(i=r.next());)if(void 0!==i.selectionSet){var c=o(i),l=e.store.optimisticMutations[c];if(void 0!==l){e.fieldName=c,l=l((s=p(i,e.variables))||d(),e.store,e);var f=se(l);ve(e,f,u(i)),t[c]=l,void 0!==(i=e.store.updates[a][c])&&i(t,s||d(),e.store,e)}}return Q(),n},fe=function(t,n,r,i){n=b(n);var o=Object.keys(n);if(void 0!==(o=n[o[0]])){var s=a(o);r=e._extends({},{__typename:s},r);var c=t.keyOfEntity(r);c&&de({parentTypeName:s,parentKey:c,parentFieldKey:"",fieldName:"",variables:i||{},fragments:n,store:t},c,u(o),r)}},de=function(e,t,n,r){var i=t===e.store.getRootKey("query")?t:r.__typename;if("string"==typeof i)for(X(t,"__typename",i),n=new ae(i,t,n,e);void 0!==(i=n.next());){var a=o(i),c=p(i,e.variables);a=N(a,c);var l=r[s(i)];c=T(t,a),void 0===i.selectionSet?X(t,a,l):(l=se(l),i=pe(e,c,u(i),l),Y(t,a,i))}},pe=function(e,t,n,r){if(Array.isArray(r)){for(var i=Array(r.length),o=0,a=r.length;o<a;o++){var s=r[o],u=T(t,""+o);s=pe(e,u,n,s),i[o]=s}return i}return null===r?null:(t=null!==(i=e.store.keyOfEntity(r))?i:t,o=r.__typename,void 0!==e.store.keys[r.__typename]||null!==i||"string"!=typeof o||o.endsWith("Connection")||o.endsWith("Edge"),de(e,t,n,r),t)},ye=function(e,t,n,r){var i,a=t===e.store.getRootKey("mutation")||t===e.store.getRootKey("subscription");for(n=new ae(t,t,n,e);void 0!==(i=n.next());){var c=o(i),l=p(i,e.variables),f=T(t,N(c,l));if(void 0!==i.selectionSet){var y=se(r[s(i)]);ve(e,y,u(i))}a&&(e.parentTypeName=t,e.parentKey=t,e.parentFieldKey=f,e.fieldName=c,void 0!==(i=e.store.updates[t][c])&&i(r,l||d(),e.store,e))}},ve=function(e,t,n){if(Array.isArray(t)){for(var r=Array(t.length),i=0,o=t.length;i<o;i++)r[i]=ve(e,t[i],n);return r}null!==t&&(null!==(r=e.store.keyOfEntity(t))?de(e,r,n,t):ye(e,t.__typename,n,t))},me=function(e,t,n){if("Query"!==t){var r=J(t,"__typename");if("string"!=typeof r)return;X(t,"__typename",void 0)}else r=t;for(n=new ae(r,t,n,e);void 0!==(r=n.next());){var i=o(r),a=N(i,p(r,e.variables));if(void 0===r.selectionSet)X(t,a,void 0);else if(r=u(r),i=H(t,a),Y(t,a,void 0),X(t,a,void 0),Array.isArray(i)){a=0;for(var s=i.length;a<s;a++){var c=i[a];null!==c&&me(e,c,r)}}else i&&me(e,i,r)}},he=function(e,n,r,i,o){var a,s=this;this.gcScheduled=!1,this.gc=function(){V(s.data),s.gcScheduled=!1},this.keyOfField=N,this.resolvers=n||{},this.optimisticMutations=i||{},this.keys=o||{},this.updates={Mutation:r&&r.Mutation||{},Subscription:r&&r.Subscription||{}},e?(r=(n=this.schema=t.buildClientSchema(e)).getQueryType(),e=n.getMutationType(),n=n.getSubscriptionType(),this.rootFields={query:r=r?r.name:"Query",mutation:e=e?e.name:"Mutation",subscription:n=n?n.name:"Subscription"},this.rootNames=((a={})[r]="query",a[e]="mutation",a[n]="subscription",a)):(this.rootFields={query:"Query",mutation:"Mutation",subscription:"Subscription"},this.rootNames={Query:"query",Mutation:"mutation",Subscription:"subscription"}),this.data=function(e){return{persistenceScheduled:!1,persistenceBatch:d(),gcScheduled:!1,queryRootKey:e,gcBatch:new Set,refCount:d(),refLock:d(),links:M(),records:M(),commutativeKeys:new Set,optimisticOrder:[],storage:null}}(this.getRootKey("query"))};he.prototype.getRootKey=function(e){return this.rootFields[e]},he.prototype.keyOfEntity=function(e){var t,n=e.__typename,r=e.id,i=e._id;return n?void 0!==this.rootNames[n]?n:(this.keys[n]?t=this.keys[n](e):null!=r?t=""+r:null!=i&&(t=""+i),t?n+":"+t:null):null},he.prototype.resolveFieldByKey=function(e,t){if(null===(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e))return null;var n=J(e,t);return void 0!==n?n:(t=H(e,t))?t:null},he.prototype.resolve=function(e,t,n){return this.resolveFieldByKey(e,N(t,n))},he.prototype.invalidateQuery=function(e,t){!function(e,t){var n=g(t.query);e={variables:y(n,t.variables),fragments:b(t.query),store:e},me(e,e.store.getRootKey("query"),u(n))}(this,n.createRequest(e,t))},he.prototype.invalidate=function(e){v(e="string"==typeof e?e:this.keyOfEntity(e),"",19);for(var t=0,n=this.inspectFields(e);t<n.length;t+=1){var r=n[t];H(e,r.fieldKey)?Y(e,r.fieldKey,void 0):X(e,r.fieldKey,void 0)}},he.prototype.inspectFields=function(e){return null!==(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e)?function(e){var t=F.links,n=F.records,r=[],i=new Set;return W(e),z(r,i,e,t),z(r,i,e,n),r}(e):[]},he.prototype.updateQuery=function(e,t){e=n.createRequest(e.query,e.variables),null!==(t=t(this.readQuery(e)))&&ce(this,e,t)},he.prototype.readQuery=function(e){return ke(this,n.createRequest(e.query,e.variables)).data},he.prototype.readFragment=function(e,t,n){return _e(this,e,t,n)},he.prototype.writeFragment=function(e,t,n){fe(this,e,t,n)};var ge=function(e,t,n){return B(e.data,null),e=ke(e,t,n),Q(),e},ke=function(e,t,n){var r=g(t.query),i=e.getRootKey(r.operation),o=u(r);return e={parentTypeName:i,parentKey:i,parentFieldKey:"",fieldName:"",store:e,variables:y(r,t.variables),fragments:b(t.query),partial:!1},n=n||d(),n=i!==e.store.getRootKey("query")?be(e,i,o,n):Se(e,i,o,n),{dependencies:j(),partial:void 0!==n&&e.partial,data:void 0===n?null:n}},be=function(e,t,n,r){if("string"!=typeof r.__typename)return r;t=new ae(t,t,n,e),(n=d()).__typename=r.__typename;for(var i;void 0!==(i=t.next());){var o=s(i),a=r[o];void 0!==i.selectionSet&&null!==a?(a=se(a),n[o]=xe(e,u(i),a)):n[o]=a}return n},xe=function(e,t,n){if(Array.isArray(n)){for(var r=Array(n.length),i=0,o=n.length;i<o;i++)r[i]=xe(e,t,n[i]);return r}return null===n?null:null!==(r=e.store.keyOfEntity(n))?void 0===(e=Se(e,r,t,d()))?null:e:be(e,n.__typename,t,n)},_e=function(t,n,r,i){n=b(n);var o=Object.keys(n);if(void 0===(o=n[o[0]]))return null;var s=a(o);return"string"==typeof r||r.__typename||(r.__typename=s),(r="string"!=typeof r?t.keyOfEntity(e._extends({},{__typename:s},r)):r)&&Se({parentTypeName:s,parentKey:r,parentFieldKey:"",fieldName:"",variables:i||{},fragments:n,partial:!1,store:t},r,u(o),d())||null},Se=function(e,t,n,r){var i=e.store,a=t===i.getRootKey("query"),c=a?t:J(t,"__typename");if("string"==typeof c){r.__typename=c,n=new ae(c,t,n,e);for(var l,f=!1,y=!1;void 0!==(l=n.next());){var v=o(l),m=p(l,e.variables),h=s(l),g=N(v,m),k=J(t,g),b=T(t,g),x=void 0,S=i.resolvers[c];if(void 0!==S&&"function"==typeof S[v]){if(e.parentTypeName=c,e.parentKey=t,e.parentFieldKey=b,e.fieldName=v,void 0!==k&&(r[h]=k),x=S[v](r,m||d(),i,e),void 0!==l.selectionSet&&(x=Ke(e,c,v,b,u(l),r[h]||d(),x)),i.schema&&null===x&&!_(i.schema,c,v))return}else void 0===l.selectionSet?x=k:void 0!==(m=H(t,g))?x=Oe(e,m,c,v,u(l),r[h]):"object"==typeof k&&null!==k&&(x=k);if(void 0===x&&i.schema&&_(i.schema,c,v))y=!0,r[h]=null;else{if(void 0===x)return;f=!0,r[h]=x}}return y&&(e.partial=!0),a&&y&&!f?void 0:r}},Ke=function(e,t,n,r,i,a,c){if(Array.isArray(c)){var l=e.store;l=!l.schema||S(l.schema,t,n);for(var f=Array(c.length),y=0,v=c.length;y<v;y++){var m=Ke(e,t,n,T(r,""+y),i,void 0!==a?a[y]:void 0,c[y]);if(void 0===m&&!l)return;f[y]=void 0!==m?m:null}return f}return null==c?c:qe(c)?(t=void 0===a?d():a,"string"==typeof c?Se(e,c,i,t):function(e,t,n,r,i){var a=e.store;t=a.keyOfEntity(i)||t;var c=i.__typename,l=J(t,"__typename")||c;if(!("string"!=typeof l||c&&l!==c)){r.__typename=l,n=new ae(l,t,n,e);for(var f=!1,d=!1;void 0!==(c=n.next());){var y=o(c),v=s(c),m=N(y,p(c,e.variables)),h=T(t,m),g=J(t,m),k=i[y],b=void 0;if(void 0!==k&&void 0===c.selectionSet?b=k:void 0===c.selectionSet?b=g:void 0!==k?b=Ke(e,l,y,h,u(c),r[v],k):void 0!==(m=H(t,m))?b=Oe(e,m,l,y,u(c),r[v]):"object"==typeof g&&null!==g&&(b=g),void 0===b&&void 0!==a.schema&&_(a.schema,l,y))d=!0,r[v]=null;else{if(void 0===b)return;f=!0,r[v]=b}}return d&&(e.partial=!0),f?r:void 0}}(e,r,i,t,c)):void 0},Oe=function(e,t,n,r,i,o){if(Array.isArray(t)){var a=e.store;a=a.schema&&S(a.schema,n,r);for(var s=Array(t.length),u=0,c=t.length;u<c;u++){var l=Oe(e,t[u],n,r,i,void 0!==o?o[u]:void 0);if(void 0===l&&!a)return;s[u]=void 0!==l?l:null}return s}return null===t?null:Se(e,t,i,void 0===o?d():o)},qe=function(e){return"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename},Ne=function(t,n){return e._extends({},t,{context:e._extends({},t.context,{meta:e._extends({},t.context.meta,{cacheOutcome:n})})})},we=function(t){return e._extends({},t,{query:n.formatDocument(t.query)})},Te=function(e){return e.context.requestPolicy},Ee=function(e){return"query"===e.operationName},Ae=function(e){return"mutation"===e.operationName},Fe=function(e){return Ee(e)&&"network-only"!==Te(e)},Re=function(t,n){return e._extends({},t,{context:e._extends({},t.context,{requestPolicy:n})})};function Le(e){return Fe(e)}function Me(e){return Ne(e.operation,e.outcome)}function Be(e){return"miss"===e.outcome}function Qe(e){return"miss"!==e.outcome}function Ie(e){return"cache-only"!==e.context.requestPolicy}function je(e){return!Fe(e)}exports.populateExchange=i.populateExchange,exports.Store=he,exports.cacheExchange=function(e){return function(t){function n(e){var t=e.operation,n=e.outcome,r=Te(t);return e={operation:Ne(t,n),data:e.data,error:e.error,extensions:e.extensions},("cache-and-network"===r||"cache-first"===r&&"partial"===n)&&(e.stale=!0,o.reexecuteOperation(Re(t,"network-only"))),e}var i=t.forward,o=t.client;e||(e={});var a=new he(e.schema,e.resolvers,e.updates,e.optimistic,e.keys);if(e.storage)var s=e.storage,u=s.read().then((function(e){!function(e,t,n){for(var r in B(e,null),n){var i=r.indexOf("."),o=r.slice(2,i);switch(i=r.slice(i+1),r.charCodeAt(0)){case 108:Y(o,i,n[r]);break;case 114:X(o,i,n[r])}}Q(),e.storage=t}(a.data,s,e)}));var c=new Map,l=new Map,f=d(),p=function(e,t){void 0!==t&&t.forEach((function(t){var n=f[t];if(void 0!==n){f[t]=[],t=0;for(var r=n.length;t<r;t++)e.add(n[t])}}))},y=function(e,t){t.forEach((function(t){if(t!==e.key){var n=l.get(t);void 0!==n&&(l.delete(t),o.reexecuteOperation(Re(n,"cache-first")))}}))},v=function(e){Ee(e)?Z(a.data,e.key):"teardown"===e.operationName&&I(a.data,e.key)},m=function(e){var t=e.key;if(function(e){return Ae(e)&&"network-only"!==Te(e)}(e)){var n=le(a,e,t).dependencies;0!==n.size&&(c.set(t,n),t=new Set,p(t,n),y(e,t))}else I(a.data,t,!0)},h=function(e,t){t.forEach((function(t){(f[t]||(f[t]=[])).push(e.key),l.has(e.key)||l.set(e.key,"network-only"===Te(e)?Re(e,"cache-and-network"):e)}))},g=function(e){var t=ge(a,e),n=t.data,r=t.dependencies;return t=t.partial,null===n?r="miss":(h(e,r),r=t&&"cache-only"!==Te(e)?"partial":"hit"),{outcome:r,operation:e,data:n}},k=function(e){var t=e.operation,n=e.error,r=e.extensions,i=Ee(t),o=e.data,s=t.key,u=new Set;if(Ae(t)?(p(u,c.get(s)),c.delete(s)):function(e){return"subscription"===e.operationName}(t)&&Z(a.data,t.key),null!=o){var l=ue(a,t,o,s).dependencies;if(i){o=(s=ge(a,t)).data;var f=s.dependencies}else o=ge(a,t,o).data}else I(a.data,t.key);return p(u,l),i&&p(u,f),y(e.operation,u),i&&void 0!==f&&h(e.operation,f),{data:o,error:n,extensions:r,operation:t}};return function(e){e=r.share(e);var t=u?r.mergeMap(r.fromArray)(r.take(1)(r.buffer(r.fromPromise(u))(e))):r.empty;e=r.share(r.tap(m)(r.map(we)(r.concat([t,e]))));var o=r.share(r.map(g)(r.filter(Le)(e)));return t=r.map(Me)(r.filter(Be)(o)),o=r.map(n)(r.filter(Qe)(o)),e=r.map(k)(i(r.tap(v)(r.filter(Ie)(r.merge([r.filter(je)(e),t]))))),r.merge([e,o])}}},exports.clearDataState=Q,exports.initDataState=B,exports.query=ge,exports.read=ke,exports.write=ue,exports.writeFragment=fe,exports.writeOptimistic=le; | ||
"use strict";var e=require("./5329e1b9.cjs.min.js"),t=require("graphql"),n=require("@urql/core"),r=require("wonka"),i=require("@urql/exchange-populate"),o=function(e){return e.name.value},a=function(e){return e.typeCondition.name.value},s=function(e){return e.alias?e.alias.value:o(e)},u=function(e){return e.selectionSet?e.selectionSet.selections:[]},c=function(e){return(e=e.typeCondition)?o(e):null},l=function(e){return e.kind===t.Kind.FIELD},f=function(e){return e.kind===t.Kind.INLINE_FRAGMENT},d=function(){return Object.create(null)},p=function(e,n){var r=d(),i=0;if(e.arguments&&e.arguments.length)for(var a=0,s=e.arguments.length;a<s;a++){var u=e.arguments[a],c=t.valueFromASTUntyped(u.value,n);null!=c&&(r[o(u)]=c,i++)}return 0<i?r:null},y=function(e,n){n=n||{};var r=d();if(e.variableDefinitions)for(var i=0,a=e.variableDefinitions.length;i<a;i++){var s=e.variableDefinitions[i],u=o(s.variable),c=n[u];void 0===c&&s.defaultValue&&(c=t.valueFromASTUntyped(s.defaultValue,n)),r[u]=c}return r};function v(e,t,n){if(!e)throw(e=Error((t||"Minfied Error #"+n+"\n")+"\nhttps://bit.ly/38yWDau#"+n)).name="Graphcache Error",e}var m=function(e){return e.kind===t.Kind.FRAGMENT_DEFINITION};function h(e){return e.kind===t.Kind.OPERATION_DEFINITION}var g=function(e){return v(!!(e=e.definitions.find(h)),"",1),e};function k(e,t){return e[o(t)]=t,e}var x=function(e){return e.definitions.filter(m).reduce(k,{})},_=function(e,n){var r=e.directives;if(!r)return!0;for(var i=0,a=r.length;i<a;i++){var s=r[i];if(("include"===(e=o(s))||"skip"===e)&&s.arguments&&s.arguments[0]&&"if"===o(s.arguments[0]))return n=t.valueFromASTUntyped(s.arguments[0].value,n),"include"===e?!!n:!n}return!0},b=function(e,n,r){return!!(e=S(e,n,r))&&t.isNullableType(e.type)},O=function(e,n,r){return!!(e=S(e,n,r))&&(e=t.isNonNullType(e.type)?e.type.ofType:e.type,t.isListType(e)&&t.isNullableType(e.ofType))},q=function(e,n,r){return!(!r||!n)&&(r===n||(n=e.getType(n),r=e.getType(r),n instanceof t.GraphQLObjectType?n===r:(function(e,n){v(e instanceof t.GraphQLInterfaceType||e instanceof t.GraphQLUnionType,"",5)}(n),w(r),e.isPossibleType(n,r))))},S=function(e,t,n){return w(e=e.getType(t)),e.getFields()[n]};function w(e,n){v(e instanceof t.GraphQLObjectType,"",3)}var N=function(e,t){return t?e+"("+n.stringifyVariables(t)+")":e},E=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}},K=function(e,t){return e+"."+t},T=function(e,t){return e+"|"+t},F="undefined"!=typeof Promise?Promise.prototype.then.bind(Promise.resolve()):function(e){return setTimeout(e,0)},A=null,L=null,B=null,M=null,P=function(){return{optimistic:d(),base:new Map}},R=function(e,t,n){A=e,B=L,L=new Set,t?n||1<e.optimisticOrder.length&&-1<e.optimisticOrder.indexOf(t)?(n||e.commutativeKeys.has(t)||(re(e,t),e.commutativeKeys.add(t)),M=t,ne(e,t)):(M=null,ie(e,t)):M=null},I=function(){var e=A,t=M;if(M=null,t&&-1<e.optimisticOrder.indexOf(t))for(t=e.optimisticOrder.length;0<=--t&&e.refLock[e.optimisticOrder[t]]&&e.commutativeKeys.has(e.optimisticOrder[t]);)se(e.optimisticOrder[t]);L=A=null,!e.gcScheduled&&0<e.gcBatch.size&&(e.gcScheduled=!0,F((function(){H(e)}))),e.storage&&!e.persistenceScheduled&&(e.persistenceScheduled=!0,F((function(){e.storage.write(e.persistenceBatch),e.persistenceScheduled=!1,e.persistenceBatch=d()})))},C=function(e,t,n){R(e,t,n),I()},Q=function(){return v(null!==L,"",2),L},j=function(){return B=L,L=new Set},D=function(){L=B,B=null},G=function(e,t,n,r){var i=(e=M?e.optimistic[M]:e.base).get(t);void 0===i&&e.set(t,i=d()),void 0!==r||M?i[n]=r:delete i[n]},U=function(e,t,n){for(var r,i=0,o=A.optimisticOrder.length;i<o;i++){var a=e.optimistic[A.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},W=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))},V=function(e,t,n,r){if("string"==typeof n)W(e,t,n,r);else if(Array.isArray(n))for(var i=0,o=n.length;i<o;i++){var a=n[i];a&&W(e,t,a,r)}},z=function(e,t,n){if(void 0!==n)for(var r in n)t.has(r)||(e.push(E(r)),t.add(r))},J=function(e,t,n,r){z(e,t,r.base.get(n));for(var i=0,o=A.optimisticOrder.length;i<o;i++)z(e,t,r.optimistic[A.optimisticOrder[i]].get(n))},H=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=T("r",K(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=T("l",K(t,o)),e.persistenceBatch[n]=void 0),V(e.gcBatch,e.refCount,i[o],-1)}else e.gcBatch.delete(t)}))},X=function(e,t){"__typename"!==t&&(e!==A.queryRootKey?L.add(e):void 0!==t&&L.add(K(e,t)))},Y=function(e,t){return X(e,t),U(A.records,e,t)},Z=function(e,t){return X(e,t),U(A.links,e,t)},$=function(e,t,n){X(e,t),G(A.records,e,t,n),A.storage&&!M&&(e=T("r",K(e,t)),A.persistenceBatch[e]=n)},ee=function(e,t,n){var r=A;if(M)var i=r.refLock[M]||(r.refLock[M]=d()),o=r.links.optimistic[M];else{r.storage&&(i=T("l",K(e,t)),r.persistenceBatch[i]=n),i=r.refCount,o=r.links.base;var a=r.gcBatch}o=(o=o&&o.get(e))&&o[t],X(e,t),G(r.links,e,t,n),V(a,i,o,-1),V(a,i,n,1)},te=function(e,t){e.commutativeKeys.has(t)||(e.optimisticOrder.unshift(t),e.commutativeKeys.add(t))},ne=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)},re=function(e,t){e.refLock[t]&&(delete e.refLock[t],delete e.records.optimistic[t],delete e.links.optimistic[t])},ie=function(e,t){var n=e.optimisticOrder.indexOf(t);-1<n&&(e.optimisticOrder.splice(n,1),e.commutativeKeys.delete(t)),re(e,t)};function oe(e,t){for(var n in e)ee(t,n,e[n])}function ae(e,t){for(var n in e)$(t,n,e[n])}var se=function(e){j();var t=A.links.optimistic[e];t&&t.forEach(oe),(t=A.records.optimistic[e])&&t.forEach(ae),D(),ie(A,e)},ue=function(e,t,n,r,i,o){return{store:e,variables:t,fragments:n,parentTypeName:r,parentKey:i,parentFieldKey:"",fieldName:"",partial:!1,optimistic:!!o}},ce=function(e,t,n,r,i){e.parentTypeName=t,e.parentKey=n,e.parentFieldKey=r,e.fieldName=i},le=function(e,t,n,r){return!(!t||t!==c(e)&&u(e).some((function(e){return!!l(e)&&(e=N(o(e),p(e,r)),!function(e,t){return void 0!==Y(e,t)||void 0!==Z(e,t)}(n,e))})))},fe=function(e,t,n,r){this.typename=e,this.entityKey=t,this.context=r,this.indexStack=[0],this.selectionStack=[n]};fe.prototype.next=function(){for(;0!==this.indexStack.length;){var e=this.indexStack[this.indexStack.length-1]++,t=this.selectionStack[this.selectionStack.length-1];if(e>=t.length)this.indexStack.pop(),this.selectionStack.pop();else if(_(e=t[e],this.context.variables))if(l(e)){if("__typename"!==o(e))return e}else void 0!==(e=f(e)?e:this.context.fragments[o(e)])&&(this.context.store.schema?q(this.context.store.schema,c(e),this.typename):le(e,this.typename,this.entityKey,this.context.variables))&&(this.indexStack.push(0),this.selectionStack.push(u(e)))}};var de=function(e){return void 0===e?null:e},pe=function(e,t,n,r){return R(e.data,r||null),e=ye(e,t,n),I(),e},ye=function(e,t,n){var r=g(t.query),i={dependencies:Q()},o=e.rootFields[r.operation];return e=ue(e,y(r,t.variables),x(t.query),o,o),me(e,o,u(r),n),i},ve=function(e,t,n){R(e.data,n,!0),n=g(t.query);var r={dependencies:Q()},i=e.rootFields[n.operation];return v(i===e.rootFields.mutation,"",10),e=ue(e,y(n,t.variables),x(t.query),i,i,!0),t=d(),me(e,i,u(n),t),I(),r},me=function(e,t,n,r){var i=t===e.store.rootFields.query,a=!i&&!!e.store.rootNames[t],c=a||i?t:r.__typename;if(c){a||i||!t||$(t,"__typename",c),n=new fe(c,t||c,n,e);for(var l;l=n.next();){var f=o(l);i=p(l,e.variables);var y=N(f,i),v=r[s(l)];if(l.selectionSet){if(e.optimistic&&a){if(!(v=e.store.optimisticMutations[f]))continue;ce(e,c,c,y,f),v=de(v(i||d(),e.store,e)),r[f]=v}else v=de(v);if(t&&!a){var m=K(t,y);l=he(e,u(l),v,m),ee(t||c,y,l)}else he(e,u(l),v)}else t&&!a&&$(t||c,y,v);a&&(ce(e,c,c,K(c,y),f),(f=e.store.updates[c][f])&&f(r,i||d(),e.store,e))}}},he=function(e,t,n,r){if(Array.isArray(n)){for(var i=Array(n.length),o=0,a=n.length;o<a;o++){var s=n[o],u=r?K(r,""+o):void 0;s=he(e,t,s,u),i[o]=s}return i}return null===n?null:(i=e.store.keyOfEntity(n),o=n.__typename,!r||void 0!==e.store.keys[n.__typename]||null!==i||"string"!=typeof o||o.endsWith("Connection")||o.endsWith("Edge"),me(e,r=i||r,t,n),r||null)},ge=function(e,n,r,i,o){var a;if(this.keyOfField=N,this.resolvers=n||{},this.optimisticMutations=i||{},this.keys=o||{},this.updates={Mutation:r&&r.Mutation||{},Subscription:r&&r.Subscription||{}},n="Query",r="Mutation",i="Subscription",e){var s=this.schema=t.buildClientSchema(e);e=s.getQueryType(),o=s.getMutationType(),s=s.getSubscriptionType(),e&&(n=e.name),o&&(r=o.name),s&&(i=s.name)}this.rootFields={query:n,mutation:r,subscription:i},this.rootNames=((a={})[n]="query",a[r]="mutation",a[i]="subscription",a),this.data=function(e){return{persistenceScheduled:!1,persistenceBatch:d(),gcScheduled:!1,queryRootKey:e,gcBatch:new Set,refCount:d(),refLock:d(),links:P(),records:P(),commutativeKeys:new Set,optimisticOrder:[],storage:null}}(n)};ge.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},ge.prototype.resolveFieldByKey=function(e,t){if(null===(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e))return null;var n=Y(e,t);return void 0!==n?n:(t=Z(e,t))?t:null},ge.prototype.resolve=function(e,t,n){return this.resolveFieldByKey(e,N(t,n))},ge.prototype.invalidateQuery=function(e,t){!function(e,t){var n=j();xe(e,t),n.forEach((function(t){t.startsWith(e.data.queryRootKey+".")?(t=t.slice((e.data.queryRootKey+".").length),ee(e.data.queryRootKey,t),$(e.data.queryRootKey,t)):e.invalidate(t)})),D(),H(e.data)}(this,n.createRequest(e,t))},ge.prototype.invalidate=function(e){v(e="string"==typeof e?e:this.keyOfEntity(e),"",19);for(var t=0,n=this.inspectFields(e);t<n.length;t+=1){var r=n[t];Z(e,r.fieldKey)?ee(e,r.fieldKey,void 0):$(e,r.fieldKey,void 0)}},ge.prototype.inspectFields=function(e){return null!==(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e)?function(e){var t=A.links,n=A.records,r=[],i=new Set;return X(e),J(r,i,e,t),J(r,i,e,n),r}(e):[]},ge.prototype.updateQuery=function(e,t){e=n.createRequest(e.query,e.variables),null!==(t=t(this.readQuery(e)))&&ye(this,e,t)},ge.prototype.readQuery=function(e){return xe(this,n.createRequest(e.query,e.variables)).data},ge.prototype.readFragment=function(e,t,n){return Oe(this,e,t,n)},ge.prototype.writeFragment=function(t,n,r){!function(t,n,r,i){n=x(n);var o=Object.keys(n);if(void 0!==(o=n[o[0]])){var s=a(o);r=e._extends({},{__typename:s},r);var c=t.keyOfEntity(r);c&&(t=ue(t,i||{},n,s,c),me(t,c,u(o),r))}}(this,t,n,r)};var ke=function(e,t,n){return R(e.data,null),e=xe(e,t,n),I(),e},xe=function(e,t,n){var r=g(t.query),i=e.rootFields[r.operation],o=u(r);return e=ue(e,y(r,t.variables),x(t.query),i,i),n=n||d(),n=i!==e.store.rootFields.query?_e(e,i,o,n):qe(e,i,o,n),{dependencies:Q(),partial:void 0!==n&&e.partial,data:void 0===n?null:n}},_e=function(e,t,n,r){if("string"!=typeof r.__typename)return r;t=new fe(t,t,n,e),(n=d()).__typename=r.__typename;for(var i;void 0!==(i=t.next());){var o=s(i),a=r[o];void 0!==i.selectionSet&&null!==a?(a=de(a),n[o]=be(e,u(i),a)):n[o]=a}return n},be=function(e,t,n){if(Array.isArray(n)){for(var r=Array(n.length),i=0,o=n.length;i<o;i++)r[i]=be(e,t,n[i]);return r}return null===n?null:null!==(r=e.store.keyOfEntity(n))?void 0===(e=qe(e,r,t,d()))?null:e:_e(e,n.__typename,t,n)},Oe=function(t,n,r,i){n=x(n);var o=Object.keys(n);if(void 0===(o=n[o[0]]))return null;var s=a(o);return"string"==typeof r||r.__typename||(r.__typename=s),(r="string"!=typeof r?t.keyOfEntity(e._extends({},{__typename:s},r)):r)?(t=ue(t,i||{},n,s,r),qe(t,r,u(o),d())||null):null},qe=function(e,t,n,r,i){var a=e.store,c=t===a.rootFields.query,l=i&&a.keyOfEntity(i)||t;if(!("string"!=typeof(t=c?t:Y(l,"__typename")||i&&i.__typename)||i&&t!==i.__typename)){r.__typename=t,n=new fe(t,l,n,e);for(var f,y=!1,v=!1;void 0!==(f=n.next());){var m=o(f),h=p(f,e.variables),g=s(f),k=N(m,h),x=K(l,k),_=Y(l,k),O=i?i[m]:void 0,q=a.resolvers[t],S=void 0;if(void 0!==O&&void 0===f.selectionSet)S=O;else if(q&&"function"==typeof q[m]){if(ce(e,t,l,x,m),void 0!==_&&(r[g]=_),S=q[m](r,h||d(),a,e),void 0!==f.selectionSet&&(S=Se(e,t,m,x,u(f),r[g]||d(),S)),a.schema&&null===S&&!b(a.schema,t,m))return}else void 0===f.selectionSet?S=_:void 0!==O?S=Se(e,t,m,x,u(f),r[g],O):void 0!==(h=Z(l,k))?S=we(e,h,t,m,u(f),r[g]):"object"==typeof _&&null!==_&&(S=_);if(void 0===S&&a.schema&&b(a.schema,t,m))v=!0,r[g]=null;else{if(void 0===S)return;y=!0,r[g]=S}}return v&&(e.partial=!0),c&&v&&!y?void 0:r}},Se=function(e,t,n,r,i,o,a){if(Array.isArray(a)){var s=e.store;s=!s.schema||O(s.schema,t,n);for(var u=Array(a.length),c=0,l=a.length;c<l;c++){var f=Se(e,t,n,K(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}return null==a?a:Ne(a)?(t=void 0===o?d():o,"string"==typeof a?qe(e,a,i,t):qe(e,r,i,t,a)):void 0},we=function(e,t,n,r,i,o){if(Array.isArray(t)){var a=e.store;a=a.schema&&O(a.schema,n,r);for(var s=Array(t.length),u=0,c=t.length;u<c;u++){var l=we(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:qe(e,t,i,void 0===o?d():o)},Ne=function(e){return"string"==typeof e||"object"==typeof e&&"string"==typeof e.__typename},Ee=function(t,n){return e._extends({},t,{context:e._extends({},t.context,{meta:e._extends({},t.context.meta,{cacheOutcome:n})})})},Ke=function(t,n){return e._extends({},t,{context:e._extends({},t.context,{requestPolicy:n})})};function Te(t){return e._extends({},t,{query:n.formatDocument(t.query)})}function Fe(e){return"query"===e.operationName&&"network-only"!==e.context.requestPolicy}function Ae(e){return Ee(e.operation,"miss")}function Le(e){return"miss"===e.outcome}function Be(e){return"miss"!==e.outcome}function Me(e){return"cache-only"!==e.context.requestPolicy}function Pe(e){return!("query"===e.operationName&&"network-only"!==e.context.requestPolicy)}exports.populateExchange=i.populateExchange,exports.Store=ge,exports.cacheExchange=function(e){return function(t){function n(e){var t=e.operation,n=e.outcome;return e={operation:Ee(t,n),data:e.data,error:e.error,extensions:e.extensions},("cache-and-network"===t.context.requestPolicy||"cache-first"===t.context.requestPolicy&&"partial"===n)&&(e.stale=!0,o.reexecuteOperation(Ke(t,"network-only"))),e}var i=t.forward,o=t.client;e||(e={});var a,s=new ge(e.schema,e.resolvers,e.updates,e.optimistic,e.keys);e.storage&&(a=e.storage.read().then((function(t){!function(e,t,n){for(var r in R(e,null),n){var i=r.indexOf("."),o=r.slice(2,i);switch(i=r.slice(i+1),r.charCodeAt(0)){case 108:ee(o,i,n[r]);break;case 114:$(o,i,n[r])}}I(),e.storage=t}(s.data,e.storage,t)})));var u=new Map,c=new Map,l=d(),f=function(e,t){t&&t.forEach((function(t){var n=l[t];if(n){l[t]=[],t=0;for(var r=n.length;t<r;t++)e.add(n[t])}}))},p=function(e,t){t.forEach((function(t){if(t!==e.key){var n=c.get(t);n&&(c.delete(t),o.reexecuteOperation(Ke(n,"cache-first")))}}))},y=function(e){"query"===e.operationName?te(s.data,e.key):"teardown"===e.operationName&&C(s.data,e.key)},v=function(e){var t=e.key;if("mutation"===e.operationName&&"network-only"!==e.context.requestPolicy){var n=ve(s,e,t).dependencies;0!==n.size&&(u.set(t,n),t=new Set,f(t,n),p(e,t))}else C(s.data,t,!0)},m=function(e,t){t.forEach((function(t){(l[t]||(l[t]=[])).push(e.key),c.has(e.key)||c.set(e.key,"network-only"===e.context.requestPolicy?Ke(e,"cache-and-network"):e)}))},h=function(e){var t=ke(s,e),n=t.data?t.partial&&"cache-only"!==e.context.requestPolicy?"partial":"hit":"miss";return t.data&&m(e,t.dependencies),{outcome:n,operation:e,data:t.data}},g=function(e){var t=e.operation,n=e.error,r=e.extensions,i=t.key,o=new Set;if("mutation"===t.operationName?(f(o,u.get(i)),u.delete(i)):"subscription"===t.operationName&&te(s.data,t.key),e.data){if(i=pe(s,t,e.data,i).dependencies,f(o,i),i=ke(s,t,e.data),e.data=i.data,"query"===t.operationName){var a=i.dependencies;f(o,a)}}else C(s.data,t.key);return p(e.operation,o),a&&m(e.operation,a),{data:e.data,error:n,extensions:r,operation:t}};return function(e){e=r.share(e);var t=a?r.mergeMap(r.fromArray)(r.take(1)(r.buffer(r.fromPromise(a))(e))):r.empty;e=r.share(r.tap(v)(r.map(Te)(r.concat([t,e]))));var o=r.share(r.map(h)(r.filter(Fe)(e)));return t=r.map(Ae)(r.filter(Le)(o)),o=r.map(n)(r.filter(Be)(o)),e=r.map(g)(i(r.tap(y)(r.filter(Me)(r.merge([r.filter(Pe)(e),t]))))),r.merge([e,o])}}},exports.noopDataState=C,exports.query=ke,exports.reserveLayer=te,exports.write=pe,exports.writeOptimistic=ve; | ||
//# sourceMappingURL=urql-exchange-graphcache.cjs.min.js.map |
@@ -12,62 +12,52 @@ import { share, mergeMap, fromArray, take, buffer, fromPromise, empty, tap, map, concat, filter, merge } from "wonka"; | ||
function n(a) { | ||
return void 0 !== a.alias ? a.alias.value : a.name.value; | ||
return a.selectionSet ? a.selectionSet.selections : []; | ||
} | ||
function r(a) { | ||
return void 0 !== a.selectionSet ? a.selectionSet.selections : []; | ||
function aa(a) { | ||
return (a = a.typeCondition) ? a.name.value : null; | ||
} | ||
function ba(a) { | ||
return void 0 !== (a = a.typeCondition) ? a.name.value : null; | ||
} | ||
function t() { | ||
function q() { | ||
return Object.create(null); | ||
} | ||
function x(a, b) { | ||
if (void 0 === a.arguments || 0 === a.arguments.length) { | ||
return null; | ||
function u(a, b) { | ||
var c = q(), d = 0; | ||
if (a.arguments && a.arguments.length) { | ||
for (var e = 0, f = a.arguments.length; e < f; e++) { | ||
var g = a.arguments[e], h = valueFromASTUntyped(g.value, b); | ||
null != h && (c[g.name.value] = h, d++); | ||
} | ||
} | ||
for (var c = t(), d = 0, e = 0, f = a.arguments.length; e < f; e++) { | ||
var g = a.arguments[e], h = valueFromASTUntyped(g.value, b); | ||
null != h && (c[g.name.value] = h, d++); | ||
} | ||
return 0 < d ? c : null; | ||
} | ||
function y(a, b) { | ||
if (void 0 === a.variableDefinitions) { | ||
return {}; | ||
function v(a, b) { | ||
b = b || {}; | ||
var c = q(); | ||
if (a.variableDefinitions) { | ||
for (var d = 0, e = a.variableDefinitions.length; d < e; d++) { | ||
var f = a.variableDefinitions[d], g = f.variable.name.value, h = b[g]; | ||
void 0 === h && f.defaultValue && (h = valueFromASTUntyped(f.defaultValue, b)); | ||
c[g] = h; | ||
} | ||
} | ||
var c = b || {}; | ||
return a.variableDefinitions.reduce((function(a, b) { | ||
var d = b.variable.name.value, e = c[d]; | ||
if (void 0 === e) { | ||
if (void 0 !== b.defaultValue) { | ||
e = valueFromASTUntyped(b.defaultValue, c); | ||
} else { | ||
return a; | ||
} | ||
} | ||
a[d] = e; | ||
return a; | ||
}), t()); | ||
return c; | ||
} | ||
var ca = new Set, z = []; | ||
var ba = new Set, w = []; | ||
function B(a, b) { | ||
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 && z.push(c); | ||
c && w.push(c); | ||
} | ||
function da() { | ||
return z.length ? "\n(Caused At: " + z.join(", ") + ")" : ""; | ||
function ca() { | ||
return w.length ? "\n(Caused At: " + w.join(", ") + ")" : ""; | ||
} | ||
function C(a, b, c) { | ||
function B(a, b, c) { | ||
if (!a) { | ||
throw a = b || "Minfied Error #" + c + "\n", "production" !== process.env.NODE_ENV && (a += da()), | ||
throw a = b || "Minfied Error #" + c + "\n", "production" !== process.env.NODE_ENV && (a += ca()), | ||
(c = Error(a + "\nhttps://bit.ly/38yWDau#" + c)).name = "Graphcache Error", c; | ||
@@ -77,16 +67,16 @@ } | ||
function D(a, b) { | ||
ca.has(a) || (console.warn(a + da() + "\nhttps://bit.ly/38yWDau#" + b), ca.add(a)); | ||
function F(a, b) { | ||
ba.has(a) || (console.warn(a + ca() + "\nhttps://bit.ly/38yWDau#" + b), ba.add(a)); | ||
} | ||
function ea(a) { | ||
function da(a) { | ||
return a.kind === Kind.FRAGMENT_DEFINITION; | ||
} | ||
function fa(a) { | ||
function ea(a) { | ||
return a.kind === Kind.OPERATION_DEFINITION; | ||
} | ||
function E(a) { | ||
C(!!(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 fa(a) { | ||
B(!!(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; | ||
@@ -100,12 +90,12 @@ } | ||
function F(a) { | ||
return a.definitions.filter(ea).reduce(ha, {}); | ||
function G(a) { | ||
return a.definitions.filter(da).reduce(ha, {}); | ||
} | ||
function ia(a, b, c) { | ||
return void 0 === (a = G(a, b, c)) ? !1 : isNullableType(a.type); | ||
return !!(a = H(a, b, c)) && isNullableType(a.type); | ||
} | ||
function ja(a, b, c) { | ||
if (void 0 === (a = G(a, b, c))) { | ||
if (!(a = H(a, b, c))) { | ||
return !1; | ||
@@ -117,13 +107,10 @@ } | ||
function G(a, b, c) { | ||
function H(a, b, c) { | ||
ka(a = a.getType(b), b); | ||
if (void 0 === (a = a.getFields()[c])) { | ||
"production" !== process.env.NODE_ENV && D("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 { | ||
return a; | ||
} | ||
(a = a.getFields()[c]) || "production" !== process.env.NODE_ENV && F("Invalid field: The field `" + c + "` does not exist on `" + b + "`, but the GraphQL document expects it to exist.\nTraversal will continue, however this may lead to undefined behavior!", 4); | ||
return a; | ||
} | ||
function ka(a, b) { | ||
C(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); | ||
B(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); | ||
} | ||
@@ -150,25 +137,25 @@ | ||
return setTimeout(a, 0); | ||
}, J = null, K = null, L = null; | ||
}, J = null, K = null, L = null, M = null; | ||
function M(a, b, c) { | ||
function N(a, b, c) { | ||
J = a; | ||
L = K; | ||
K = new Set; | ||
"production" !== process.env.NODE_ENV && (z.length = 0); | ||
"production" !== process.env.NODE_ENV && (w.length = 0); | ||
b ? c || 1 < a.optimisticOrder.length && -1 < a.optimisticOrder.indexOf(b) ? (c || a.commutativeKeys.has(b) || (na(a, b), | ||
a.commutativeKeys.add(b)), L = b, -1 === a.optimisticOrder.indexOf(b) && a.optimisticOrder.unshift(b), | ||
a.refLock[b] || (a.refLock[b] = t(), a.links.optimistic[b] = new Map, a.records.optimistic[b] = new Map)) : (L = null, | ||
oa(a, b)) : L = null; | ||
a.commutativeKeys.add(b)), M = b, -1 === a.optimisticOrder.indexOf(b) && a.optimisticOrder.unshift(b), | ||
a.refLock[b] || (a.refLock[b] = q(), a.links.optimistic[b] = new Map, a.records.optimistic[b] = new Map)) : (M = null, | ||
oa(a, b)) : M = null; | ||
} | ||
function N() { | ||
var c = J, d = L; | ||
L = null; | ||
function O() { | ||
var c = J, d = M; | ||
M = null; | ||
if (d && -1 < c.optimisticOrder.indexOf(d)) { | ||
d = c.optimisticOrder.length - c.commutativeKeys.size; | ||
for (var e = c.optimisticOrder.length; --e >= d && c.refLock[c.optimisticOrder[e]] && c.commutativeKeys.has(c.optimisticOrder[e]); ) { | ||
qa(c.optimisticOrder[e]); | ||
for (d = c.optimisticOrder.length; 0 <= --d && c.refLock[c.optimisticOrder[d]] && c.commutativeKeys.has(c.optimisticOrder[d]); ) { | ||
qa(c.optimisticOrder[d]); | ||
} | ||
} | ||
K = J = null; | ||
"production" !== process.env.NODE_ENV && (z.length = 0); | ||
"production" !== process.env.NODE_ENV && (w.length = 0); | ||
!c.gcScheduled && 0 < c.gcBatch.size && (c.gcScheduled = !0, ma((function a() { | ||
@@ -180,15 +167,25 @@ pa(c); | ||
c.persistenceScheduled = !1; | ||
c.persistenceBatch = t(); | ||
c.persistenceBatch = q(); | ||
}))); | ||
} | ||
function P(a, b, c) { | ||
N(a, b, c); | ||
O(); | ||
} | ||
function ra() { | ||
C(null !== K, "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); | ||
B(null !== K, "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 K; | ||
} | ||
function sa() { | ||
L = K; | ||
return K = new Set; | ||
} | ||
function ta(a, b, c, d) { | ||
var e = (a = L ? a.optimistic[L] : a.base).get(b); | ||
void 0 === e && a.set(b, e = t()); | ||
void 0 !== d || L ? e[c] = d : delete e[c]; | ||
var e = (a = M ? a.optimistic[M] : a.base).get(b); | ||
void 0 === e && a.set(b, e = q()); | ||
void 0 !== d || M ? e[c] = d : delete e[c]; | ||
} | ||
@@ -268,27 +265,27 @@ | ||
function O(a, b) { | ||
function Q(a, b) { | ||
"__typename" !== b && (a !== J.queryRootKey ? K.add(a) : void 0 !== b && K.add(a + "." + b)); | ||
} | ||
function Q(a, b) { | ||
O(a, b); | ||
function R(a, b) { | ||
Q(a, b); | ||
return ua(J.records, a, b); | ||
} | ||
function R(a, b) { | ||
O(a, b); | ||
function S(a, b) { | ||
Q(a, b); | ||
return ua(J.links, a, b); | ||
} | ||
function S(a, b, c) { | ||
O(a, b); | ||
function T(a, b, c) { | ||
Q(a, b); | ||
ta(J.records, a, b, c); | ||
J.storage && !L && (J.persistenceBatch["r|" + a + "." + b] = c); | ||
J.storage && !M && (J.persistenceBatch["r|" + a + "." + b] = c); | ||
} | ||
function T(a, b, c) { | ||
function U(a, b, c) { | ||
var d = J; | ||
if (L) { | ||
var e = d.refLock[L] || (d.refLock[L] = t()); | ||
var f = d.links.optimistic[L]; | ||
if (M) { | ||
var e = d.refLock[M] || (d.refLock[M] = q()); | ||
var f = d.links.optimistic[M]; | ||
} else { | ||
@@ -300,4 +297,4 @@ d.storage && (d.persistenceBatch["l|" + a + "." + b] = c); | ||
} | ||
f = void 0 !== (f = void 0 !== f ? f.get(a) : void 0) ? f[b] : null; | ||
O(a, b); | ||
f = (f = f && f.get(a)) && f[b]; | ||
Q(a, b); | ||
ta(d.links, a, b, c); | ||
@@ -324,3 +321,3 @@ wa(g, e, f, -1); | ||
for (var c in a) { | ||
T(b, c, a[c]); | ||
U(b, c, a[c]); | ||
} | ||
@@ -331,3 +328,3 @@ } | ||
for (var c in a) { | ||
S(b, c, a[c]); | ||
T(b, c, a[c]); | ||
} | ||
@@ -337,11 +334,25 @@ } | ||
function qa(a) { | ||
var b = K; | ||
K = new Set; | ||
var c = J.links.optimistic[a]; | ||
c && c.forEach(Aa); | ||
(c = J.records.optimistic[a]) && c.forEach(Ba); | ||
K = b; | ||
sa(); | ||
var b = J.links.optimistic[a]; | ||
b && b.forEach(Aa); | ||
(b = J.records.optimistic[a]) && b.forEach(Ba); | ||
K = L; | ||
L = null; | ||
oa(J, a); | ||
} | ||
function V(a, b, c, d, e, f) { | ||
return { | ||
store: a, | ||
variables: b, | ||
fragments: c, | ||
parentTypeName: d, | ||
parentKey: e, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
partial: !1, | ||
optimistic: !!f | ||
}; | ||
} | ||
function Ca(a, b, c, d) { | ||
@@ -351,17 +362,17 @@ if (!b) { | ||
} | ||
var e = ba(a); | ||
var e = aa(a); | ||
if (b === e) { | ||
return !0; | ||
} | ||
"production" !== process.env.NODE_ENV && D("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) { | ||
"production" !== process.env.NODE_ENV && F("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 !n(a).some((function(a) { | ||
if (a.kind !== Kind.FIELD) { | ||
return !1; | ||
} | ||
a = I(a.name.value, x(a, d)); | ||
return !(void 0 !== Q(c, a) || void 0 !== R(c, a)); | ||
a = I(a.name.value, u(a, d)); | ||
return !(void 0 !== R(c, a) || void 0 !== S(c, a)); | ||
})); | ||
} | ||
function U(a, b, c, d) { | ||
function W(a, b, c, d) { | ||
this.typename = a; | ||
@@ -374,3 +385,3 @@ this.entityKey = b; | ||
U.prototype.next = function() { | ||
W.prototype.next = function() { | ||
for (;0 !== this.indexStack.length; ) { | ||
@@ -381,11 +392,10 @@ var a = this.indexStack[this.indexStack.length - 1]++, b = this.selectionStack[this.selectionStack.length - 1]; | ||
} else { | ||
a = b[a]; | ||
a: { | ||
b = this.context.variables; | ||
var c = a.directives; | ||
if (void 0 !== c) { | ||
for (var d = 0, e = c.length; d < e; d++) { | ||
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; | ||
var c = this.context.variables, d = (a = b[a]).directives; | ||
if (d) { | ||
for (var e = 0, f = d.length; e < f; e++) { | ||
var g = d[e]; | ||
if (("include" === (b = g.name.value) || "skip" === b) && g.arguments && g.arguments[0] && "if" === g.arguments[0].name.value) { | ||
c = valueFromASTUntyped(g.arguments[0].value, c); | ||
b = "include" === b ? !!c : !c; | ||
break a; | ||
@@ -399,7 +409,7 @@ } | ||
if (a.kind !== Kind.FIELD) { | ||
void 0 !== (a = a.kind !== Kind.INLINE_FRAGMENT ? this.context.fragments[a.name.value] : a) && ("production" !== process.env.NODE_ENV && B(this.typename, a), | ||
this.context.store.schema ? (b = this.context.store.schema, c = ba(a), (d = this.typename) && c ? d === c ? b = !0 : (e = b.getType(c), | ||
h = b.getType(d), e instanceof GraphQLObjectType ? b = e === h : (C(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 = Ca(a, this.typename, this.entityKey, this.context.variables), | ||
b && (this.indexStack.push(0), this.selectionStack.push(r(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), | ||
f = b.getType(d), e instanceof GraphQLObjectType ? b = e === f : (B(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(f, d), b = b.isPossibleType(e, f))) : b = !1) : b = Ca(a, this.typename, this.entityKey, this.context.variables), | ||
b && (this.indexStack.push(0), this.selectionStack.push(n(a)))); | ||
} else if ("__typename" !== a.name.value) { | ||
@@ -413,10 +423,6 @@ return a; | ||
function V(a) { | ||
return void 0 === a ? null : a; | ||
} | ||
function Da(a, b, c, d) { | ||
M(a.data, d || null); | ||
N(a.data, d || null); | ||
a = Ea(a, b, c); | ||
N(); | ||
O(); | ||
return a; | ||
@@ -426,101 +432,65 @@ } | ||
function Ea(a, b, c) { | ||
var d = E(b.query), e = { | ||
var d = fa(b.query), e = { | ||
dependencies: ra() | ||
}, f = r(d), g = a.getRootKey(d.operation); | ||
a = { | ||
parentTypeName: g, | ||
parentKey: g, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
store: a, | ||
variables: y(d, b.variables), | ||
fragments: F(b.query) | ||
}; | ||
"production" !== process.env.NODE_ENV && B(g, d); | ||
g === a.store.getRootKey("query") ? W(a, g, f, c) : Fa(a, g, f, c); | ||
}, f = a.rootFields[d.operation]; | ||
a = V(a, v(d, b.variables), G(b.query), f, f); | ||
"production" !== process.env.NODE_ENV && x(f, d); | ||
X(a, f, n(d), c); | ||
return e; | ||
} | ||
function Ga(a, b, c) { | ||
M(a.data, c, !0); | ||
var d = E(b.query); | ||
c = { | ||
function Fa(a, b, c) { | ||
N(a.data, c, !0); | ||
c = fa(b.query); | ||
var d = { | ||
dependencies: ra() | ||
}; | ||
var e = a.getRootKey("mutation"), f = a.getRootKey(d.operation); | ||
C(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 && B(f, d); | ||
a = { | ||
parentTypeName: e, | ||
parentKey: e, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
variables: y(d, b.variables), | ||
fragments: F(b.query), | ||
store: a, | ||
optimistic: !0 | ||
}; | ||
b = t(); | ||
d = new U(f, f, r(d), a); | ||
for (var g; void 0 !== (g = d.next()); ) { | ||
if (void 0 !== g.selectionSet) { | ||
var h = g.name.value, k = a.store.optimisticMutations[h]; | ||
if (void 0 !== k) { | ||
a.fieldName = h; | ||
Ha(a, V(k = k((f = x(g, a.variables)) || t(), a.store, a)), r(g)); | ||
b[h] = k; | ||
void 0 !== (g = a.store.updates[e][h]) && g(b, f || t(), a.store, a); | ||
} | ||
} | ||
} | ||
N(); | ||
return c; | ||
}, e = a.rootFields[c.operation]; | ||
B(e === a.rootFields.mutation, "production" !== process.env.NODE_ENV ? "writeOptimistic(...) was called with an operation that is not a mutation.\nThis case is unsupported and should never occur." : "", 10); | ||
"production" !== process.env.NODE_ENV && x(e, c); | ||
a = V(a, v(c, b.variables), G(b.query), e, e, !0); | ||
b = q(); | ||
X(a, e, n(c), b); | ||
O(); | ||
return d; | ||
} | ||
function Ia(a, b, c, d) { | ||
b = F(b); | ||
var e = Object.keys(b); | ||
if (void 0 === (e = b[e[0]])) { | ||
return "production" !== process.env.NODE_ENV ? D("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({}, { | ||
__typename: f | ||
}, c); | ||
var g = a.keyOfEntity(c); | ||
if (!g) { | ||
return "production" !== process.env.NODE_ENV ? D("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 && B(f, e); | ||
W({ | ||
parentTypeName: f, | ||
parentKey: g, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
variables: d || {}, | ||
fragments: b, | ||
store: a | ||
}, g, r(e), c); | ||
} | ||
function W(a, b, c, d) { | ||
var e = b === a.store.getRootKey("query") ? b : d.__typename; | ||
if ("string" == typeof e) { | ||
S(b, "__typename", e); | ||
c = new U(e, b, c, a); | ||
for (var f; void 0 !== (f = c.next()); ) { | ||
var g = f.name.value, h = x(f, a.variables); | ||
h = I(g, h); | ||
var k = d[n(f)], m = b + "." + h; | ||
function X(a, b, c, d) { | ||
var e = b === a.store.rootFields.query, f = !e && !!a.store.rootNames[b], g = f || e ? b : d.__typename; | ||
if (g) { | ||
f || e || !b || T(b, "__typename", g); | ||
c = new W(g, b || g, c, a); | ||
for (var h; h = c.next(); ) { | ||
var k = h.name.value; | ||
var p = I(k, e = u(h, a.variables)), l = d[h.alias ? h.alias.value : h.name.value]; | ||
if ("production" !== process.env.NODE_ENV) { | ||
if (void 0 === k) { | ||
g = a.optimistic ? "\nYour optimistic result may be missing a field!" : ""; | ||
f = void 0 === f.selectionSet ? "scalar (number, boolean, etc)" : "selection set"; | ||
"production" !== process.env.NODE_ENV && D("Invalid undefined: The field at `" + h + "` is `undefined`, but the GraphQL query expects a " + f + " for this field." + g, 13); | ||
if (f || void 0 !== l) { | ||
a.store.schema && g && H(a.store.schema, g, k); | ||
} else { | ||
e = a.optimistic ? "\nYour optimistic result may be missing a field!" : ""; | ||
k = void 0 === h.selectionSet ? "scalar (number, boolean, etc)" : "selection set"; | ||
"production" !== process.env.NODE_ENV && F("Invalid undefined: The field at `" + p + "` is `undefined`, but the GraphQL query expects a " + k + " for this field." + e, 13); | ||
continue; | ||
} | ||
} | ||
if (h.selectionSet) { | ||
if (a.optimistic && f) { | ||
if (!(l = a.store.optimisticMutations[k])) { | ||
continue; | ||
} | ||
var m = a, C = g, r = p, y = k; | ||
m.parentTypeName = g; | ||
m.parentKey = C; | ||
m.parentFieldKey = r; | ||
m.fieldName = y; | ||
l = l(e || q(), a.store, a); | ||
d[k] = l = void 0 === l ? null : l; | ||
} else { | ||
a.store.schema && e && G(a.store.schema, e, g); | ||
l = void 0 === l ? null : l; | ||
} | ||
b && !f ? (m = b + "." + p, U(b || g, p, h = Ga(a, n(h), l, m))) : Ga(a, n(h), l); | ||
} else { | ||
b && !f && T(b || g, p, l); | ||
} | ||
void 0 === f.selectionSet ? S(b, h, k) : (g = V(k), T(b, h, f = Ja(a, m, r(f), g))); | ||
f && (l = g, p = g + "." + p, m = k, (h = a).parentTypeName = g, h.parentKey = l, | ||
h.parentFieldKey = p, h.fieldName = m, (k = a.store.updates[g][k]) && k(d, e || q(), a.store, a)); | ||
} | ||
@@ -530,6 +500,6 @@ } | ||
function Ja(a, b, c, d) { | ||
if (Array.isArray(d)) { | ||
for (var e = Array(d.length), f = 0, g = d.length; f < g; f++) { | ||
var h = Ja(a, b + "." + f, c, d[f]); | ||
function Ga(a, b, c, d) { | ||
if (Array.isArray(c)) { | ||
for (var e = Array(c.length), f = 0, g = c.length; f < g; f++) { | ||
var h = Ga(a, b, c[f], d ? d + "." + f : void 0); | ||
e[f] = h; | ||
@@ -539,44 +509,14 @@ } | ||
} | ||
if (null === d) { | ||
if (null === c) { | ||
return null; | ||
} | ||
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 && D("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); | ||
return f; | ||
e = a.store.keyOfEntity(c); | ||
f = c.__typename; | ||
!d || void 0 !== a.store.keys[c.__typename] || null !== e || "string" != typeof f || f.endsWith("Connection") || f.endsWith("Edge") || "PageInfo" === f || "production" !== process.env.NODE_ENV && F("Invalid key: The GraphQL query at the field at `" + d + "` has a selection set, but no key could be generated for the data at this field.\nYou have to request `id` or `_id` fields for all selection sets or create a custom `keys` config for `" + f + "`.\nEntities without keys will be embedded directly on the parent entity. If this is intentional, create a `keys` config for `" + f + "` that always returns null.", 15); | ||
X(a, d = e || d, b, c); | ||
return d || null; | ||
} | ||
function Fa(a, b, c, d) { | ||
var e = b === a.store.getRootKey("mutation") || b === a.store.getRootKey("subscription"); | ||
c = new U(b, b, c, a); | ||
for (var f; void 0 !== (f = c.next()); ) { | ||
var g = f.name.value, h = x(f, a.variables); | ||
var k = I(g, h); | ||
k = b + "." + k; | ||
if (void 0 !== f.selectionSet) { | ||
Ha(a, V(d[n(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 || t(), a.store, a)); | ||
} | ||
} | ||
function Ha(a, b, c) { | ||
if (Array.isArray(b)) { | ||
for (var d = Array(b.length), e = 0, f = b.length; e < f; e++) { | ||
d[e] = Ha(a, b[e], c); | ||
} | ||
return d; | ||
} | ||
null !== b && (null !== (d = a.store.keyOfEntity(b)) ? W(a, d, c, b) : Fa(a, b.__typename, c, b)); | ||
} | ||
function X(a, b, c, d, e) { | ||
var g, f = this; | ||
this.gcScheduled = !1; | ||
this.gc = function() { | ||
pa(f.data); | ||
f.gcScheduled = !1; | ||
}; | ||
function Y(a, b, c, d, e) { | ||
var f; | ||
this.keyOfField = I; | ||
@@ -590,46 +530,45 @@ this.resolvers = b || {}; | ||
}; | ||
a ? (c = (b = this.schema = buildClientSchema(a)).getQueryType(), a = b.getMutationType(), | ||
b = b.getSubscriptionType(), this.rootFields = { | ||
query: c = c ? c.name : "Query", | ||
mutation: a = a ? a.name : "Mutation", | ||
subscription: b = b ? b.name : "Subscription" | ||
}, this.rootNames = ((g = {})[c] = "query", g[a] = "mutation", g[b] = "subscription", | ||
g)) : (this.rootFields = { | ||
query: "Query", | ||
mutation: "Mutation", | ||
subscription: "Subscription" | ||
}, this.rootNames = { | ||
Query: "query", | ||
Mutation: "mutation", | ||
Subscription: "subscription" | ||
}); | ||
this.data = function sa(a) { | ||
return { | ||
persistenceScheduled: !1, | ||
persistenceBatch: t(), | ||
gcScheduled: !1, | ||
queryRootKey: a, | ||
gcBatch: new Set, | ||
refCount: t(), | ||
refLock: t(), | ||
links: { | ||
optimistic: t(), | ||
base: new Map | ||
}, | ||
records: { | ||
optimistic: t(), | ||
base: new Map | ||
}, | ||
commutativeKeys: new Set, | ||
optimisticOrder: [], | ||
storage: null | ||
}; | ||
}(this.getRootKey("query")); | ||
b = "Query"; | ||
c = "Mutation"; | ||
d = "Subscription"; | ||
if (a) { | ||
var g = this.schema = buildClientSchema(a); | ||
a = g.getQueryType(); | ||
e = g.getMutationType(); | ||
g = g.getSubscriptionType(); | ||
a && (b = a.name); | ||
e && (c = e.name); | ||
g && (d = g.name); | ||
} | ||
this.rootFields = { | ||
query: b, | ||
mutation: c, | ||
subscription: d | ||
}; | ||
this.rootNames = ((f = {})[b] = "query", f[c] = "mutation", f[d] = "subscription", | ||
f); | ||
f = b; | ||
this.data = { | ||
persistenceScheduled: !1, | ||
persistenceBatch: q(), | ||
gcScheduled: !1, | ||
queryRootKey: f, | ||
gcBatch: new Set, | ||
refCount: q(), | ||
refLock: q(), | ||
links: { | ||
optimistic: q(), | ||
base: new Map | ||
}, | ||
records: { | ||
optimistic: q(), | ||
base: new Map | ||
}, | ||
commutativeKeys: new Set, | ||
optimisticOrder: [], | ||
storage: null | ||
}; | ||
} | ||
X.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; | ||
@@ -647,62 +586,42 @@ 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 = Q(a, b); | ||
return void 0 !== c ? c : (b = R(a, b)) ? b : null; | ||
var c = R(a, b); | ||
return void 0 !== c ? c : (b = S(a, b)) ? b : null; | ||
}; | ||
X.prototype.resolve = function(a, b, c) { | ||
Y.prototype.resolve = function(a, b, c) { | ||
return this.resolveFieldByKey(a, I(b, c)); | ||
}; | ||
X.prototype.invalidateQuery = function(a, b) { | ||
!function Ka(a, b, c) { | ||
if ("Query" !== b) { | ||
var d = Q(b, "__typename"); | ||
if ("string" != typeof d) { | ||
return; | ||
} | ||
S(b, "__typename", void 0); | ||
} else { | ||
d = b; | ||
} | ||
c = new U(d, b, c, a); | ||
for (var e; void 0 !== (e = c.next()); ) { | ||
var f = e.name.value, g = I(f, x(e, a.variables)); | ||
"production" !== process.env.NODE_ENV && a.store.schema && d && G(a.store.schema, d, f); | ||
if (void 0 === e.selectionSet) { | ||
S(b, g, void 0); | ||
} else if (e = r(e), f = R(b, g), T(b, g, void 0), S(b, g, void 0), Array.isArray(f)) { | ||
g = 0; | ||
for (var h = f.length; g < h; g++) { | ||
var k = f[g]; | ||
null !== k && Ka(a, k, e); | ||
} | ||
} else { | ||
f && Ka(a, f, e); | ||
} | ||
} | ||
}(b = { | ||
variables: y(a = E((b = createRequest(a, b)).query), b.variables), | ||
fragments: F(b.query), | ||
store: this | ||
}, b.store.getRootKey("query"), r(a)); | ||
Y.prototype.invalidateQuery = function(a, b) { | ||
!function Ha(a, b) { | ||
var c = sa(); | ||
Ia(a, b); | ||
c.forEach((function(b) { | ||
b.startsWith(a.data.queryRootKey + ".") ? (b = b.slice((a.data.queryRootKey + ".").length), | ||
U(a.data.queryRootKey, b), T(a.data.queryRootKey, b)) : a.invalidate(b); | ||
})); | ||
K = L; | ||
L = null; | ||
pa(a.data); | ||
}(this, createRequest(a, b)); | ||
}; | ||
X.prototype.invalidate = function(a) { | ||
Y.prototype.invalidate = function(a) { | ||
var b = "string" == typeof a ? a : this.keyOfEntity(a); | ||
C(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); | ||
B(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]; | ||
R(b, d.fieldKey) ? T(b, d.fieldKey, void 0) : S(b, d.fieldKey, void 0); | ||
S(b, d.fieldKey) ? U(b, d.fieldKey, void 0) : T(b, d.fieldKey, void 0); | ||
} | ||
}; | ||
X.prototype.inspectFields = function(a) { | ||
Y.prototype.inspectFields = function(a) { | ||
if (null !== (a = null !== a && "string" != typeof a ? this.keyOfEntity(a) : a)) { | ||
var b = J.links, c = J.records, d = [], e = new Set; | ||
O(a); | ||
Q(a); | ||
ya(d, e, a, b); | ||
@@ -717,3 +636,3 @@ ya(d, e, a, c); | ||
X.prototype.updateQuery = function(a, b) { | ||
Y.prototype.updateQuery = function(a, b) { | ||
a = createRequest(a.query, a.variables); | ||
@@ -723,11 +642,11 @@ null !== (b = b(this.readQuery(a))) && Ea(this, a, b); | ||
X.prototype.readQuery = function(a) { | ||
return La(this, createRequest(a.query, a.variables)).data; | ||
Y.prototype.readQuery = function(a) { | ||
return Ia(this, createRequest(a.query, a.variables)).data; | ||
}; | ||
X.prototype.readFragment = function(a, b, c) { | ||
a = F(a); | ||
Y.prototype.readFragment = function(a, b, c) { | ||
a = G(a); | ||
var d = Object.keys(a); | ||
if (void 0 === (d = a[d[0]])) { | ||
"production" !== process.env.NODE_ENV && D("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 && F("readFragment(...) was called with an empty fragment.\nYou have to call it with at least one fragment in your GraphQL document.", 6), | ||
c = null; | ||
@@ -739,12 +658,3 @@ } else { | ||
__typename: e | ||
}, b)) : b) ? ("production" !== process.env.NODE_ENV && B(e, d), c = Y({ | ||
parentTypeName: e, | ||
parentKey: b, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
variables: c || {}, | ||
fragments: a, | ||
partial: !1, | ||
store: this | ||
}, b, r(d), t()) || null) : ("production" !== process.env.NODE_ENV && D("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)) : b) ? ("production" !== process.env.NODE_ENV && x(e, d), c = Z(c = V(this, c || {}, a, e, b), b, n(d), q()) || null) : ("production" !== process.env.NODE_ENV && F("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); | ||
@@ -755,28 +665,30 @@ } | ||
X.prototype.writeFragment = function(a, b, c) { | ||
Ia(this, a, b, c); | ||
Y.prototype.writeFragment = function(a, b, c) { | ||
a = G(a); | ||
var d = Object.keys(a); | ||
if (void 0 === (d = a[d[0]])) { | ||
"production" !== process.env.NODE_ENV && F("writeFragment(...) was called with an empty fragment.\nYou have to call it with at least one fragment in your GraphQL document.", 11); | ||
} else { | ||
var e = d.typeCondition.name.value; | ||
b = _extends({}, { | ||
__typename: e | ||
}, b); | ||
var f = this.keyOfEntity(b); | ||
f ? ("production" !== process.env.NODE_ENV && x(e, d), X(c = V(this, c || {}, a, e, f), f, n(d), b)) : "production" !== process.env.NODE_ENV && F("Can't generate a key for writeFragment(...) data.\nYou have to pass an `id` or `_id` field or create a custom `keys` config for `" + e + "`.", 12); | ||
} | ||
}; | ||
function Z(a, b, c) { | ||
M(a.data, null); | ||
a = La(a, b, c); | ||
N(); | ||
function Ja(a, b, c) { | ||
N(a.data, null); | ||
a = Ia(a, b, c); | ||
O(); | ||
return a; | ||
} | ||
function La(a, b, c) { | ||
var d = E(b.query), e = a.getRootKey(d.operation), f = r(d); | ||
a = { | ||
parentTypeName: e, | ||
parentKey: e, | ||
parentFieldKey: "", | ||
fieldName: "", | ||
store: a, | ||
variables: y(d, b.variables), | ||
fragments: F(b.query), | ||
partial: !1 | ||
}; | ||
"production" !== process.env.NODE_ENV && B(e, d); | ||
c = c || t(); | ||
c = e !== a.store.getRootKey("query") ? Ma(a, e, f, c) : Y(a, e, f, c); | ||
function Ia(a, b, c) { | ||
var d = fa(b.query), e = a.rootFields[d.operation], f = n(d); | ||
a = V(a, v(d, b.variables), G(b.query), e, e); | ||
"production" !== process.env.NODE_ENV && x(e, d); | ||
c = c || q(); | ||
c = e !== a.store.rootFields.query ? Ka(a, e, f, c) : Z(a, e, f, c); | ||
return { | ||
@@ -789,11 +701,11 @@ dependencies: ra(), | ||
function Ma(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 = t()).__typename = d.__typename; | ||
b = new W(b, b, c, a); | ||
(c = q()).__typename = d.__typename; | ||
for (var e; void 0 !== (e = b.next()); ) { | ||
var f = n(e), g = d[f]; | ||
void 0 !== e.selectionSet && null !== g ? (g = V(g), c[f] = Na(a, r(e), g)) : c[f] = g; | ||
var f = e.alias ? e.alias.value : e.name.value, g = d[f]; | ||
void 0 !== e.selectionSet && null !== g ? (g = void 0 === g ? null : g, c[f] = La(a, n(e), g)) : c[f] = g; | ||
} | ||
@@ -803,6 +715,6 @@ return c; | ||
function Na(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] = Na(a, b, c[e]); | ||
d[e] = La(a, b, c[e]); | ||
} | ||
@@ -814,46 +726,58 @@ return d; | ||
} | ||
return null !== (d = a.store.keyOfEntity(c)) ? void 0 === (a = Y(a, d, b, t())) ? null : a : Ma(a, c.__typename, b, c); | ||
return null !== (d = a.store.keyOfEntity(c)) ? void 0 === (a = Z(a, d, b, q())) ? 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 : Q(b, "__typename"); | ||
if ("string" == typeof g) { | ||
d.__typename = g; | ||
c = new U(g, b, c, a); | ||
for (var h, k = !1, m = !1; void 0 !== (h = c.next()); ) { | ||
var l = h.name.value, q = x(h, a.variables), v = n(h), u = I(l, q), w = Q(b, u), A = b + "." + u; | ||
"production" !== process.env.NODE_ENV && e.schema && g && G(e.schema, g, l); | ||
var p = void 0, H = e.resolvers[g]; | ||
if (void 0 !== H && "function" == typeof H[l]) { | ||
if (a.parentTypeName = g, a.parentKey = b, a.parentFieldKey = A, a.fieldName = l, | ||
void 0 !== w && (d[v] = w), p = H[l](d, q || t(), e, a), void 0 !== h.selectionSet && (p = Oa(a, g, l, A, r(h), d[v] || t(), p)), | ||
e.schema && null === p && !ia(e.schema, g, l)) { | ||
function Z(a, b, c, d, e) { | ||
var f = a.store, g = b === f.rootFields.query, h = e && f.keyOfEntity(e) || b; | ||
if ("string" != typeof (b = g ? b : R(h, "__typename") || e && e.__typename) || e && b !== e.__typename) { | ||
"production" !== process.env.NODE_ENV && F("Invalid resolver data: The resolver at `" + h + "` returned an invalid typename that could not be reconciled with the cache.", 8); | ||
} else { | ||
d.__typename = b; | ||
c = new W(b, h, c, a); | ||
for (var k, p = !1, l = !1; void 0 !== (k = c.next()); ) { | ||
var m = k.name.value, C = u(k, a.variables), r = k.alias ? k.alias.value : k.name.value, y = I(m, C), D = h + "." + y, z = R(h, y), A = e ? e[m] : void 0, E = f.resolvers[b]; | ||
"production" !== process.env.NODE_ENV && f.schema && b && H(f.schema, b, m); | ||
var t = void 0; | ||
if (void 0 !== A && void 0 === k.selectionSet) { | ||
t = A; | ||
} else if (E && "function" == typeof E[m]) { | ||
y = h; | ||
A = D; | ||
var Qa = m; | ||
(t = a).parentTypeName = b; | ||
t.parentKey = y; | ||
t.parentFieldKey = A; | ||
t.fieldName = Qa; | ||
void 0 !== z && (d[r] = z); | ||
t = E[m](d, C || q(), f, a); | ||
void 0 !== k.selectionSet && (t = Ma(a, b, m, D, n(k), d[r] || q(), t)); | ||
if (f.schema && null === t && !ia(f.schema, b, m)) { | ||
return; | ||
} | ||
} else { | ||
void 0 === h.selectionSet ? p = w : void 0 !== (q = R(b, u)) ? p = Pa(a, q, g, l, r(h), d[v]) : "object" == typeof w && null !== w && (p = w); | ||
void 0 === k.selectionSet ? t = z : void 0 !== A ? t = Ma(a, b, m, D, n(k), d[r], A) : void 0 !== (C = S(h, y)) ? t = Na(a, C, b, m, n(k), d[r]) : "object" == typeof z && null !== z && (t = z); | ||
} | ||
if (void 0 === p && e.schema && ia(e.schema, g, l)) { | ||
m = !0, d[v] = null; | ||
if (void 0 === t && f.schema && ia(f.schema, b, m)) { | ||
l = !0, d[r] = null; | ||
} else { | ||
if (void 0 === p) { | ||
if (void 0 === t) { | ||
return; | ||
} | ||
k = !0; | ||
d[v] = p; | ||
p = !0; | ||
d[r] = t; | ||
} | ||
} | ||
m && (a.partial = !0); | ||
return f && m && !k ? void 0 : d; | ||
l && (a.partial = !0); | ||
return g && l && !p ? void 0 : d; | ||
} | ||
} | ||
function Oa(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), m = 0, l = g.length; m < l; m++) { | ||
var q = Oa(a, b, c, d + "." + m, e, void 0 !== f ? f[m] : void 0, g[m]); | ||
if (void 0 !== q || h) { | ||
k[m] = void 0 !== q ? q : null; | ||
for (var k = Array(g.length), p = 0, l = g.length; p < l; p++) { | ||
var m = Ma(a, b, c, d + "." + p, e, void 0 !== f ? f[p] : void 0, g[p]); | ||
if (void 0 !== m || h) { | ||
k[p] = void 0 !== m ? m : null; | ||
} else { | ||
@@ -869,43 +793,13 @@ return; | ||
if ("string" == typeof g || "object" == typeof g && "string" == typeof g.__typename) { | ||
b = void 0 === f ? t() : f; | ||
if ("string" == typeof g) { | ||
a = Y(a, g, e, b); | ||
} else { | ||
a: if (d = (c = a.store).keyOfEntity(g) || d, h = g.__typename, "string" != typeof (f = Q(d, "__typename") || h) || h && f !== h) { | ||
"production" !== process.env.NODE_ENV && D("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 (m = k = !1; void 0 !== (h = e.next()); ) { | ||
l = h.name.value; | ||
q = n(h); | ||
var v = I(l, x(h, a.variables)), u = d + "." + v, w = Q(d, v), A = g[l]; | ||
"production" !== process.env.NODE_ENV && c.schema && f && G(c.schema, f, l); | ||
var p = void 0; | ||
void 0 !== A && void 0 === h.selectionSet ? p = A : void 0 === h.selectionSet ? p = w : void 0 !== A ? p = Oa(a, f, l, u, r(h), b[q], A) : void 0 !== (v = R(d, v)) ? p = Pa(a, v, f, l, r(h), b[q]) : "object" == typeof w && null !== w && (p = w); | ||
if (void 0 === p && void 0 !== c.schema && ia(c.schema, f, l)) { | ||
m = !0, b[q] = null; | ||
} else if (void 0 === p) { | ||
a = void 0; | ||
break a; | ||
} else { | ||
k = !0, b[q] = p; | ||
} | ||
} | ||
m && (a.partial = !0); | ||
a = k ? b : void 0; | ||
} | ||
} | ||
return a; | ||
return b = void 0 === f ? q() : f, "string" == typeof g ? Z(a, g, e, b) : Z(a, d, e, b, g); | ||
} | ||
"production" !== process.env.NODE_ENV && D("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 && F("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 Pa(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, m = b.length; k < m; k++) { | ||
var l = Pa(a, b[k], c, d, e, void 0 !== f ? f[k] : void 0); | ||
for (var h = Array(b.length), k = 0, p = b.length; k < p; k++) { | ||
var l = Na(a, b[k], c, d, e, void 0 !== f ? f[k] : void 0); | ||
if (void 0 !== l || g) { | ||
@@ -919,6 +813,6 @@ h[k] = void 0 !== l ? l : null; | ||
} | ||
return null === b ? null : Y(a, b, e, void 0 === f ? t() : f); | ||
return null === b ? null : Z(a, b, e, void 0 === f ? q() : f); | ||
} | ||
function Qa(a, b) { | ||
function Oa(a, b) { | ||
return _extends({}, a, { | ||
@@ -933,2 +827,10 @@ context: _extends({}, a.context, { | ||
function Pa(a, b) { | ||
return _extends({}, a, { | ||
context: _extends({}, a.context, { | ||
requestPolicy: b | ||
}) | ||
}); | ||
} | ||
function Ra(a) { | ||
@@ -944,56 +846,40 @@ return _extends({}, a, { | ||
function Ta(a, b) { | ||
return _extends({}, a, { | ||
context: _extends({}, a.context, { | ||
requestPolicy: b | ||
}) | ||
}); | ||
function Ta(a) { | ||
return Oa(a.operation, "miss"); | ||
} | ||
function Ua(a) { | ||
return Sa(a); | ||
return "miss" === a.outcome; | ||
} | ||
function Va(a) { | ||
return Qa(a.operation, a.outcome); | ||
return "miss" !== a.outcome; | ||
} | ||
function Wa(a) { | ||
return "miss" === a.outcome; | ||
return "cache-only" !== a.context.requestPolicy; | ||
} | ||
function Xa(a) { | ||
return "miss" !== a.outcome; | ||
return !("query" === a.operationName && "network-only" !== a.context.requestPolicy); | ||
} | ||
function Ya(a) { | ||
return "cache-only" !== a.context.requestPolicy; | ||
} | ||
function Za(a) { | ||
return !Sa(a); | ||
} | ||
function cacheExchange(a) { | ||
return function(b) { | ||
function c(a) { | ||
var b = a.operation, c = a.error, d = a.extensions, f = "query" === b.operationName, g = a.data, P = b.key, l = new Set; | ||
"mutation" === b.operationName ? (k(l, p.get(P)), p.delete(P)) : "subscription" === b.operationName && za(u.data, b.key); | ||
if (null != g) { | ||
var m = Da(u, b, g, P).dependencies; | ||
if (f) { | ||
g = (P = Z(u, b)).data; | ||
var q = P.dependencies; | ||
} else { | ||
g = Z(u, b, g).data; | ||
var b = a.operation, c = a.error, d = a.extensions, f = b.key, g = new Set; | ||
"mutation" === b.operationName ? (k(g, D.get(f)), D.delete(f)) : "subscription" === b.operationName && za(r.data, b.key); | ||
if (a.data) { | ||
if (k(g, f = Da(r, b, a.data, f).dependencies), f = Ja(r, b, a.data), a.data = f.data, | ||
"query" === b.operationName) { | ||
var E = f.dependencies; | ||
k(g, E); | ||
} | ||
} else { | ||
M(u.data, b.key, void 0), N(); | ||
P(r.data, b.key); | ||
} | ||
k(l, m); | ||
f && k(l, q); | ||
h(a.operation, l); | ||
f && void 0 !== q && e(a.operation, q); | ||
h(a.operation, g); | ||
E && e(a.operation, E); | ||
return { | ||
data: g, | ||
data: a.data, | ||
error: c, | ||
@@ -1005,9 +891,8 @@ extensions: d, | ||
function d(a) { | ||
var b = Z(u, a), c = b.data, d = b.dependencies; | ||
b = b.partial; | ||
null === c ? d = "miss" : (e(a, d), d = b && "cache-only" !== a.context.requestPolicy ? "partial" : "hit"); | ||
var b = Ja(r, a), c = b.data ? b.partial && "cache-only" !== a.context.requestPolicy ? "partial" : "hit" : "miss"; | ||
b.data && e(a, b.dependencies); | ||
return { | ||
outcome: d, | ||
outcome: c, | ||
operation: a, | ||
data: c | ||
data: b.data | ||
}; | ||
@@ -1017,4 +902,4 @@ } | ||
b.forEach((function(b) { | ||
(aa[b] || (aa[b] = [])).push(a.key); | ||
H.has(a.key) || H.set(a.key, "network-only" === a.context.requestPolicy ? Ta(a, "cache-and-network") : a); | ||
(A[b] || (A[b] = [])).push(a.key); | ||
z.has(a.key) || z.set(a.key, "network-only" === a.context.requestPolicy ? Pa(a, "cache-and-network") : a); | ||
})); | ||
@@ -1025,11 +910,10 @@ } | ||
if ("mutation" === a.operationName && "network-only" !== a.context.requestPolicy) { | ||
var c = Ga(u, a, b).dependencies; | ||
0 !== c.size && (p.set(b, c), k(b = new Set, c), h(a, b)); | ||
var c = Fa(r, a, b).dependencies; | ||
0 !== c.size && (D.set(b, c), k(b = new Set, c), h(a, b)); | ||
} else { | ||
M(u.data, b, !0), N(); | ||
P(r.data, b, !0); | ||
} | ||
} | ||
function g(a) { | ||
"query" === a.operationName ? za(u.data, a.key) : "teardown" === a.operationName && (M(u.data, a.key, void 0), | ||
N()); | ||
"query" === a.operationName ? za(r.data, a.key) : "teardown" === a.operationName && P(r.data, a.key); | ||
} | ||
@@ -1039,4 +923,4 @@ function h(a, b) { | ||
if (b !== a.key) { | ||
var c = H.get(b); | ||
void 0 !== c && (H.delete(b), v.reexecuteOperation(Ta(c, "cache-first"))); | ||
var c = z.get(b); | ||
c && (z.delete(b), C.reexecuteOperation(Pa(c, "cache-first"))); | ||
} | ||
@@ -1046,6 +930,6 @@ })); | ||
function k(a, b) { | ||
void 0 !== b && b.forEach((function c(b) { | ||
var c = aa[b]; | ||
if (void 0 !== c) { | ||
aa[b] = []; | ||
b && b.forEach((function c(b) { | ||
var c = A[b]; | ||
if (c) { | ||
A[b] = []; | ||
b = 0; | ||
@@ -1059,5 +943,5 @@ for (var d = c.length; b < d; b++) { | ||
function l(a) { | ||
var b = a.operation, c = a.outcome, d = b.context.requestPolicy; | ||
var b = a.operation, c = a.outcome; | ||
a = { | ||
operation: Qa(b, c), | ||
operation: Oa(b, c), | ||
data: a.data, | ||
@@ -1067,40 +951,37 @@ error: a.error, | ||
}; | ||
if ("cache-and-network" === d || "cache-first" === d && "partial" === c) { | ||
a.stale = !0, v.reexecuteOperation(Ta(b, "network-only")); | ||
if ("cache-and-network" === b.context.requestPolicy || "cache-first" === b.context.requestPolicy && "partial" === c) { | ||
a.stale = !0, C.reexecuteOperation(Pa(b, "network-only")); | ||
} | ||
return a; | ||
} | ||
var q = b.forward, v = b.client; | ||
var m = b.forward, C = b.client; | ||
a || (a = {}); | ||
var u = new X(a.schema, a.resolvers, a.updates, a.optimistic, a.keys); | ||
if (a.storage) { | ||
var w = a.storage; | ||
var A = w.read().then((function m(a) { | ||
var b = u.data, c = w; | ||
M(b, null); | ||
for (var d in a) { | ||
var e = d.indexOf("."), f = d.slice(2, e); | ||
e = d.slice(e + 1); | ||
switch (d.charCodeAt(0)) { | ||
case 108: | ||
T(f, e, a[d]); | ||
break; | ||
var y, r = new Y(a.schema, a.resolvers, a.updates, a.optimistic, a.keys); | ||
a.storage && (y = a.storage.read().then((function p(b) { | ||
var c = r.data, d = a.storage; | ||
N(c, null); | ||
for (var e in b) { | ||
var f = e.indexOf("."), g = e.slice(2, f); | ||
f = e.slice(f + 1); | ||
switch (e.charCodeAt(0)) { | ||
case 108: | ||
U(g, f, b[e]); | ||
break; | ||
case 114: | ||
S(f, e, a[d]); | ||
} | ||
case 114: | ||
T(g, f, b[e]); | ||
} | ||
N(); | ||
b.storage = c; | ||
})); | ||
} | ||
var p = new Map, H = new Map, aa = t(); | ||
} | ||
O(); | ||
c.storage = d; | ||
}))); | ||
var D = new Map, z = new Map, A = q(); | ||
return function(a) { | ||
a = share(a); | ||
var b = A ? mergeMap(fromArray)(take(1)(buffer(fromPromise(A))(a))) : empty; | ||
var b = y ? mergeMap(fromArray)(take(1)(buffer(fromPromise(y))(a))) : empty; | ||
a = share(tap(f)(map(Ra)(concat([ b, a ])))); | ||
var e = share(map(d)(filter(Ua)(a))); | ||
b = map(Va)(filter(Wa)(e)); | ||
e = map(l)(filter(Xa)(e)); | ||
a = map(c)(q(tap(g)(filter(Ya)(merge([ filter(Za)(a), b ]))))); | ||
var e = share(map(d)(filter(Sa)(a))); | ||
b = map(Ta)(filter(Ua)(e)); | ||
e = map(l)(filter(Va)(e)); | ||
a = map(c)(m(tap(g)(filter(Wa)(merge([ filter(Xa)(a), b ]))))); | ||
return merge([ a, e ]); | ||
@@ -1111,3 +992,3 @@ }; | ||
export { X as Store, cacheExchange, N as clearDataState, M as initDataState, Z as query, La as read, Da as write, Ia as writeFragment, Ga as writeOptimistic }; | ||
export { Y as Store, cacheExchange, P as noopDataState, Ja as query, za as reserveLayer, Da as write, Fa as writeOptimistic }; | ||
//# sourceMappingURL=urql-exchange-graphcache.esm.js.map |
@@ -1,2 +0,2 @@ | ||
import{share as e,mergeMap as t,fromArray as i,take as n,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 _,GraphQLUnionType as S,buildClientSchema as x}from"graphql";import{_ as O}from"./406259e3.esm.min.js";export{populateExchange}from"@urql/exchange-populate";function K(e){return void 0!==e.alias?e.alias.value:e.name.value}function q(e){return void 0!==e.selectionSet?e.selectionSet.selections:[]}function w(e){return void 0!==(e=e.typeCondition)?e.name.value:null}function N(){return Object.create(null)}function E(e,t){if(void 0===e.arguments||0===e.arguments.length)return null;for(var i=N(),n=0,r=0,o=e.arguments.length;r<o;r++){var a=e.arguments[r],s=m(a.value,t);null!=s&&(i[a.name.value]=s,n++)}return 0<n?i:null}function F(e,t){if(void 0===e.variableDefinitions)return{};var i=t||{};return e.variableDefinitions.reduce((function(e,t){var n=t.variable.name.value,r=i[n];if(void 0===r){if(void 0===t.defaultValue)return e;r=m(t.defaultValue,i)}return e[n]=r,e}),N())}function A(e,t,i){if(!e)throw(e=Error((t||"Minfied Error #"+i+"\n")+"\nhttps://bit.ly/38yWDau#"+i)).name="Graphcache Error",e}function T(e){return e.kind===y.FRAGMENT_DEFINITION}function R(e){return e.kind===y.OPERATION_DEFINITION}function M(e){return A(!!(e=e.definitions.find(R)),"",1),e}function B(e,t){return e[t.name.value]=t,e}function L(e){return e.definitions.filter(T).reduce(B,{})}function P(e,t,i){return void 0!==(e=C(e,t,i))&&h(e.type)}function I(e,t,i){return void 0!==(e=C(e,t,i))&&(e=g(e.type)?e.type.ofType:e.type,k(e)&&h(e.ofType))}function C(e,t,i){if(A((e=e.getType(t))instanceof b,"",3),void 0!==(i=e.getFields()[i]))return i}function D(e,t){return t?e+"("+d(t)+")":e}function Q(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 j="undefined"!=typeof Promise?Promise.prototype.then.bind(Promise.resolve()):function(e){return setTimeout(e,0)},z=null,G=null,W=null;function V(e,t,i){z=e,G=new Set,t?i||1<e.optimisticOrder.length&&-1<e.optimisticOrder.indexOf(t)?(i||e.commutativeKeys.has(t)||(ue(e,t),e.commutativeKeys.add(t)),W=t,-1===e.optimisticOrder.indexOf(t)&&e.optimisticOrder.unshift(t),e.refLock[t]||(e.refLock[t]=N(),e.links.optimistic[t]=new Map,e.records.optimistic[t]=new Map)):(W=null,ce(e,t)):W=null}function J(){var e=z,t=W;if(W=null,t&&-1<e.optimisticOrder.indexOf(t)){t=e.optimisticOrder.length-e.commutativeKeys.size;for(var i=e.optimisticOrder.length;--i>=t&&e.refLock[e.optimisticOrder[i]]&&e.commutativeKeys.has(e.optimisticOrder[i]);)de(e.optimisticOrder[i])}G=z=null,!e.gcScheduled&&0<e.gcBatch.size&&(e.gcScheduled=!0,j((function(){te(e)}))),e.storage&&!e.persistenceScheduled&&(e.persistenceScheduled=!0,j((function(){e.storage.write(e.persistenceBatch),e.persistenceScheduled=!1,e.persistenceBatch=N()})))}function H(){return A(null!==G,"",2),G}function U(e,t,i,n){var r=(e=W?e.optimistic[W]:e.base).get(t);void 0===r&&e.set(t,r=N()),void 0!==n||W?r[i]=n:delete r[i]}function X(e,t,i){for(var n,r=0,o=z.optimisticOrder.length;r<o;r++){var a=e.optimistic[z.optimisticOrder[r]];if(a&&void 0!==(n=a.get(t))&&i in n)return n[i]}return void 0!==(n=e.base.get(t))?n[i]:void 0}function Y(e,t,i,n){var r=void 0!==t[i]?t[i]:0;t=t[i]=r+n|0,void 0!==e&&(0>=t?e.add(i):0>=r&&0<t&&e.delete(i))}function Z(e,t,i,n){if("string"==typeof i)Y(e,t,i,n);else if(Array.isArray(i))for(var r=0,o=i.length;r<o;r++){var a=i[r];a&&Y(e,t,a,n)}}function $(e,t,i){if(void 0!==i)for(var n in i)t.has(n)||(e.push(Q(n)),t.add(n))}function ee(e,t,i,n){$(e,t,n.base.get(i));for(var r=0,o=z.optimisticOrder.length;r<o;r++)$(e,t,n.optimistic[z.optimisticOrder[r]].get(i))}function te(e){e.gcScheduled=!1,e.gcBatch.forEach((function(t){if(0>=(e.refCount[t]||0)){for(var i in e.refLock){var n=e.refLock[i];if(0<(n[t]||0))return;delete n[t]}if(delete e.refCount[t],e.gcBatch.delete(t),void 0!==(i=e.records.base.get(t))&&(e.records.base.delete(t),e.storage))for(var r in i)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),Z(e.gcBatch,e.refCount,r[o],-1)}else e.gcBatch.delete(t)}))}function ie(e,t){"__typename"!==t&&(e!==z.queryRootKey?G.add(e):void 0!==t&&G.add(e+"."+t))}function ne(e,t){return ie(e,t),X(z.records,e,t)}function re(e,t){return ie(e,t),X(z.links,e,t)}function oe(e,t,i){ie(e,t),U(z.records,e,t,i),z.storage&&!W&&(z.persistenceBatch["r|"+e+"."+t]=i)}function ae(e,t,i){var n=z;if(W)var r=n.refLock[W]||(n.refLock[W]=N()),o=n.links.optimistic[W];else{n.storage&&(n.persistenceBatch["l|"+e+"."+t]=i),r=n.refCount,o=n.links.base;var a=n.gcBatch}o=void 0!==(o=void 0!==o?o.get(e):void 0)?o[t]:null,ie(e,t),U(n.links,e,t,i),Z(a,r,o,-1),Z(a,r,i,1)}function se(e,t){e.commutativeKeys.has(t)||(e.optimisticOrder.unshift(t),e.commutativeKeys.add(t))}function ue(e,t){e.refLock[t]&&(delete e.refLock[t],delete e.records.optimistic[t],delete e.links.optimistic[t])}function ce(e,t){var i=e.optimisticOrder.indexOf(t);-1<i&&(e.optimisticOrder.splice(i,1),e.commutativeKeys.delete(t)),ue(e,t)}function le(e,t){for(var i in e)ae(t,i,e[i])}function fe(e,t){for(var i in e)oe(t,i,e[i])}function de(e){var t=G;G=new Set;var i=z.links.optimistic[e];i&&i.forEach(le),(i=z.records.optimistic[e])&&i.forEach(fe),G=t,ce(z,e)}function ve(e,t,i,n){return!(!t||t!==w(e)&&q(e).some((function(e){return e.kind===y.FIELD&&(e=D(e.name.value,E(e,n)),!(void 0!==ne(i,e)||void 0!==re(i,e)))})))}function pe(e,t,i,n){this.typename=e,this.entityKey=t,this.context=n,this.indexStack=[0],this.selectionStack=[i]}function ye(e){return void 0===e?null:e}function me(e,t,i,n){return V(e.data,n||null),e=he(e,t,i),J(),e}function he(e,t,i){var n=M(t.query),r={dependencies:H()},o=q(n),a=e.getRootKey(n.operation);return a===(e={parentTypeName:a,parentKey:a,parentFieldKey:"",fieldName:"",store:e,variables:F(n,t.variables),fragments:L(t.query)}).store.getRootKey("query")?be(e,a,o,i):Se(e,a,o,i),r}function ge(e,t,i){V(e.data,i,!0);var n=M(t.query);i={dependencies:H()};var r,o=e.getRootKey("mutation"),a=e.getRootKey(n.operation);for(A(a===o,"",10),e={parentTypeName:o,parentKey:o,parentFieldKey:"",fieldName:"",variables:F(n,t.variables),fragments:L(t.query),store:e,optimistic:!0},t=N(),n=new pe(a,a,q(n),e);void 0!==(r=n.next());)if(void 0!==r.selectionSet){var s=r.name.value,u=e.store.optimisticMutations[s];void 0!==u&&(e.fieldName=s,xe(e,ye(u=u((a=E(r,e.variables))||N(),e.store,e)),q(r)),t[s]=u,void 0!==(r=e.store.updates[o][s])&&r(t,a||N(),e.store,e))}return J(),i}function ke(e,t,i,n){t=L(t);var r=Object.keys(t);if(void 0!==(r=t[r[0]])){var o=r.typeCondition.name.value;i=O({},{__typename:o},i);var a=e.keyOfEntity(i);a&&be({parentTypeName:o,parentKey:a,parentFieldKey:"",fieldName:"",variables:n||{},fragments:t,store:e},a,q(r),i)}}function be(e,t,i,n){var r=t===e.store.getRootKey("query")?t:n.__typename;if("string"==typeof r)for(oe(t,"__typename",r),i=new pe(r,t,i,e);void 0!==(r=i.next());){var o=r.name.value,a=E(r,e.variables);o=D(o,a);var s=n[K(r)];a=t+"."+o,void 0===r.selectionSet?oe(t,o,s):(s=ye(s),ae(t,o,r=_e(e,a,q(r),s)))}}function _e(e,t,i,n){if(Array.isArray(n)){for(var r=Array(n.length),o=0,a=n.length;o<a;o++){var s=_e(e,t+"."+o,i,n[o]);r[o]=s}return r}return null===n?null:(t=null!==(r=e.store.keyOfEntity(n))?r:t,o=n.__typename,void 0!==e.store.keys[n.__typename]||null!==r||"string"!=typeof o||o.endsWith("Connection")||o.endsWith("Edge"),be(e,t,i,n),t)}function Se(e,t,i,n){var r,o=t===e.store.getRootKey("mutation")||t===e.store.getRootKey("subscription");for(i=new pe(t,t,i,e);void 0!==(r=i.next());){var a=r.name.value,s=E(r,e.variables),u=D(a,s);u=t+"."+u,void 0!==r.selectionSet&&xe(e,ye(n[K(r)]),q(r)),o&&(e.parentTypeName=t,e.parentKey=t,e.parentFieldKey=u,e.fieldName=a,void 0!==(r=e.store.updates[t][a])&&r(n,s||N(),e.store,e))}}function xe(e,t,i){if(Array.isArray(t)){for(var n=Array(t.length),r=0,o=t.length;r<o;r++)n[r]=xe(e,t[r],i);return n}null!==t&&(null!==(n=e.store.keyOfEntity(t))?be(e,n,i,t):Se(e,t.__typename,i,t))}function Oe(e,t,i,n,r){var o,a=this;this.gcScheduled=!1,this.gc=function(){te(a.data),a.gcScheduled=!1},this.keyOfField=D,this.resolvers=t||{},this.optimisticMutations=n||{},this.keys=r||{},this.updates={Mutation:i&&i.Mutation||{},Subscription:i&&i.Subscription||{}},e?(i=(t=this.schema=x(e)).getQueryType(),e=t.getMutationType(),t=t.getSubscriptionType(),this.rootFields={query:i=i?i.name:"Query",mutation:e=e?e.name:"Mutation",subscription:t=t?t.name:"Subscription"},this.rootNames=((o={})[i]="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:N(),gcScheduled:!1,queryRootKey:e,gcBatch:new Set,refCount:N(),refLock:N(),links:{optimistic:N(),base:new Map},records:{optimistic:N(),base:new Map},commutativeKeys:new Set,optimisticOrder:[],storage:null}}(this.getRootKey("query"))}function Ke(e,t,i){return V(e.data,null),e=qe(e,t,i),J(),e}function qe(e,t,i){var n=M(t.query),r=e.getRootKey(n.operation),o=q(n);return e={parentTypeName:r,parentKey:r,parentFieldKey:"",fieldName:"",store:e,variables:F(n,t.variables),fragments:L(t.query),partial:!1},i=i||N(),i=r!==e.store.getRootKey("query")?we(e,r,o,i):Ee(e,r,o,i),{dependencies:H(),partial:void 0!==i&&e.partial,data:void 0===i?null:i}}function we(e,t,i,n){if("string"!=typeof n.__typename)return n;t=new pe(t,t,i,e),(i=N()).__typename=n.__typename;for(var r;void 0!==(r=t.next());){var o=K(r),a=n[o];void 0!==r.selectionSet&&null!==a?(a=ye(a),i[o]=Ne(e,q(r),a)):i[o]=a}return i}function Ne(e,t,i){if(Array.isArray(i)){for(var n=Array(i.length),r=0,o=i.length;r<o;r++)n[r]=Ne(e,t,i[r]);return n}return null===i?null:null!==(n=e.store.keyOfEntity(i))?void 0===(e=Ee(e,n,t,N()))?null:e:we(e,i.__typename,t,i)}function Ee(e,t,i,n){var r=e.store,o=t===r.getRootKey("query"),a=o?t:ne(t,"__typename");if("string"==typeof a){n.__typename=a,i=new pe(a,t,i,e);for(var s,u=!1,c=!1;void 0!==(s=i.next());){var l=s.name.value,f=E(s,e.variables),d=K(s),v=D(l,f),p=ne(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&&(n[d]=p),m=h[l](n,f||N(),r,e),void 0!==s.selectionSet&&(m=Fe(e,a,l,y,q(s),n[d]||N(),m)),r.schema&&null===m&&!P(r.schema,a,l))return}else void 0===s.selectionSet?m=p:void 0!==(f=re(t,v))?m=Ae(e,f,a,l,q(s),n[d]):"object"==typeof p&&null!==p&&(m=p);if(void 0===m&&r.schema&&P(r.schema,a,l))c=!0,n[d]=null;else{if(void 0===m)return;u=!0,n[d]=m}}return c&&(e.partial=!0),o&&c&&!u?void 0:n}}function Fe(e,t,i,n,r,o,a){if(Array.isArray(a)){var s=e.store;s=!s.schema||I(s.schema,t,i);for(var u=Array(a.length),c=0,l=a.length;c<l;c++){var f=Fe(e,t,i,n+"."+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?N():o,"string"==typeof a)e=Ee(e,a,r,t);else e:if(n=(i=e.store).keyOfEntity(a)||n,s=a.__typename,"string"!=typeof(o=ne(n,"__typename")||s)||s&&o!==s)e=void 0;else{for(t.__typename=o,r=new pe(o,n,r,e),c=u=!1;void 0!==(s=r.next());){l=s.name.value,f=K(s);var d=D(l,E(s,e.variables)),v=n+"."+d,p=ne(n,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=Fe(e,o,l,v,q(s),t[f],y):void 0!==(d=re(n,d))?m=Ae(e,d,o,l,q(s),t[f]):"object"==typeof p&&null!==p&&(m=p),void 0===m&&void 0!==i.schema&&P(i.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 Ae(e,t,i,n,r,o){if(Array.isArray(t)){var a=e.store;a=a.schema&&I(a.schema,i,n);for(var s=Array(t.length),u=0,c=t.length;u<c;u++){var l=Ae(e,t[u],i,n,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:Ee(e,t,r,void 0===o?N():o)}function Te(e,t){return O({},e,{context:O({},e.context,{meta:O({},e.context.meta,{cacheOutcome:t})})})}function Re(e){return O({},e,{query:p(e.query)})}function Me(e){return"query"===e.operationName&&"network-only"!==e.context.requestPolicy}function Be(e,t){return O({},e,{context:O({},e.context,{requestPolicy:t})})}function Le(e){return Me(e)}function Pe(e){return Te(e.operation,e.outcome)}function Ie(e){return"miss"===e.outcome}function Ce(e){return"miss"!==e.outcome}function De(e){return"cache-only"!==e.context.requestPolicy}function Qe(e){return!Me(e)}function je(d){return function(v){function p(e){var t=e.operation,i=e.error,n=e.extensions,r="query"===t.operationName,o=e.data,a=t.key,s=new Set;if("mutation"===t.operationName?(b(s,w.get(a)),w.delete(a)):"subscription"===t.operationName&&se(O.data,t.key),null!=o){var u=me(O,t,o,a).dependencies;if(r){o=(a=Ke(O,t)).data;var c=a.dependencies}else o=Ke(O,t,o).data}else V(O.data,t.key,void 0),J();return b(s,u),r&&b(s,c),k(e.operation,s),r&&void 0!==c&&m(e.operation,c),{data:o,error:i,extensions:n,operation:t}}function y(e){var t=Ke(O,e),i=t.data,n=t.dependencies;return t=t.partial,null===i?n="miss":(m(e,n),n=t&&"cache-only"!==e.context.requestPolicy?"partial":"hit"),{outcome:n,operation:e,data:i}}function m(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?Be(e,"cache-and-network"):e)}))}function h(e){var t=e.key;if("mutation"===e.operationName&&"network-only"!==e.context.requestPolicy){var i=ge(O,e,t).dependencies;0!==i.size&&(w.set(t,i),b(t=new Set,i),k(e,t))}else V(O.data,t,!0),J()}function g(e){"query"===e.operationName?se(O.data,e.key):"teardown"===e.operationName&&(V(O.data,e.key,void 0),J())}function k(e,t){t.forEach((function(t){if(t!==e.key){var i=E.get(t);void 0!==i&&(E.delete(t),x.reexecuteOperation(Be(i,"cache-first")))}}))}function b(e,t){void 0!==t&&t.forEach((function(t){var i=F[t];if(void 0!==i){F[t]=[],t=0;for(var n=i.length;t<n;t++)e.add(i[t])}}))}function _(e){var t=e.operation,i=e.outcome,n=t.context.requestPolicy;return e={operation:Te(t,i),data:e.data,error:e.error,extensions:e.extensions},("cache-and-network"===n||"cache-first"===n&&"partial"===i)&&(e.stale=!0,x.reexecuteOperation(Be(t,"network-only"))),e}var S=v.forward,x=v.client;d||(d={});var O=new Oe(d.schema,d.resolvers,d.updates,d.optimistic,d.keys);if(d.storage)var K=d.storage,q=K.read().then((function(e){var t=O.data,i=K;for(var n in V(t,null),e){var r=n.indexOf("."),o=n.slice(2,r);switch(r=n.slice(r+1),n.charCodeAt(0)){case 108:ae(o,r,e[n]);break;case 114:oe(o,r,e[n])}}J(),t.storage=i}));var w=new Map,E=new Map,F=N();return function(d){d=e(d);var v=q?t(i)(n(1)(r(o(q))(d))):a;d=e(s(h)(u(Re)(c([v,d]))));var m=e(u(y)(l(Le)(d)));return v=u(Pe)(l(Ie)(m)),m=u(_)(l(Ce)(m)),d=u(p)(S(s(g)(l(De)(f([l(Qe)(d),v]))))),f([d,m])}}}pe.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 i=e.directives;if(void 0!==i)for(var n=0,r=i.length;n<r;n++){var o=i[n],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,n=w(e),(i=this.typename)&&n?i===n?t=!0:(n=t.getType(n),i=t.getType(i),n instanceof b?t=n===i:(A(n instanceof _||n instanceof S,"",5),A(i instanceof b,"",3),t=t.isPossibleType(n,i))):t=!1):t=ve(e,this.typename,this.entityKey,this.context.variables),t&&(this.indexStack.push(0),this.selectionStack.push(q(e))));else if("__typename"!==e.name.value)return e}}},Oe.prototype.getRootKey=function(e){return this.rootFields[e]},Oe.prototype.keyOfEntity=function(e){var t,i=e.__typename,n=e.id,r=e._id;return i?void 0!==this.rootNames[i]?i:(this.keys[i]?t=this.keys[i](e):null!=n?t=""+n:null!=r&&(t=""+r),t?i+":"+t:null):null},Oe.prototype.resolveFieldByKey=function(e,t){if(null===(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e))return null;var i=ne(e,t);return void 0!==i?i:(t=re(e,t))?t:null},Oe.prototype.resolve=function(e,t,i){return this.resolveFieldByKey(e,D(t,i))},Oe.prototype.invalidateQuery=function(e,t){!function e(t,i,n){if("Query"!==i){var r=ne(i,"__typename");if("string"!=typeof r)return;oe(i,"__typename",void 0)}else r=i;for(n=new pe(r,i,n,t);void 0!==(r=n.next());){var o=D(r.name.value,E(r,t.variables));if(void 0===r.selectionSet)oe(i,o,void 0);else{r=q(r);var a=re(i,o);if(ae(i,o,void 0),oe(i,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:F(e=M((t=v(e,t)).query),t.variables),fragments:L(t.query),store:this},t.store.getRootKey("query"),q(e))},Oe.prototype.invalidate=function(e){A(e="string"==typeof e?e:this.keyOfEntity(e),"",19);for(var t=0,i=this.inspectFields(e);t<i.length;t+=1){var n=i[t];re(e,n.fieldKey)?ae(e,n.fieldKey,void 0):oe(e,n.fieldKey,void 0)}},Oe.prototype.inspectFields=function(e){if(null!==(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e)){var t=z.links,i=z.records,n=[],r=new Set;ie(e),ee(n,r,e,t),ee(n,r,e,i),e=n}else e=[];return e},Oe.prototype.updateQuery=function(e,t){e=v(e.query,e.variables),null!==(t=t(this.readQuery(e)))&&he(this,e,t)},Oe.prototype.readQuery=function(e){return qe(this,v(e.query,e.variables)).data},Oe.prototype.readFragment=function(e,t,i){e=L(e);var n=Object.keys(e);if(void 0===(n=e[n[0]]))i=null;else{var r=n.typeCondition.name.value;"string"==typeof t||t.__typename||(t.__typename=r),i=(t="string"!=typeof t?this.keyOfEntity(O({},{__typename:r},t)):t)&&Ee({parentTypeName:r,parentKey:t,parentFieldKey:"",fieldName:"",variables:i||{},fragments:e,partial:!1,store:this},t,q(n),N())||null}return i},Oe.prototype.writeFragment=function(e,t,i){ke(this,e,t,i)};export{Oe as Store,je as cacheExchange,J as clearDataState,V as initDataState,Ke as query,qe as read,me as write,ke as writeFragment,ge 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 p,formatDocument as y}from"@urql/core";import{Kind as v,valueFromASTUntyped as m,isNullableType as h,isNonNullType as g,isListType as k,GraphQLObjectType as x,GraphQLInterfaceType as O,GraphQLUnionType as _,buildClientSchema as b}from"graphql";import{_ as S}from"./406259e3.esm.min.js";export{populateExchange}from"@urql/exchange-populate";function q(e){return e.selectionSet?e.selectionSet.selections:[]}function w(e){return(e=e.typeCondition)?e.name.value:null}function N(){return Object.create(null)}function K(e,t){var n=N(),i=0;if(e.arguments&&e.arguments.length)for(var 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 E(e,t){t=t||{};var n=N();if(e.variableDefinitions)for(var i=0,r=e.variableDefinitions.length;i<r;i++){var o=e.variableDefinitions[i],a=o.variable.name.value,s=t[a];void 0===s&&o.defaultValue&&(s=m(o.defaultValue,t)),n[a]=s}return n}function F(e,t,n){if(!e)throw(e=Error((t||"Minfied Error #"+n+"\n")+"\nhttps://bit.ly/38yWDau#"+n)).name="Graphcache Error",e}function T(e){return e.kind===v.FRAGMENT_DEFINITION}function A(e){return e.kind===v.OPERATION_DEFINITION}function B(e){return F(!!(e=e.definitions.find(A)),"",1),e}function M(e,t){return e[t.name.value]=t,e}function L(e){return e.definitions.filter(T).reduce(M,{})}function P(e,t,n){return!!(e=C(e,t,n))&&h(e.type)}function I(e,t,n){return!!(e=C(e,t,n))&&(e=g(e.type)?e.type.ofType:e.type,k(e)&&h(e.ofType))}function C(e,t,n){return F((e=e.getType(t))instanceof x,"",3),e.getFields()[n]}function D(e,t){return t?e+"("+d(t)+")":e}function R(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 j="undefined"!=typeof Promise?Promise.prototype.then.bind(Promise.resolve()):function(e){return setTimeout(e,0)},Q=null,W=null,G=null,z=null;function V(e,t,n){Q=e,G=W,W=new Set,t?n||1<e.optimisticOrder.length&&-1<e.optimisticOrder.indexOf(t)?(n||e.commutativeKeys.has(t)||(le(e,t),e.commutativeKeys.add(t)),z=t,-1===e.optimisticOrder.indexOf(t)&&e.optimisticOrder.unshift(t),e.refLock[t]||(e.refLock[t]=N(),e.links.optimistic[t]=new Map,e.records.optimistic[t]=new Map)):(z=null,fe(e,t)):z=null}function J(){var e=Q,t=z;if(z=null,t&&-1<e.optimisticOrder.indexOf(t))for(t=e.optimisticOrder.length;0<=--t&&e.refLock[e.optimisticOrder[t]]&&e.commutativeKeys.has(e.optimisticOrder[t]);)ye(e.optimisticOrder[t]);W=Q=null,!e.gcScheduled&&0<e.gcBatch.size&&(e.gcScheduled=!0,j((function(){ie(e)}))),e.storage&&!e.persistenceScheduled&&(e.persistenceScheduled=!0,j((function(){e.storage.write(e.persistenceBatch),e.persistenceScheduled=!1,e.persistenceBatch=N()})))}function H(e,t,n){V(e,t,n),J()}function U(){return F(null!==W,"",2),W}function X(){return G=W,W=new Set}function Y(e,t,n,i){var r=(e=z?e.optimistic[z]:e.base).get(t);void 0===r&&e.set(t,r=N()),void 0!==i||z?r[n]=i:delete r[n]}function Z(e,t,n){for(var i,r=0,o=Q.optimisticOrder.length;r<o;r++){var a=e.optimistic[Q.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 $(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 ee(e,t,n,i){if("string"==typeof n)$(e,t,n,i);else if(Array.isArray(n))for(var r=0,o=n.length;r<o;r++){var a=n[r];a&&$(e,t,a,i)}}function te(e,t,n){if(void 0!==n)for(var i in n)t.has(i)||(e.push(R(i)),t.add(i))}function ne(e,t,n,i){te(e,t,i.base.get(n));for(var r=0,o=Q.optimisticOrder.length;r<o;r++)te(e,t,i.optimistic[Q.optimisticOrder[r]].get(n))}function ie(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),ee(e.gcBatch,e.refCount,r[o],-1)}else e.gcBatch.delete(t)}))}function re(e,t){"__typename"!==t&&(e!==Q.queryRootKey?W.add(e):void 0!==t&&W.add(e+"."+t))}function oe(e,t){return re(e,t),Z(Q.records,e,t)}function ae(e,t){return re(e,t),Z(Q.links,e,t)}function se(e,t,n){re(e,t),Y(Q.records,e,t,n),Q.storage&&!z&&(Q.persistenceBatch["r|"+e+"."+t]=n)}function ue(e,t,n){var i=Q;if(z)var r=i.refLock[z]||(i.refLock[z]=N()),o=i.links.optimistic[z];else{i.storage&&(i.persistenceBatch["l|"+e+"."+t]=n),r=i.refCount,o=i.links.base;var a=i.gcBatch}o=(o=o&&o.get(e))&&o[t],re(e,t),Y(i.links,e,t,n),ee(a,r,o,-1),ee(a,r,n,1)}function ce(e,t){e.commutativeKeys.has(t)||(e.optimisticOrder.unshift(t),e.commutativeKeys.add(t))}function le(e,t){e.refLock[t]&&(delete e.refLock[t],delete e.records.optimistic[t],delete e.links.optimistic[t])}function fe(e,t){var n=e.optimisticOrder.indexOf(t);-1<n&&(e.optimisticOrder.splice(n,1),e.commutativeKeys.delete(t)),le(e,t)}function de(e,t){for(var n in e)ue(t,n,e[n])}function pe(e,t){for(var n in e)se(t,n,e[n])}function ye(e){X();var t=Q.links.optimistic[e];t&&t.forEach(de),(t=Q.records.optimistic[e])&&t.forEach(pe),W=G,G=null,fe(Q,e)}function ve(e,t,n,i,r,o){return{store:e,variables:t,fragments:n,parentTypeName:i,parentKey:r,parentFieldKey:"",fieldName:"",partial:!1,optimistic:!!o}}function me(e,t,n,i){return!(!t||t!==w(e)&&q(e).some((function(e){return e.kind===v.FIELD&&(e=D(e.name.value,K(e,i)),!(void 0!==oe(n,e)||void 0!==ae(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,t,n,i){return V(e.data,i||null),e=ke(e,t,n),J(),e}function ke(e,t,n){var i=B(t.query),r={dependencies:U()},o=e.rootFields[i.operation];return Oe(e=ve(e,E(i,t.variables),L(t.query),o,o),o,q(i),n),r}function xe(e,t,n){V(e.data,n,!0),n=B(t.query);var i={dependencies:U()},r=e.rootFields[n.operation];return F(r===e.rootFields.mutation,"",10),e=ve(e,E(n,t.variables),L(t.query),r,r,!0),t=N(),Oe(e,r,q(n),t),J(),i}function Oe(e,t,n,i){var r=t===e.store.rootFields.query,o=!r&&!!e.store.rootNames[t],a=o||r?t:i.__typename;if(a){o||r||!t||se(t,"__typename",a),n=new he(a,t||a,n,e);for(var s;s=n.next();){var u=s.name.value,c=D(u,r=K(s,e.variables)),l=i[s.alias?s.alias.value:s.name.value];if(s.selectionSet){if(e.optimistic&&o){if(!(l=e.store.optimisticMutations[u]))continue;var f=e,d=a,p=c,y=u;f.parentTypeName=a,f.parentKey=d,f.parentFieldKey=p,f.fieldName=y,l=l(r||N(),e.store,e),i[u]=l=void 0===l?null:l}else l=void 0===l?null:l;t&&!o?(f=t+"."+c,ue(t||a,c,s=_e(e,q(s),l,f))):_e(e,q(s),l)}else t&&!o&&se(t||a,c,l);o&&(l=a,c=a+"."+c,f=u,(s=e).parentTypeName=a,s.parentKey=l,s.parentFieldKey=c,s.fieldName=f,(u=e.store.updates[a][u])&&u(i,r||N(),e.store,e))}}}function _e(e,t,n,i){if(Array.isArray(n)){for(var r=Array(n.length),o=0,a=n.length;o<a;o++){var s=_e(e,t,n[o],i?i+"."+o:void 0);r[o]=s}return r}return null===n?null:(r=e.store.keyOfEntity(n),o=n.__typename,!i||void 0!==e.store.keys[n.__typename]||null!==r||"string"!=typeof o||o.endsWith("Connection")||o.endsWith("Edge"),Oe(e,i=r||i,t,n),i||null)}function be(e,t,n,i,r){var o;if(this.keyOfField=D,this.resolvers=t||{},this.optimisticMutations=i||{},this.keys=r||{},this.updates={Mutation:n&&n.Mutation||{},Subscription:n&&n.Subscription||{}},t="Query",n="Mutation",i="Subscription",e){var a=this.schema=b(e);e=a.getQueryType(),r=a.getMutationType(),a=a.getSubscriptionType(),e&&(t=e.name),r&&(n=r.name),a&&(i=a.name)}this.rootFields={query:t,mutation:n,subscription:i},this.rootNames=((o={})[t]="query",o[n]="mutation",o[i]="subscription",o),o=t,this.data={persistenceScheduled:!1,persistenceBatch:N(),gcScheduled:!1,queryRootKey:o,gcBatch:new Set,refCount:N(),refLock:N(),links:{optimistic:N(),base:new Map},records:{optimistic:N(),base:new Map},commutativeKeys:new Set,optimisticOrder:[],storage:null}}function Se(e,t,n){return V(e.data,null),e=qe(e,t,n),J(),e}function qe(e,t,n){var i=B(t.query),r=e.rootFields[i.operation],o=q(i);return e=ve(e,E(i,t.variables),L(t.query),r,r),n=n||N(),n=r!==e.store.rootFields.query?we(e,r,o,n):Ke(e,r,o,n),{dependencies:U(),partial:void 0!==n&&e.partial,data:void 0===n?null:n}}function we(e,t,n,i){if("string"!=typeof i.__typename)return i;t=new he(t,t,n,e),(n=N()).__typename=i.__typename;for(var r;void 0!==(r=t.next());){var o=r.alias?r.alias.value:r.name.value,a=i[o];void 0!==r.selectionSet&&null!==a?(a=void 0===a?null:a,n[o]=Ne(e,q(r),a)):n[o]=a}return n}function Ne(e,t,n){if(Array.isArray(n)){for(var i=Array(n.length),r=0,o=n.length;r<o;r++)i[r]=Ne(e,t,n[r]);return i}return null===n?null:null!==(i=e.store.keyOfEntity(n))?void 0===(e=Ke(e,i,t,N()))?null:e:we(e,n.__typename,t,n)}function Ke(e,t,n,i,r){var o=e.store,a=t===o.rootFields.query,s=r&&o.keyOfEntity(r)||t;if(!("string"!=typeof(t=a?t:oe(s,"__typename")||r&&r.__typename)||r&&t!==r.__typename)){i.__typename=t,n=new he(t,s,n,e);for(var u,c=!1,l=!1;void 0!==(u=n.next());){var f=u.name.value,d=K(u,e.variables),p=u.alias?u.alias.value:u.name.value,y=D(f,d),v=s+"."+y,m=oe(s,y),h=r?r[f]:void 0,g=o.resolvers[t],k=void 0;if(void 0!==h&&void 0===u.selectionSet)k=h;else if(g&&"function"==typeof g[f]){y=s,h=v;var x=f;if((k=e).parentTypeName=t,k.parentKey=y,k.parentFieldKey=h,k.fieldName=x,void 0!==m&&(i[p]=m),k=g[f](i,d||N(),o,e),void 0!==u.selectionSet&&(k=Ee(e,t,f,v,q(u),i[p]||N(),k)),o.schema&&null===k&&!P(o.schema,t,f))return}else void 0===u.selectionSet?k=m:void 0!==h?k=Ee(e,t,f,v,q(u),i[p],h):void 0!==(d=ae(s,y))?k=Fe(e,d,t,f,q(u),i[p]):"object"==typeof m&&null!==m&&(k=m);if(void 0===k&&o.schema&&P(o.schema,t,f))l=!0,i[p]=null;else{if(void 0===k)return;c=!0,i[p]=k}}return l&&(e.partial=!0),a&&l&&!c?void 0:i}}function Ee(e,t,n,i,r,o,a){if(Array.isArray(a)){var s=e.store;s=!s.schema||I(s.schema,t,n);for(var u=Array(a.length),c=0,l=a.length;c<l;c++){var f=Ee(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}return null==a?a:"string"==typeof a||"object"==typeof a&&"string"==typeof a.__typename?(t=void 0===o?N():o,"string"==typeof a?Ke(e,a,r,t):Ke(e,i,r,t,a)):void 0}function Fe(e,t,n,i,r,o){if(Array.isArray(t)){var a=e.store;a=a.schema&&I(a.schema,n,i);for(var s=Array(t.length),u=0,c=t.length;u<c;u++){var l=Fe(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:Ke(e,t,r,void 0===o?N():o)}function Te(e,t){return S({},e,{context:S({},e.context,{meta:S({},e.context.meta,{cacheOutcome:t})})})}function Ae(e,t){return S({},e,{context:S({},e.context,{requestPolicy:t})})}function Be(e){return S({},e,{query:y(e.query)})}function Me(e){return"query"===e.operationName&&"network-only"!==e.context.requestPolicy}function Le(e){return Te(e.operation,"miss")}function Pe(e){return"miss"===e.outcome}function Ie(e){return"miss"!==e.outcome}function Ce(e){return"cache-only"!==e.context.requestPolicy}function De(e){return!("query"===e.operationName&&"network-only"!==e.context.requestPolicy)}function Re(d){return function(p){function y(e){var t=e.operation,n=e.error,i=e.extensions,r=t.key,o=new Set;if("mutation"===t.operationName?(x(o,w.get(r)),w.delete(r)):"subscription"===t.operationName&&ce(q.data,t.key),e.data){if(x(o,r=ge(q,t,e.data,r).dependencies),r=Se(q,t,e.data),e.data=r.data,"query"===t.operationName){var a=r.dependencies;x(o,a)}}else H(q.data,t.key);return k(e.operation,o),a&&m(e.operation,a),{data:e.data,error:n,extensions:i,operation:t}}function v(e){var t=Se(q,e),n=t.data?t.partial&&"cache-only"!==e.context.requestPolicy?"partial":"hit":"miss";return t.data&&m(e,t.dependencies),{outcome:n,operation:e,data:t.data}}function m(e,t){t.forEach((function(t){(E[t]||(E[t]=[])).push(e.key),K.has(e.key)||K.set(e.key,"network-only"===e.context.requestPolicy?Ae(e,"cache-and-network"):e)}))}function h(e){var t=e.key;if("mutation"===e.operationName&&"network-only"!==e.context.requestPolicy){var n=xe(q,e,t).dependencies;0!==n.size&&(w.set(t,n),x(t=new Set,n),k(e,t))}else H(q.data,t,!0)}function g(e){"query"===e.operationName?ce(q.data,e.key):"teardown"===e.operationName&&H(q.data,e.key)}function k(e,t){t.forEach((function(t){if(t!==e.key){var n=K.get(t);n&&(K.delete(t),b.reexecuteOperation(Ae(n,"cache-first")))}}))}function x(e,t){t&&t.forEach((function(t){var n=E[t];if(n){E[t]=[],t=0;for(var i=n.length;t<i;t++)e.add(n[t])}}))}function O(e){var t=e.operation,n=e.outcome;return e={operation:Te(t,n),data:e.data,error:e.error,extensions:e.extensions},("cache-and-network"===t.context.requestPolicy||"cache-first"===t.context.requestPolicy&&"partial"===n)&&(e.stale=!0,b.reexecuteOperation(Ae(t,"network-only"))),e}var _=p.forward,b=p.client;d||(d={});var S,q=new be(d.schema,d.resolvers,d.updates,d.optimistic,d.keys);d.storage&&(S=d.storage.read().then((function(e){var t=q.data,n=d.storage;for(var i in V(t,null),e){var r=i.indexOf("."),o=i.slice(2,r);switch(r=i.slice(r+1),i.charCodeAt(0)){case 108:ue(o,r,e[i]);break;case 114:se(o,r,e[i])}}J(),t.storage=n})));var w=new Map,K=new Map,E=N();return function(d){d=e(d);var p=S?t(n)(i(1)(r(o(S))(d))):a;d=e(s(h)(u(Be)(c([p,d]))));var m=e(u(v)(l(Me)(d)));return p=u(Le)(l(Pe)(m)),m=u(O)(l(Ie)(m)),d=u(y)(_(s(g)(l(Ce)(f([l(De)(d),p]))))),f([d,m])}}}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:{var n=this.context.variables,i=(e=t[e]).directives;if(i)for(var r=0,o=i.length;r<o;r++){var a=i[r];if(("include"===(t=a.name.value)||"skip"===t)&&a.arguments&&a.arguments[0]&&"if"===a.arguments[0].name.value){n=m(a.arguments[0].value,n),t="include"===t?!!n:!n;break e}}t=!0}if(t)if(e.kind!==v.FIELD)void 0!==(e=e.kind!==v.INLINE_FRAGMENT?this.context.fragments[e.name.value]:e)&&(this.context.store.schema?(t=this.context.store.schema,i=w(e),(n=this.typename)&&i?n===i?t=!0:(i=t.getType(i),n=t.getType(n),i instanceof x?t=i===n:(F(i instanceof O||i instanceof _,"",5),F(n instanceof x,"",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(q(e))));else if("__typename"!==e.name.value)return e}}},be.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},be.prototype.resolveFieldByKey=function(e,t){if(null===(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e))return null;var n=oe(e,t);return void 0!==n?n:(t=ae(e,t))?t:null},be.prototype.resolve=function(e,t,n){return this.resolveFieldByKey(e,D(t,n))},be.prototype.invalidateQuery=function(e,t){!function(e,t){var n=X();qe(e,t),n.forEach((function(t){t.startsWith(e.data.queryRootKey+".")?(t=t.slice((e.data.queryRootKey+".").length),ue(e.data.queryRootKey,t),se(e.data.queryRootKey,t)):e.invalidate(t)})),W=G,G=null,ie(e.data)}(this,p(e,t))},be.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 i=n[t];ae(e,i.fieldKey)?ue(e,i.fieldKey,void 0):se(e,i.fieldKey,void 0)}},be.prototype.inspectFields=function(e){if(null!==(e=null!==e&&"string"!=typeof e?this.keyOfEntity(e):e)){var t=Q.links,n=Q.records,i=[],r=new Set;re(e),ne(i,r,e,t),ne(i,r,e,n),e=i}else e=[];return e},be.prototype.updateQuery=function(e,t){e=p(e.query,e.variables),null!==(t=t(this.readQuery(e)))&&ke(this,e,t)},be.prototype.readQuery=function(e){return qe(this,p(e.query,e.variables)).data},be.prototype.readFragment=function(e,t,n){e=L(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(S({},{__typename:r},t)):t)&&Ke(n=ve(this,n||{},e,r,t),t,q(i),N())||null}return n},be.prototype.writeFragment=function(e,t,n){e=L(e);var i=Object.keys(e);if(void 0!==(i=e[i[0]])){var r=i.typeCondition.name.value;t=S({},{__typename:r},t);var o=this.keyOfEntity(t);o&&Oe(n=ve(this,n||{},e,r,o),o,q(i),t)}};export{be as Store,Re as cacheExchange,H as noopDataState,Se as query,ce as reserveLayer,ge as write,xe as writeOptimistic}; | ||
//# sourceMappingURL=urql-exchange-graphcache.esm.min.js.map |
{ | ||
"name": "@urql/exchange-graphcache", | ||
"version": "2.2.4", | ||
"version": "2.2.5", | ||
"description": "A normalized and configurable cache exchange for urql", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56
601270
2621