@urql/core
Advanced tools
Comparing version 2.1.4 to 2.1.5
# @urql/core | ||
## 2.1.5 | ||
### Patch Changes | ||
- Prevent `ssrExchange().restoreData()` from adding results to the exchange that have already been invalidated. This may happen when `restoreData()` is called repeatedly, e.g. per page. When a prior run has already invalidated an SSR result then the result is 'migrated' to the user's `cacheExchange`, which means that `restoreData()` should never attempt to re-add it again, by [@kitten](https://github.com/kitten) (See [#1776](https://github.com/FormidableLabs/urql/pull/1776)) | ||
- ⚠️ Fix accidental change in passive `stale: true`, where a `cache-first` operation issued by Graphcache wouldn't yield an affected query and update its result to reflect the loading state with `stale: true`. This is a regression from `v2.1.0` and mostly becomes unexpected when `cache.invalidate(...)` is used, by [@kitten](https://github.com/kitten) (See [#1755](https://github.com/FormidableLabs/urql/pull/1755)) | ||
## 2.1.4 | ||
@@ -4,0 +11,0 @@ |
var e = require("graphql"); | ||
var t = require("./b4631212.js"); | ||
var r = require("./b4631212.js"); | ||
var r = require("wonka"); | ||
var t = require("wonka"); | ||
function collectTypes(e, t) { | ||
function collectTypes(e, r) { | ||
if (Array.isArray(e)) { | ||
for (var r = 0; r < e.length; r++) { | ||
collectTypes(e[r], t); | ||
for (var t = 0; t < e.length; t++) { | ||
collectTypes(e[t], r); | ||
} | ||
@@ -15,9 +15,9 @@ } else if ("object" == typeof e && null !== e) { | ||
if ("__typename" === n && "string" == typeof e[n]) { | ||
t[e[n]] = 0; | ||
r[e[n]] = 0; | ||
} else { | ||
collectTypes(e[n], t); | ||
collectTypes(e[n], r); | ||
} | ||
} | ||
} | ||
return t; | ||
return r; | ||
} | ||
@@ -29,9 +29,9 @@ | ||
var formatNode = function(r) { | ||
if (r.selectionSet && !r.selectionSet.selections.some((function(t) { | ||
return t.kind === e.Kind.FIELD && "__typename" === t.name.value && !t.alias; | ||
var formatNode = function(t) { | ||
if (t.selectionSet && !t.selectionSet.selections.some((function(r) { | ||
return r.kind === e.Kind.FIELD && "__typename" === r.name.value && !r.alias; | ||
}))) { | ||
return t._extends({}, r, { | ||
selectionSet: t._extends({}, r.selectionSet, { | ||
selections: r.selectionSet.selections.concat([ { | ||
return r._extends({}, t, { | ||
selectionSet: r._extends({}, t.selectionSet, { | ||
selections: t.selectionSet.selections.concat([ { | ||
kind: e.Kind.FIELD, | ||
@@ -50,4 +50,4 @@ name: { | ||
function formatDocument(r) { | ||
var a = t.keyDocument(r); | ||
function formatDocument(t) { | ||
var a = r.keyDocument(t); | ||
var o = n.get(a.__key); | ||
@@ -68,6 +68,6 @@ if (!o) { | ||
} | ||
return Object.keys(e).reduce((function(t, r) { | ||
var n = e[r]; | ||
if ("__typename" === r) { | ||
Object.defineProperty(t, "__typename", { | ||
return Object.keys(e).reduce((function(r, t) { | ||
var n = e[t]; | ||
if ("__typename" === t) { | ||
Object.defineProperty(r, "__typename", { | ||
enumerable: !1, | ||
@@ -77,9 +77,9 @@ value: n | ||
} else if (Array.isArray(n)) { | ||
t[r] = n.map(maskTypename); | ||
r[t] = n.map(maskTypename); | ||
} else if (n && "object" == typeof n && "__typename" in n) { | ||
t[r] = maskTypename(n); | ||
r[t] = maskTypename(n); | ||
} else { | ||
t[r] = n; | ||
r[t] = n; | ||
} | ||
return t; | ||
return r; | ||
}), {}); | ||
@@ -90,3 +90,3 @@ } | ||
e.toPromise = function() { | ||
return r.toPromise(r.take(1)(r.filter((function(e) { | ||
return t.toPromise(t.take(1)(t.filter((function(e) { | ||
return !e.stale; | ||
@@ -98,18 +98,18 @@ }))(e))); | ||
function makeOperation(e, t, r) { | ||
if (!r) { | ||
r = t.context; | ||
function makeOperation(e, r, t) { | ||
if (!t) { | ||
t = r.context; | ||
} | ||
return { | ||
key: t.key, | ||
query: t.query, | ||
variables: t.variables, | ||
key: r.key, | ||
query: r.query, | ||
variables: r.variables, | ||
kind: e, | ||
context: r | ||
context: t | ||
}; | ||
} | ||
function addMetadata(e, r) { | ||
return makeOperation(e.kind, e, t._extends({}, e.context, { | ||
meta: t._extends({}, e.context.meta, r) | ||
function addMetadata(e, t) { | ||
return makeOperation(e.kind, e, r._extends({}, e.context, { | ||
meta: r._extends({}, e.context.meta, t) | ||
})); | ||
@@ -120,11 +120,11 @@ } | ||
function applyDefinitions(r, n, a) { | ||
function applyDefinitions(t, n, a) { | ||
for (var o = 0; o < a.length; o++) { | ||
if (a[o].kind === e.Kind.FRAGMENT_DEFINITION) { | ||
var i = a[o].name.value; | ||
var u = t.stringifyDocument(a[o]); | ||
if (!r.has(i)) { | ||
r.set(i, u); | ||
var u = r.stringifyDocument(a[o]); | ||
if (!t.has(i)) { | ||
t.set(i, u); | ||
n.push(a[o]); | ||
} else if ("production" !== process.env.NODE_ENV && r.get(i) !== u) { | ||
} else if ("production" !== process.env.NODE_ENV && t.get(i) !== u) { | ||
console.warn("[WARNING: Duplicate Fragment] A fragment with name `" + i + "` already exists in this document.\nWhile fragment names may not be unique across your source, each name must be unique per document."); | ||
@@ -139,9 +139,9 @@ } | ||
function shouldSkip$1(e) { | ||
var t = e.kind; | ||
return "subscription" !== t && "query" !== t; | ||
var r = e.kind; | ||
return "subscription" !== r && "query" !== r; | ||
} | ||
function shouldSkip(e) { | ||
var t = e.kind; | ||
return "mutation" !== t && "query" !== t; | ||
var r = e.kind; | ||
return "mutation" !== r && "query" !== r; | ||
} | ||
@@ -156,17 +156,17 @@ | ||
function mapTypeNames(e) { | ||
var t = makeOperation(e.kind, e); | ||
t.query = formatDocument(e.query); | ||
return t; | ||
var r = makeOperation(e.kind, e); | ||
r.query = formatDocument(e.query); | ||
return r; | ||
} | ||
function isOperationCached(e) { | ||
var t = e.context.requestPolicy; | ||
return "query" === e.kind && "network-only" !== t && ("cache-only" === t || i.has(e.key)); | ||
var r = e.context.requestPolicy; | ||
return "query" === e.kind && "network-only" !== r && ("cache-only" === r || i.has(e.key)); | ||
} | ||
return function(e) { | ||
var c = r.share(e); | ||
var s = r.map((function(e) { | ||
var r = i.get(e.key); | ||
"production" !== process.env.NODE_ENV && o(t._extends({}, { | ||
var c = t.share(e); | ||
var s = t.map((function(e) { | ||
var t = i.get(e.key); | ||
"production" !== process.env.NODE_ENV && o(r._extends({}, { | ||
operation: e | ||
}, r ? { | ||
}, t ? { | ||
type: "cacheHit", | ||
@@ -178,5 +178,5 @@ message: "The result was successfully retried from the cache" | ||
})); | ||
var n = t._extends({}, r, { | ||
var n = r._extends({}, t, { | ||
operation: addMetadata(e, { | ||
cacheOutcome: r ? "hit" : "miss" | ||
cacheOutcome: t ? "hit" : "miss" | ||
}) | ||
@@ -189,11 +189,11 @@ }); | ||
return n; | ||
}))(r.filter((function(e) { | ||
}))(t.filter((function(e) { | ||
return !shouldSkip(e) && isOperationCached(e); | ||
}))(c)); | ||
var p = r.tap((function(e) { | ||
var t = e.operation; | ||
if (!t) { | ||
var p = t.tap((function(e) { | ||
var r = e.operation; | ||
if (!r) { | ||
return; | ||
} | ||
var r = collectTypesFromResponse(e.data).concat(t.context.additionalTypenames || []); | ||
var t = collectTypesFromResponse(e.data).concat(r.context.additionalTypenames || []); | ||
if ("mutation" === e.operation.kind) { | ||
@@ -203,6 +203,6 @@ var n = new Set; | ||
type: "cacheInvalidation", | ||
message: "The following typenames have been invalidated: " + r, | ||
operation: t, | ||
message: "The following typenames have been invalidated: " + t, | ||
operation: r, | ||
data: { | ||
typenames: r, | ||
typenames: t, | ||
response: e | ||
@@ -212,4 +212,4 @@ }, | ||
}); | ||
for (var c = 0; c < r.length; c++) { | ||
var s = r[c]; | ||
for (var c = 0; c < t.length; c++) { | ||
var s = t[c]; | ||
var p = u[s] || (u[s] = new Set); | ||
@@ -223,31 +223,31 @@ p.forEach((function(e) { | ||
if (i.has(e)) { | ||
t = i.get(e).operation; | ||
r = i.get(e).operation; | ||
i.delete(e); | ||
reexecuteOperation(a, t); | ||
reexecuteOperation(a, r); | ||
} | ||
})); | ||
} else if ("query" === t.kind && e.data) { | ||
i.set(t.key, e); | ||
for (var f = 0; f < r.length; f++) { | ||
var l = r[f]; | ||
(u[l] || (u[l] = new Set)).add(t.key); | ||
} else if ("query" === r.kind && e.data) { | ||
i.set(r.key, e); | ||
for (var f = 0; f < t.length; f++) { | ||
var l = t[f]; | ||
(u[l] || (u[l] = new Set)).add(r.key); | ||
} | ||
} | ||
}))(n(r.filter((function(e) { | ||
}))(n(t.filter((function(e) { | ||
return "query" !== e.kind || "cache-only" !== e.context.requestPolicy; | ||
}))(r.map((function(e) { | ||
}))(t.map((function(e) { | ||
return addMetadata(e, { | ||
cacheOutcome: "miss" | ||
}); | ||
}))(r.merge([ r.map(mapTypeNames)(r.filter((function(e) { | ||
}))(t.merge([ t.map(mapTypeNames)(t.filter((function(e) { | ||
return !shouldSkip(e) && !isOperationCached(e); | ||
}))(c)), r.filter((function(e) { | ||
}))(c)), t.filter((function(e) { | ||
return shouldSkip(e); | ||
}))(c) ]))))); | ||
return r.merge([ s, p ]); | ||
return t.merge([ s, p ]); | ||
}; | ||
} | ||
function reexecuteOperation(e, r) { | ||
return e.reexecuteOperation(makeOperation(r.kind, r, t._extends({}, r.context, { | ||
function reexecuteOperation(e, t) { | ||
return e.reexecuteOperation(makeOperation(t.kind, t, r._extends({}, t.context, { | ||
requestPolicy: "network-only" | ||
@@ -258,17 +258,17 @@ }))); | ||
function dedupExchange(e) { | ||
var t = e.forward; | ||
var r = e.forward; | ||
var n = e.dispatchDebug; | ||
var a = new Set; | ||
function filterIncomingOperation(e) { | ||
var t = e.key; | ||
var r = e.kind; | ||
if ("teardown" === r) { | ||
a.delete(t); | ||
var r = e.key; | ||
var t = e.kind; | ||
if ("teardown" === t) { | ||
a.delete(r); | ||
return !0; | ||
} | ||
if ("query" !== r && "subscription" !== r) { | ||
if ("query" !== t && "subscription" !== t) { | ||
return !0; | ||
} | ||
var o = a.has(t); | ||
a.add(t); | ||
var o = a.has(r); | ||
a.add(r); | ||
if (o) { | ||
@@ -288,4 +288,4 @@ "production" !== process.env.NODE_ENV && n({ | ||
return function(e) { | ||
var n = r.filter(filterIncomingOperation)(e); | ||
return r.tap(afterOperationResult)(t(n)); | ||
var n = t.filter(filterIncomingOperation)(e); | ||
return t.tap(afterOperationResult)(r(n)); | ||
}; | ||
@@ -298,11 +298,11 @@ } | ||
return function(e) { | ||
var o = r.share(e); | ||
var i = r.mergeMap((function(e) { | ||
var o = t.share(e); | ||
var i = t.mergeMap((function(e) { | ||
var n = e.key; | ||
var i = r.filter((function(e) { | ||
var i = t.filter((function(e) { | ||
return "teardown" === e.kind && e.key === n; | ||
}))(o); | ||
var u = t.makeFetchBody(e); | ||
var c = t.makeFetchURL(e, u); | ||
var s = t.makeFetchOptions(e, u); | ||
var u = r.makeFetchBody(e); | ||
var c = r.makeFetchURL(e, u); | ||
var s = r.makeFetchOptions(e, u); | ||
"production" !== process.env.NODE_ENV && a({ | ||
@@ -318,7 +318,7 @@ type: "fetchRequest", | ||
}); | ||
return r.onPush((function(t) { | ||
var r = !t.data ? t.error : void 0; | ||
return t.onPush((function(r) { | ||
var t = !r.data ? r.error : void 0; | ||
"production" !== process.env.NODE_ENV && a({ | ||
type: r ? "fetchError" : "fetchSuccess", | ||
message: "A " + (r ? "failed" : "successful") + " fetch response has been returned.", | ||
type: t ? "fetchError" : "fetchSuccess", | ||
message: "A " + (t ? "failed" : "successful") + " fetch response has been returned.", | ||
operation: e, | ||
@@ -328,14 +328,14 @@ data: { | ||
fetchOptions: s, | ||
value: r || t | ||
value: t || r | ||
}, | ||
source: "fetchExchange" | ||
}); | ||
}))(r.takeUntil(i)(t.makeFetchSource(e, c, s))); | ||
}))(r.filter((function(e) { | ||
}))(t.takeUntil(i)(r.makeFetchSource(e, c, s))); | ||
}))(t.filter((function(e) { | ||
return "query" === e.kind || "mutation" === e.kind; | ||
}))(o)); | ||
var u = n(r.filter((function(e) { | ||
var u = n(t.filter((function(e) { | ||
return "query" !== e.kind && "mutation" !== e.kind; | ||
}))(o)); | ||
return r.merge([ i, u ]); | ||
return t.merge([ i, u ]); | ||
}; | ||
@@ -345,16 +345,16 @@ } | ||
function fallbackExchange(e) { | ||
var t = e.dispatchDebug; | ||
var r = e.dispatchDebug; | ||
return function(e) { | ||
return r.filter((function() { | ||
return t.filter((function() { | ||
return !1; | ||
}))(r.tap((function(e) { | ||
}))(t.tap((function(e) { | ||
if ("teardown" !== e.kind && "production" !== process.env.NODE_ENV) { | ||
var r = 'No exchange has handled operations of kind "' + e.kind + "\". Check whether you've added an exchange responsible for these operations."; | ||
"production" !== process.env.NODE_ENV && t({ | ||
var t = 'No exchange has handled operations of kind "' + e.kind + "\". Check whether you've added an exchange responsible for these operations."; | ||
"production" !== process.env.NODE_ENV && r({ | ||
type: "fallbackCatch", | ||
message: r, | ||
message: t, | ||
operation: e, | ||
source: "fallbackExchange" | ||
}); | ||
console.warn(r); | ||
console.warn(t); | ||
} | ||
@@ -370,17 +370,17 @@ }))(e)); | ||
function composeExchanges(e) { | ||
return function(r) { | ||
var n = r.client; | ||
var a = r.dispatchDebug; | ||
return e.reduceRight((function(e, r) { | ||
return r({ | ||
return function(t) { | ||
var n = t.client; | ||
var a = t.dispatchDebug; | ||
return e.reduceRight((function(e, t) { | ||
return t({ | ||
client: n, | ||
forward: e, | ||
dispatchDebug: function dispatchDebug$1(e) { | ||
"production" !== process.env.NODE_ENV && a(t._extends({}, { | ||
"production" !== process.env.NODE_ENV && a(r._extends({}, { | ||
timestamp: Date.now(), | ||
source: r.name | ||
source: t.name | ||
}, e)); | ||
} | ||
}); | ||
}), r.forward); | ||
}), t.forward); | ||
}; | ||
@@ -398,3 +398,3 @@ } | ||
var i = []; | ||
var u = r.makeSubject(); | ||
var u = t.makeSubject(); | ||
var c = u.source; | ||
@@ -414,8 +414,8 @@ var s = u.next; | ||
function makeResultSource(e) { | ||
var o = r.filter((function(t) { | ||
return t.operation.kind === e.kind && t.operation.key === e.key; | ||
}))(y); | ||
var o = t.filter((function(r) { | ||
return r.operation.kind === e.kind && r.operation.key === e.key; | ||
}))(k); | ||
if (l.maskTypename) { | ||
o = r.map((function(e) { | ||
return t._extends({}, e, { | ||
o = t.map((function(e) { | ||
return r._extends({}, e, { | ||
data: maskTypename(e.data) | ||
@@ -426,32 +426,32 @@ }); | ||
if ("mutation" === e.kind) { | ||
return r.take(1)(r.onStart((function() { | ||
return t.take(1)(t.onStart((function() { | ||
return dispatchOperation(e); | ||
}))(o)); | ||
} | ||
var u = r.share(r.onEnd((function() { | ||
var u = t.share(t.onEnd((function() { | ||
n.delete(e.key); | ||
a.delete(e.key); | ||
for (var t = i.length - 1; t >= 0; t--) { | ||
if (i[t].key === e.key) { | ||
i.splice(t, 1); | ||
for (var r = i.length - 1; r >= 0; r--) { | ||
if (i[r].key === e.key) { | ||
i.splice(r, 1); | ||
} | ||
} | ||
dispatchOperation(makeOperation("teardown", e, e.context)); | ||
}))(r.onStart((function() { | ||
}))(t.onStart((function() { | ||
a.set(e.key, u); | ||
}))(r.onPush((function(t) { | ||
n.set(e.key, t); | ||
}))(r.switchMap((function(n) { | ||
if (n.stale) { | ||
return r.fromValue(n); | ||
}))(t.onPush((function(r) { | ||
n.set(e.key, r); | ||
}))(t.switchMap((function(n) { | ||
if ("query" !== e.kind || n.stale) { | ||
return t.fromValue(n); | ||
} | ||
return r.merge([ r.fromValue(n), r.map((function() { | ||
return t._extends({}, n, { | ||
return t.merge([ t.fromValue(n), t.map((function() { | ||
return r._extends({}, n, { | ||
stale: !0 | ||
}); | ||
}))(r.take(1)(r.filter((function(t) { | ||
return t.kind === e.kind && t.key === e.key && ("network-only" === t.context.requestPolicy || "cache-and-network" === t.context.requestPolicy); | ||
}))(t.take(1)(t.filter((function(r) { | ||
return "query" === r.kind && r.key === e.key && "cache-only" !== r.context.requestPolicy; | ||
}))(c))) ]); | ||
}))(r.takeUntil(r.filter((function(t) { | ||
return "teardown" === t.kind && t.key === e.key; | ||
}))(t.takeUntil(t.filter((function(r) { | ||
return "teardown" === r.kind && r.key === e.key; | ||
}))(c))(o)))))); | ||
@@ -461,3 +461,3 @@ return u; | ||
var f = this instanceof Client ? this : Object.create(Client.prototype); | ||
var l = t._extends(f, { | ||
var l = r._extends(f, { | ||
url: e.url, | ||
@@ -483,3 +483,3 @@ fetchOptions: e.fetchOptions, | ||
} | ||
return t._extends({}, { | ||
return r._extends({}, { | ||
url: l.url, | ||
@@ -494,4 +494,4 @@ fetchOptions: l.fetchOptions, | ||
}, | ||
createRequestOperation: function createRequestOperation(e, t, r) { | ||
return makeOperation(e, t, l.createOperationContext(r)); | ||
createRequestOperation: function createRequestOperation(e, r, t) { | ||
return makeOperation(e, r, l.createOperationContext(t)); | ||
}, | ||
@@ -504,5 +504,5 @@ executeRequestOperation: function executeRequestOperation(e) { | ||
var i = "cache-and-network" === e.context.requestPolicy || "network-only" === e.context.requestPolicy; | ||
return r.make((function(a) { | ||
return r.subscribe(a.next)(r.onEnd(a.complete)(r.onStart((function() { | ||
var r = n.get(e.key); | ||
return t.make((function(a) { | ||
return t.subscribe(a.next)(t.onEnd(a.complete)(t.onStart((function() { | ||
var t = n.get(e.key); | ||
if ("subscription" === e.kind) { | ||
@@ -513,6 +513,6 @@ return dispatchOperation(e); | ||
} | ||
if (null != r && r === n.get(e.key)) { | ||
a.next(i ? t._extends({}, r, { | ||
if (null != t && t === n.get(e.key)) { | ||
a.next(i ? r._extends({}, t, { | ||
stale: !0 | ||
}) : r); | ||
}) : t); | ||
} else if (!i) { | ||
@@ -524,34 +524,34 @@ dispatchOperation(e); | ||
}, | ||
executeQuery: function executeQuery(e, t) { | ||
var r = l.createRequestOperation("query", e, t); | ||
return l.executeRequestOperation(r); | ||
executeQuery: function executeQuery(e, r) { | ||
var t = l.createRequestOperation("query", e, r); | ||
return l.executeRequestOperation(t); | ||
}, | ||
executeSubscription: function executeSubscription(e, t) { | ||
var r = l.createRequestOperation("subscription", e, t); | ||
return l.executeRequestOperation(r); | ||
executeSubscription: function executeSubscription(e, r) { | ||
var t = l.createRequestOperation("subscription", e, r); | ||
return l.executeRequestOperation(t); | ||
}, | ||
executeMutation: function executeMutation(e, t) { | ||
var r = l.createRequestOperation("mutation", e, t); | ||
return l.executeRequestOperation(r); | ||
executeMutation: function executeMutation(e, r) { | ||
var t = l.createRequestOperation("mutation", e, r); | ||
return l.executeRequestOperation(t); | ||
}, | ||
query: function query(e, r, n) { | ||
query: function query(e, t, n) { | ||
if (!n || "boolean" != typeof n.suspense) { | ||
n = t._extends({}, n, { | ||
n = r._extends({}, n, { | ||
suspense: !1 | ||
}); | ||
} | ||
return withPromise(l.executeQuery(t.createRequest(e, r), n)); | ||
return withPromise(l.executeQuery(r.createRequest(e, t), n)); | ||
}, | ||
readQuery: function readQuery(e, t, n) { | ||
readQuery: function readQuery(e, r, n) { | ||
var a = null; | ||
r.subscribe((function(e) { | ||
t.subscribe((function(e) { | ||
a = e; | ||
}))(l.query(e, t, n)).unsubscribe(); | ||
}))(l.query(e, r, n)).unsubscribe(); | ||
return a; | ||
}, | ||
subscription: function subscription(e, r, n) { | ||
return l.executeSubscription(t.createRequest(e, r), n); | ||
subscription: function subscription(e, t, n) { | ||
return l.executeSubscription(r.createRequest(e, t), n); | ||
}, | ||
mutation: function mutation(e, r, n) { | ||
return withPromise(l.executeMutation(t.createRequest(e, r), n)); | ||
mutation: function mutation(e, t, n) { | ||
return withPromise(l.executeMutation(r.createRequest(e, t), n)); | ||
} | ||
@@ -561,12 +561,12 @@ }); | ||
if ("production" !== process.env.NODE_ENV) { | ||
var h = r.makeSubject(); | ||
var h = t.makeSubject(); | ||
var v = h.next; | ||
var m = h.source; | ||
l.subscribeToDebugTarget = function(e) { | ||
return r.subscribe(e)(m); | ||
return t.subscribe(e)(m); | ||
}; | ||
d = v; | ||
} | ||
var k = composeExchanges(void 0 !== e.exchanges ? e.exchanges : o); | ||
var y = r.share(k({ | ||
var y = composeExchanges(void 0 !== e.exchanges ? e.exchanges : o); | ||
var k = t.share(y({ | ||
client: l, | ||
@@ -578,3 +578,3 @@ dispatchDebug: d, | ||
})(c)); | ||
r.publish(y); | ||
t.publish(k); | ||
return l; | ||
@@ -585,13 +585,13 @@ }; | ||
exports.CombinedError = t.CombinedError; | ||
exports.CombinedError = r.CombinedError; | ||
exports.createRequest = t.createRequest; | ||
exports.createRequest = r.createRequest; | ||
exports.getOperationName = t.getOperationName; | ||
exports.getOperationName = r.getOperationName; | ||
exports.makeErrorResult = t.makeErrorResult; | ||
exports.makeErrorResult = r.makeErrorResult; | ||
exports.makeResult = t.makeResult; | ||
exports.makeResult = r.makeResult; | ||
exports.stringifyVariables = t.stringifyVariables; | ||
exports.stringifyVariables = r.stringifyVariables; | ||
@@ -607,12 +607,12 @@ exports.Client = i; | ||
exports.debugExchange = function debugExchange(e) { | ||
var t = e.forward; | ||
var r = e.forward; | ||
if ("production" === process.env.NODE_ENV) { | ||
return function(e) { | ||
return t(e); | ||
return r(e); | ||
}; | ||
} else { | ||
return function(e) { | ||
return r.tap((function(e) { | ||
return t.tap((function(e) { | ||
return console.log("[Exchange debug]: Completed operation: ", e); | ||
}))(t(r.tap((function(e) { | ||
}))(r(t.tap((function(e) { | ||
return console.log("[Exchange debug]: Incoming operation: ", e); | ||
@@ -629,10 +629,10 @@ }))(e))); | ||
exports.errorExchange = function errorExchange(e) { | ||
var t = e.onError; | ||
var r = e.onError; | ||
return function(e) { | ||
var n = e.forward; | ||
return function(e) { | ||
return r.tap((function(e) { | ||
var r = e.error; | ||
if (r) { | ||
t(r, e.operation); | ||
return t.tap((function(e) { | ||
var t = e.error; | ||
if (t) { | ||
r(t, e.operation); | ||
} | ||
@@ -651,3 +651,3 @@ }))(n(e)); | ||
exports.gql = function gql() { | ||
var r = arguments; | ||
var t = arguments; | ||
var n = new Map; | ||
@@ -658,3 +658,3 @@ var a = []; | ||
for (var u = 1; u < arguments.length; u++) { | ||
var c = r[u]; | ||
var c = t[u]; | ||
if (c && c.definitions) { | ||
@@ -665,7 +665,7 @@ o.push.apply(o, c.definitions); | ||
} | ||
i += r[0][u]; | ||
i += t[0][u]; | ||
} | ||
applyDefinitions(n, a, t.keyDocument(i).definitions); | ||
applyDefinitions(n, a, r.keyDocument(i).definitions); | ||
applyDefinitions(n, a, o); | ||
return t.keyDocument({ | ||
return r.keyDocument({ | ||
kind: e.Kind.DOCUMENT, | ||
@@ -689,3 +689,3 @@ definitions: a | ||
while (e = a.shift()) { | ||
delete n[e]; | ||
n[e] = null; | ||
} | ||
@@ -696,3 +696,3 @@ })); | ||
function isCached(e) { | ||
return !shouldSkip$1(e) && void 0 !== n[e.key]; | ||
return !shouldSkip$1(e) && null != n[e.key]; | ||
} | ||
@@ -704,10 +704,10 @@ var ssr = function(a) { | ||
var u = e && "boolean" == typeof e.isClient ? !!e.isClient : !o.suspense; | ||
var c = r.share(a); | ||
var s = i(r.filter((function(e) { | ||
var c = t.share(a); | ||
var s = i(t.filter((function(e) { | ||
return !isCached(e); | ||
}))(c)); | ||
var p = r.map((function(e) { | ||
return function deserializeResult(e, r) { | ||
var n = r.error; | ||
var a = r.data; | ||
var p = t.map((function(e) { | ||
return function deserializeResult(e, t) { | ||
var n = t.error; | ||
var a = t.data; | ||
return { | ||
@@ -717,3 +717,3 @@ operation: e, | ||
extensions: void 0, | ||
error: n ? new t.CombinedError({ | ||
error: n ? new r.CombinedError({ | ||
networkError: n.networkError ? new Error(n.networkError) : void 0, | ||
@@ -724,19 +724,19 @@ graphQLErrors: n.graphQLErrors && n.graphQLErrors.length ? n.graphQLErrors : void 0 | ||
}(e, n[e.key]); | ||
}))(r.filter((function(e) { | ||
}))(t.filter((function(e) { | ||
return isCached(e); | ||
}))(c)); | ||
if (!u) { | ||
s = r.tap((function(e) { | ||
var t = e.operation; | ||
if (!shouldSkip$1(t)) { | ||
var r = function serializeResult(e) { | ||
var t = e.data; | ||
var r = e.error; | ||
s = t.tap((function(e) { | ||
var r = e.operation; | ||
if (!shouldSkip$1(r)) { | ||
var t = function serializeResult(e) { | ||
var r = e.data; | ||
var t = e.error; | ||
var n = {}; | ||
if (void 0 !== t) { | ||
n.data = JSON.stringify(t); | ||
if (void 0 !== r) { | ||
n.data = JSON.stringify(r); | ||
} | ||
if (r) { | ||
if (t) { | ||
n.error = { | ||
graphQLErrors: r.graphQLErrors.map((function(e) { | ||
graphQLErrors: t.graphQLErrors.map((function(e) { | ||
if (!e.path && !e.extensions) { | ||
@@ -752,4 +752,4 @@ return e.message; | ||
}; | ||
if (r.networkError) { | ||
n.error.networkError = "" + r.networkError; | ||
if (t.networkError) { | ||
n.error.networkError = "" + t.networkError; | ||
} | ||
@@ -759,16 +759,26 @@ } | ||
}(e); | ||
n[t.key] = r; | ||
n[r.key] = t; | ||
} | ||
}))(s); | ||
} else { | ||
p = r.tap(invalidate)(p); | ||
p = t.tap(invalidate)(p); | ||
} | ||
return r.merge([ s, p ]); | ||
return t.merge([ s, p ]); | ||
}; | ||
}; | ||
ssr.restoreData = function(e) { | ||
return t._extends(n, e); | ||
for (var r in e) { | ||
if (null !== n[r]) { | ||
n[r] = e[r]; | ||
} | ||
} | ||
}; | ||
ssr.extractData = function() { | ||
return t._extends({}, n); | ||
var e = {}; | ||
for (var r in n) { | ||
if (null != n[r]) { | ||
e[r] = n[r]; | ||
} | ||
} | ||
return e; | ||
}; | ||
@@ -788,13 +798,13 @@ if (e && e.initialState) { | ||
function isSubscriptionOperation(e) { | ||
var t = e.kind; | ||
return "subscription" === t || !!o && ("query" === t || "mutation" === t); | ||
var r = e.kind; | ||
return "subscription" === r || !!o && ("query" === r || "mutation" === r); | ||
} | ||
return function(n) { | ||
var o = r.share(n); | ||
var c = r.mergeMap((function(n) { | ||
var o = t.share(n); | ||
var c = t.mergeMap((function(n) { | ||
var u = n.key; | ||
var c = r.filter((function(e) { | ||
var c = t.filter((function(e) { | ||
return "teardown" === e.kind && e.key === u; | ||
}))(o); | ||
return r.takeUntil(c)(function createSubscriptionSource(n) { | ||
return t.takeUntil(c)(function createSubscriptionSource(n) { | ||
var o = a({ | ||
@@ -804,6 +814,6 @@ key: n.key.toString(36), | ||
variables: n.variables, | ||
context: t._extends({}, n.context) | ||
context: r._extends({}, n.context) | ||
}); | ||
return r.make((function(e) { | ||
var r = e.next; | ||
return t.make((function(e) { | ||
var t = e.next; | ||
var a = e.complete; | ||
@@ -818,6 +828,6 @@ var u = !1; | ||
next: function(e) { | ||
return r(t.makeResult(n, e)); | ||
return t(r.makeResult(n, e)); | ||
}, | ||
error: function(e) { | ||
return r(t.makeErrorResult(n, e)); | ||
return t(r.makeErrorResult(n, e)); | ||
}, | ||
@@ -843,7 +853,7 @@ complete: function() { | ||
}(n)); | ||
}))(r.filter(isSubscriptionOperation)(o)); | ||
var s = u(r.filter((function(e) { | ||
}))(t.filter(isSubscriptionOperation)(o)); | ||
var s = u(t.filter((function(e) { | ||
return !isSubscriptionOperation(e); | ||
}))(o)); | ||
return r.merge([ c, s ]); | ||
return t.merge([ c, s ]); | ||
}; | ||
@@ -850,0 +860,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
var e=require("graphql"),t=require("./5f352e3e.min.js"),n=require("wonka");function r(e,t){if(Array.isArray(e))for(var n=0;n<e.length;n++)r(e[n],t);else if("object"==typeof e&&null!==e)for(var o in e)"__typename"===o&&"string"==typeof e[o]?t[e[o]]=0:r(e[o],t);return t}function o(e){return Object.keys(r(e,{}))}var i=function(n){if(n.selectionSet&&!n.selectionSet.selections.some((function(t){return t.kind===e.Kind.FIELD&&"__typename"===t.name.value&&!t.alias})))return t._extends({},n,{selectionSet:t._extends({},n.selectionSet,{selections:n.selectionSet.selections.concat([{kind:e.Kind.FIELD,name:{kind:e.Kind.NAME,value:"__typename"}}])})})},u=new Map;function a(n){var r=t.keyDocument(n),o=u.get(r.__key);return o||((o=e.visit(r,{Field:i,InlineFragment:i})).__key=r.__key,u.set(r.__key,o)),o}function c(e){return e&&"object"==typeof e?Object.keys(e).reduce((function(t,n){var r=e[n];return"__typename"===n?Object.defineProperty(t,"__typename",{enumerable:!1,value:r}):t[n]=Array.isArray(r)?r.map(c):r&&"object"==typeof r&&"__typename"in r?c(r):r,t}),{}):e}function s(e){return e.toPromise=function(){return n.toPromise(n.take(1)(n.filter((function(e){return!e.stale}))(e)))},e}function f(e,t,n){return n||(n=t.context),{key:t.key,query:t.query,variables:t.variables,kind:e,context:n}}function p(e,n){return f(e.kind,e,t._extends({},e.context,{meta:t._extends({},e.context.meta,n)}))}function l(){}function d(n,r,o){for(var i=0;i<o.length;i++)if(o[i].kind===e.Kind.FRAGMENT_DEFINITION){var u=o[i].name.value,a=t.stringifyDocument(o[i]);n.has(u)||(n.set(u,a),r.push(o[i]))}else r.push(o[i])}function k(e){var t=e.kind;return"subscription"!==t&&"query"!==t}function y(e){var t=e.kind;return"mutation"!==t&&"query"!==t}function m(e){var r=e.forward,i=e.client,u=new Map,c=Object.create(null);function s(e){var t=f(e.kind,e);return t.query=a(e.query),t}function l(e){var t=e.context.requestPolicy;return"query"===e.kind&&"network-only"!==t&&("cache-only"===t||u.has(e.key))}return function(e){var a=n.share(e),f=n.map((function(e){var n=u.get(e.key),r=t._extends({},n,{operation:p(e,{cacheOutcome:n?"hit":"miss"})});return"cache-and-network"===e.context.requestPolicy&&(r.stale=!0,x(i,e)),r}))(n.filter((function(e){return!y(e)&&l(e)}))(a)),d=n.tap((function(e){var t=e.operation;if(t){var n=o(e.data).concat(t.context.additionalTypenames||[]);if("mutation"===e.operation.kind){for(var r=new Set,a=0;a<n.length;a++){var s=n[a],f=c[s]||(c[s]=new Set);f.forEach((function(e){r.add(e)})),f.clear()}r.forEach((function(e){u.has(e)&&(t=u.get(e).operation,u.delete(e),x(i,t))}))}else if("query"===t.kind&&e.data){u.set(t.key,e);for(var p=0;p<n.length;p++){var l=n[p];(c[l]||(c[l]=new Set)).add(t.key)}}}}))(r(n.filter((function(e){return"query"!==e.kind||"cache-only"!==e.context.requestPolicy}))(n.map((function(e){return p(e,{cacheOutcome:"miss"})}))(n.merge([n.map(s)(n.filter((function(e){return!y(e)&&!l(e)}))(a)),n.filter((function(e){return y(e)}))(a)])))));return n.merge([f,d])}}function x(e,n){return e.reexecuteOperation(f(n.kind,n,t._extends({},n.context,{requestPolicy:"network-only"})))}function h(e){var t=e.forward,r=new Set;function o(e){var t=e.key,n=e.kind;if("teardown"===n)return r.delete(t),!0;if("query"!==n&&"subscription"!==n)return!0;var o=r.has(t);return r.add(t),!o}function i(e){r.delete(e.operation.key)}return function(e){var r=n.filter(o)(e);return n.tap(i)(t(r))}}function v(e){var r=e.forward;return function(e){var o=n.share(e),i=n.mergeMap((function(e){var r=e.key,i=n.filter((function(e){return"teardown"===e.kind&&e.key===r}))(o),u=t.makeFetchBody(e),a=t.makeFetchURL(e,u),c=t.makeFetchOptions(e,u);return n.onPush((function(e){}))(n.takeUntil(i)(t.makeFetchSource(e,a,c)))}))(n.filter((function(e){return"query"===e.kind||"mutation"===e.kind}))(o)),u=r(n.filter((function(e){return"query"!==e.kind&&"mutation"!==e.kind}))(o));return n.merge([i,u])}}function g(e){return function(e){return n.filter((function(){return!1}))(n.tap((function(e){}))(e))}}var b=g();function q(e){return function(t){var n=t.client;return e.reduceRight((function(e,t){return t({client:n,forward:e,dispatchDebug:function(e){}})}),t.forward)}}var w=[h,m,v],E=function e(r){var o=new Map,i=new Map,u=[],a=n.makeSubject(),p=a.source,d=a.next,k=!1;function y(e){for(k=!0,e&&d(e);e=u.shift();)d(e);k=!1}function m(e){var r=n.filter((function(t){return t.operation.kind===e.kind&&t.operation.key===e.key}))(E);if(h.maskTypename&&(r=n.map((function(e){return t._extends({},e,{data:c(e.data)})}))(r)),"mutation"===e.kind)return n.take(1)(n.onStart((function(){return y(e)}))(r));var a=n.share(n.onEnd((function(){o.delete(e.key),i.delete(e.key);for(var t=u.length-1;t>=0;t--)u[t].key===e.key&&u.splice(t,1);y(f("teardown",e,e.context))}))(n.onStart((function(){i.set(e.key,a)}))(n.onPush((function(t){o.set(e.key,t)}))(n.switchMap((function(r){return r.stale?n.fromValue(r):n.merge([n.fromValue(r),n.map((function(){return t._extends({},r,{stale:!0})}))(n.take(1)(n.filter((function(t){return t.kind===e.kind&&t.key===e.key&&("network-only"===t.context.requestPolicy||"cache-and-network"===t.context.requestPolicy)}))(p)))])}))(n.takeUntil(n.filter((function(t){return"teardown"===t.kind&&t.key===e.key}))(p))(r))))));return a}var x=this instanceof e?this:Object.create(e.prototype),h=t._extends(x,{url:r.url,fetchOptions:r.fetchOptions,fetch:r.fetch,suspense:!!r.suspense,requestPolicy:r.requestPolicy||"cache-first",preferGetMethod:!!r.preferGetMethod,maskTypename:!!r.maskTypename,operations$:p,reexecuteOperation:function(e){("mutation"===e.kind||i.has(e.key))&&(u.push(e),k||Promise.resolve().then(y))},createOperationContext:function(e){return e||(e={}),t._extends({},{url:h.url,fetchOptions:h.fetchOptions,fetch:h.fetch,preferGetMethod:h.preferGetMethod},e,{suspense:e.suspense||!1!==e.suspense&&h.suspense,requestPolicy:e.requestPolicy||h.requestPolicy})},createRequestOperation:function(e,t,n){return f(e,t,h.createOperationContext(n))},executeRequestOperation:function(e){if("mutation"===e.kind)return m(e);var r=i.get(e.key)||m(e),u="cache-and-network"===e.context.requestPolicy||"network-only"===e.context.requestPolicy;return n.make((function(i){return n.subscribe(i.next)(n.onEnd(i.complete)(n.onStart((function(){var n=o.get(e.key);if("subscription"===e.kind)return y(e);u&&y(e),null!=n&&n===o.get(e.key)?i.next(u?t._extends({},n,{stale:!0}):n):u||y(e)}))(r))).unsubscribe}))},executeQuery:function(e,t){var n=h.createRequestOperation("query",e,t);return h.executeRequestOperation(n)},executeSubscription:function(e,t){var n=h.createRequestOperation("subscription",e,t);return h.executeRequestOperation(n)},executeMutation:function(e,t){var n=h.createRequestOperation("mutation",e,t);return h.executeRequestOperation(n)},query:function(e,n,r){return r&&"boolean"==typeof r.suspense||(r=t._extends({},r,{suspense:!1})),s(h.executeQuery(t.createRequest(e,n),r))},readQuery:function(e,t,r){var o=null;return n.subscribe((function(e){o=e}))(h.query(e,t,r)).unsubscribe(),o},subscription:function(e,n,r){return h.executeSubscription(t.createRequest(e,n),r)},mutation:function(e,n,r){return s(h.executeMutation(t.createRequest(e,n),r))}}),v=l,b=q(void 0!==r.exchanges?r.exchanges:w),E=n.share(b({client:h,dispatchDebug:v,forward:g()})(p));return n.publish(E),h},_=E;exports.CombinedError=t.CombinedError,exports.createRequest=t.createRequest,exports.getOperationName=t.getOperationName,exports.makeErrorResult=t.makeErrorResult,exports.makeResult=t.makeResult,exports.stringifyVariables=t.stringifyVariables,exports.Client=E,exports.cacheExchange=m,exports.composeExchanges=q,exports.createClient=_,exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=h,exports.defaultExchanges=w,exports.errorExchange=function(e){var t=e.onError;return function(e){var r=e.forward;return function(e){return n.tap((function(e){var n=e.error;n&&t(n,e.operation)}))(r(e))}}},exports.fallbackExchangeIO=b,exports.fetchExchange=v,exports.formatDocument=a,exports.gql=function(){for(var n=arguments,r=new Map,o=[],i=[],u=Array.isArray(arguments[0])?arguments[0][0]:arguments[0]||"",a=1;a<arguments.length;a++){var c=n[a];c&&c.definitions?i.push.apply(i,c.definitions):u+=c,u+=n[0][a]}return d(r,o,t.keyDocument(u).definitions),d(r,o,i),t.keyDocument({kind:e.Kind.DOCUMENT,definitions:o})},exports.makeOperation=f,exports.maskTypename=c,exports.ssrExchange=function(e){var r={},o=[];function i(e){o.push(e.operation.key),1===o.length&&Promise.resolve().then((function(){for(var e;e=o.shift();)delete r[e]}))}function u(e){return!k(e)&&void 0!==r[e.key]}var a=function(o){var a=o.client,c=o.forward;return function(o){var s=e&&"boolean"==typeof e.isClient?!!e.isClient:!a.suspense,f=n.share(o),p=c(n.filter((function(e){return!u(e)}))(f)),l=n.map((function(e){var n,o,i;return o=(n=r[e.key]).error,{operation:e,data:(i=n.data)?JSON.parse(i):void 0,extensions:void 0,error:o?new t.CombinedError({networkError:o.networkError?new Error(o.networkError):void 0,graphQLErrors:o.graphQLErrors&&o.graphQLErrors.length?o.graphQLErrors:void 0}):void 0}}))(n.filter((function(e){return u(e)}))(f));return s?l=n.tap(i)(l):p=n.tap((function(e){var t=e.operation;if(!k(t)){var n=function(e){var t=e.data,n=e.error,r={};return void 0!==t&&(r.data=JSON.stringify(t)),n&&(r.error={graphQLErrors:n.graphQLErrors.map((function(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}))},n.networkError&&(r.error.networkError=""+n.networkError)),r}(e);r[t.key]=n}}))(p),n.merge([p,l])}};return a.restoreData=function(e){return t._extends(r,e)},a.extractData=function(){return t._extends({},r)},e&&e.initialState&&a.restoreData(e.initialState),a},exports.subscriptionExchange=function(r){var o=r.forwardSubscription,i=r.enableAllOperations;return function(r){var u=r.client,a=r.forward;function c(e){var t=e.kind;return"subscription"===t||!!i&&("query"===t||"mutation"===t)}return function(r){var i=n.share(r),s=n.mergeMap((function(r){var a=r.key,c=n.filter((function(e){return"teardown"===e.kind&&e.key===a}))(i);return n.takeUntil(c)(function(r){var i=o({key:r.key.toString(36),query:e.print(r.query),variables:r.variables,context:t._extends({},r.context)});return n.make((function(e){var n,o=e.next,a=e.complete,c=!1;return Promise.resolve().then((function(){c||(n=i.subscribe({next:function(e){return o(t.makeResult(r,e))},error:function(e){return o(t.makeErrorResult(r,e))},complete:function(){c||(c=!0,"subscription"===r.kind&&u.reexecuteOperation(f("teardown",r,r.context)),a())}}))})),function(){c=!0,n&&n.unsubscribe()}}))}(r))}))(n.filter(c)(i)),p=a(n.filter((function(e){return!c(e)}))(i));return n.merge([s,p])}}}; | ||
var e=require("graphql"),t=require("./5f352e3e.min.js"),r=require("wonka");function n(e,t){if(Array.isArray(e))for(var r=0;r<e.length;r++)n(e[r],t);else if("object"==typeof e&&null!==e)for(var o in e)"__typename"===o&&"string"==typeof e[o]?t[e[o]]=0:n(e[o],t);return t}function o(e){return Object.keys(n(e,{}))}var i=function(r){if(r.selectionSet&&!r.selectionSet.selections.some((function(t){return t.kind===e.Kind.FIELD&&"__typename"===t.name.value&&!t.alias})))return t._extends({},r,{selectionSet:t._extends({},r.selectionSet,{selections:r.selectionSet.selections.concat([{kind:e.Kind.FIELD,name:{kind:e.Kind.NAME,value:"__typename"}}])})})},u=new Map;function a(r){var n=t.keyDocument(r),o=u.get(n.__key);return o||((o=e.visit(n,{Field:i,InlineFragment:i})).__key=n.__key,u.set(n.__key,o)),o}function c(e){return e&&"object"==typeof e?Object.keys(e).reduce((function(t,r){var n=e[r];return"__typename"===r?Object.defineProperty(t,"__typename",{enumerable:!1,value:n}):t[r]=Array.isArray(n)?n.map(c):n&&"object"==typeof n&&"__typename"in n?c(n):n,t}),{}):e}function s(e){return e.toPromise=function(){return r.toPromise(r.take(1)(r.filter((function(e){return!e.stale}))(e)))},e}function f(e,t,r){return r||(r=t.context),{key:t.key,query:t.query,variables:t.variables,kind:e,context:r}}function p(e,r){return f(e.kind,e,t._extends({},e.context,{meta:t._extends({},e.context.meta,r)}))}function l(){}function d(r,n,o){for(var i=0;i<o.length;i++)if(o[i].kind===e.Kind.FRAGMENT_DEFINITION){var u=o[i].name.value,a=t.stringifyDocument(o[i]);r.has(u)||(r.set(u,a),n.push(o[i]))}else n.push(o[i])}function y(e){var t=e.kind;return"subscription"!==t&&"query"!==t}function k(e){var t=e.kind;return"mutation"!==t&&"query"!==t}function m(e){var n=e.forward,i=e.client,u=new Map,c=Object.create(null);function s(e){var t=f(e.kind,e);return t.query=a(e.query),t}function l(e){var t=e.context.requestPolicy;return"query"===e.kind&&"network-only"!==t&&("cache-only"===t||u.has(e.key))}return function(e){var a=r.share(e),f=r.map((function(e){var r=u.get(e.key),n=t._extends({},r,{operation:p(e,{cacheOutcome:r?"hit":"miss"})});return"cache-and-network"===e.context.requestPolicy&&(n.stale=!0,h(i,e)),n}))(r.filter((function(e){return!k(e)&&l(e)}))(a)),d=r.tap((function(e){var t=e.operation;if(t){var r=o(e.data).concat(t.context.additionalTypenames||[]);if("mutation"===e.operation.kind){for(var n=new Set,a=0;a<r.length;a++){var s=r[a],f=c[s]||(c[s]=new Set);f.forEach((function(e){n.add(e)})),f.clear()}n.forEach((function(e){u.has(e)&&(t=u.get(e).operation,u.delete(e),h(i,t))}))}else if("query"===t.kind&&e.data){u.set(t.key,e);for(var p=0;p<r.length;p++){var l=r[p];(c[l]||(c[l]=new Set)).add(t.key)}}}}))(n(r.filter((function(e){return"query"!==e.kind||"cache-only"!==e.context.requestPolicy}))(r.map((function(e){return p(e,{cacheOutcome:"miss"})}))(r.merge([r.map(s)(r.filter((function(e){return!k(e)&&!l(e)}))(a)),r.filter((function(e){return k(e)}))(a)])))));return r.merge([f,d])}}function h(e,r){return e.reexecuteOperation(f(r.kind,r,t._extends({},r.context,{requestPolicy:"network-only"})))}function x(e){var t=e.forward,n=new Set;function o(e){var t=e.key,r=e.kind;if("teardown"===r)return n.delete(t),!0;if("query"!==r&&"subscription"!==r)return!0;var o=n.has(t);return n.add(t),!o}function i(e){n.delete(e.operation.key)}return function(e){var n=r.filter(o)(e);return r.tap(i)(t(n))}}function v(e){var n=e.forward;return function(e){var o=r.share(e),i=r.mergeMap((function(e){var n=e.key,i=r.filter((function(e){return"teardown"===e.kind&&e.key===n}))(o),u=t.makeFetchBody(e),a=t.makeFetchURL(e,u),c=t.makeFetchOptions(e,u);return r.onPush((function(e){}))(r.takeUntil(i)(t.makeFetchSource(e,a,c)))}))(r.filter((function(e){return"query"===e.kind||"mutation"===e.kind}))(o)),u=n(r.filter((function(e){return"query"!==e.kind&&"mutation"!==e.kind}))(o));return r.merge([i,u])}}function g(e){return function(e){return r.filter((function(){return!1}))(r.tap((function(e){}))(e))}}var b=g();function q(e){return function(t){var r=t.client;return e.reduceRight((function(e,t){return t({client:r,forward:e,dispatchDebug:function(e){}})}),t.forward)}}var w=[x,m,v],E=function e(n){var o=new Map,i=new Map,u=[],a=r.makeSubject(),p=a.source,d=a.next,y=!1;function k(e){for(y=!0,e&&d(e);e=u.shift();)d(e);y=!1}function m(e){var n=r.filter((function(t){return t.operation.kind===e.kind&&t.operation.key===e.key}))(E);if(x.maskTypename&&(n=r.map((function(e){return t._extends({},e,{data:c(e.data)})}))(n)),"mutation"===e.kind)return r.take(1)(r.onStart((function(){return k(e)}))(n));var a=r.share(r.onEnd((function(){o.delete(e.key),i.delete(e.key);for(var t=u.length-1;t>=0;t--)u[t].key===e.key&&u.splice(t,1);k(f("teardown",e,e.context))}))(r.onStart((function(){i.set(e.key,a)}))(r.onPush((function(t){o.set(e.key,t)}))(r.switchMap((function(n){return"query"!==e.kind||n.stale?r.fromValue(n):r.merge([r.fromValue(n),r.map((function(){return t._extends({},n,{stale:!0})}))(r.take(1)(r.filter((function(t){return"query"===t.kind&&t.key===e.key&&"cache-only"!==t.context.requestPolicy}))(p)))])}))(r.takeUntil(r.filter((function(t){return"teardown"===t.kind&&t.key===e.key}))(p))(n))))));return a}var h=this instanceof e?this:Object.create(e.prototype),x=t._extends(h,{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,suspense:!!n.suspense,requestPolicy:n.requestPolicy||"cache-first",preferGetMethod:!!n.preferGetMethod,maskTypename:!!n.maskTypename,operations$:p,reexecuteOperation:function(e){("mutation"===e.kind||i.has(e.key))&&(u.push(e),y||Promise.resolve().then(k))},createOperationContext:function(e){return e||(e={}),t._extends({},{url:x.url,fetchOptions:x.fetchOptions,fetch:x.fetch,preferGetMethod:x.preferGetMethod},e,{suspense:e.suspense||!1!==e.suspense&&x.suspense,requestPolicy:e.requestPolicy||x.requestPolicy})},createRequestOperation:function(e,t,r){return f(e,t,x.createOperationContext(r))},executeRequestOperation:function(e){if("mutation"===e.kind)return m(e);var n=i.get(e.key)||m(e),u="cache-and-network"===e.context.requestPolicy||"network-only"===e.context.requestPolicy;return r.make((function(i){return r.subscribe(i.next)(r.onEnd(i.complete)(r.onStart((function(){var r=o.get(e.key);if("subscription"===e.kind)return k(e);u&&k(e),null!=r&&r===o.get(e.key)?i.next(u?t._extends({},r,{stale:!0}):r):u||k(e)}))(n))).unsubscribe}))},executeQuery:function(e,t){var r=x.createRequestOperation("query",e,t);return x.executeRequestOperation(r)},executeSubscription:function(e,t){var r=x.createRequestOperation("subscription",e,t);return x.executeRequestOperation(r)},executeMutation:function(e,t){var r=x.createRequestOperation("mutation",e,t);return x.executeRequestOperation(r)},query:function(e,r,n){return n&&"boolean"==typeof n.suspense||(n=t._extends({},n,{suspense:!1})),s(x.executeQuery(t.createRequest(e,r),n))},readQuery:function(e,t,n){var o=null;return r.subscribe((function(e){o=e}))(x.query(e,t,n)).unsubscribe(),o},subscription:function(e,r,n){return x.executeSubscription(t.createRequest(e,r),n)},mutation:function(e,r,n){return s(x.executeMutation(t.createRequest(e,r),n))}}),v=l,b=q(void 0!==n.exchanges?n.exchanges:w),E=r.share(b({client:x,dispatchDebug:v,forward:g()})(p));return r.publish(E),x},O=E;exports.CombinedError=t.CombinedError,exports.createRequest=t.createRequest,exports.getOperationName=t.getOperationName,exports.makeErrorResult=t.makeErrorResult,exports.makeResult=t.makeResult,exports.stringifyVariables=t.stringifyVariables,exports.Client=E,exports.cacheExchange=m,exports.composeExchanges=q,exports.createClient=O,exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=x,exports.defaultExchanges=w,exports.errorExchange=function(e){var t=e.onError;return function(e){var n=e.forward;return function(e){return r.tap((function(e){var r=e.error;r&&t(r,e.operation)}))(n(e))}}},exports.fallbackExchangeIO=b,exports.fetchExchange=v,exports.formatDocument=a,exports.gql=function(){for(var r=arguments,n=new Map,o=[],i=[],u=Array.isArray(arguments[0])?arguments[0][0]:arguments[0]||"",a=1;a<arguments.length;a++){var c=r[a];c&&c.definitions?i.push.apply(i,c.definitions):u+=c,u+=r[0][a]}return d(n,o,t.keyDocument(u).definitions),d(n,o,i),t.keyDocument({kind:e.Kind.DOCUMENT,definitions:o})},exports.makeOperation=f,exports.maskTypename=c,exports.ssrExchange=function(e){var n={},o=[];function i(e){o.push(e.operation.key),1===o.length&&Promise.resolve().then((function(){for(var e;e=o.shift();)n[e]=null}))}function u(e){return!y(e)&&null!=n[e.key]}var a=function(o){var a=o.client,c=o.forward;return function(o){var s=e&&"boolean"==typeof e.isClient?!!e.isClient:!a.suspense,f=r.share(o),p=c(r.filter((function(e){return!u(e)}))(f)),l=r.map((function(e){var r,o,i;return o=(r=n[e.key]).error,{operation:e,data:(i=r.data)?JSON.parse(i):void 0,extensions:void 0,error:o?new t.CombinedError({networkError:o.networkError?new Error(o.networkError):void 0,graphQLErrors:o.graphQLErrors&&o.graphQLErrors.length?o.graphQLErrors:void 0}):void 0}}))(r.filter((function(e){return u(e)}))(f));return s?l=r.tap(i)(l):p=r.tap((function(e){var t=e.operation;if(!y(t)){var r=function(e){var t=e.data,r=e.error,n={};return void 0!==t&&(n.data=JSON.stringify(t)),r&&(n.error={graphQLErrors:r.graphQLErrors.map((function(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}))},r.networkError&&(n.error.networkError=""+r.networkError)),n}(e);n[t.key]=r}}))(p),r.merge([p,l])}};return a.restoreData=function(e){for(var t in e)null!==n[t]&&(n[t]=e[t])},a.extractData=function(){var e={};for(var t in n)null!=n[t]&&(e[t]=n[t]);return e},e&&e.initialState&&a.restoreData(e.initialState),a},exports.subscriptionExchange=function(n){var o=n.forwardSubscription,i=n.enableAllOperations;return function(n){var u=n.client,a=n.forward;function c(e){var t=e.kind;return"subscription"===t||!!i&&("query"===t||"mutation"===t)}return function(n){var i=r.share(n),s=r.mergeMap((function(n){var a=n.key,c=r.filter((function(e){return"teardown"===e.kind&&e.key===a}))(i);return r.takeUntil(c)(function(n){var i=o({key:n.key.toString(36),query:e.print(n.query),variables:n.variables,context:t._extends({},n.context)});return r.make((function(e){var r,o=e.next,a=e.complete,c=!1;return Promise.resolve().then((function(){c||(r=i.subscribe({next:function(e){return o(t.makeResult(n,e))},error:function(e){return o(t.makeErrorResult(n,e))},complete:function(){c||(c=!0,"subscription"===n.kind&&u.reexecuteOperation(f("teardown",n,n.context)),a())}}))})),function(){c=!0,r&&r.unsubscribe()}}))}(n))}))(r.filter(c)(i)),p=a(r.filter((function(e){return!c(e)}))(i));return r.merge([s,p])}}}; | ||
//# sourceMappingURL=urql-core.min.js.map |
{ | ||
"name": "@urql/core", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"description": "The shared core for the highly customizable and versatile GraphQL client", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
360026
2565