@urql/core
Advanced tools
Comparing version 1.12.1 to 1.12.2
# @urql/core | ||
## 1.12.2 | ||
### Patch Changes | ||
- ⚠️ Fix `formatDocument` mutating parts of the `DocumentNode` which may be shared by other documents and queries. Also ensure that a formatted document will always generate the same key in `createRequest` as the original document, by [@kitten](https://github.com/kitten) (See [#880](https://github.com/FormidableLabs/urql/pull/880)) | ||
- ⚠️ Fix `ssrExchange` invalidating results on the client-side too eagerly, by delaying invalidation by a tick, by [@kitten](https://github.com/kitten) (See [#885](https://github.com/FormidableLabs/urql/pull/885)) | ||
## 1.12.1 | ||
@@ -4,0 +11,0 @@ |
import { DocumentNode } from 'graphql'; | ||
export declare const collectTypesFromResponse: (response: object) => string[]; | ||
export declare const formatDocument: (node: DocumentNode) => any; | ||
export declare const formatDocument: (node: DocumentNode) => DocumentNode; |
"use strict"; | ||
function _ref2(a, c, b) { | ||
return b.indexOf(a) === c; | ||
function _ref2(a, b, c) { | ||
return c.indexOf(a) === b; | ||
} | ||
@@ -71,6 +71,6 @@ | ||
var fetchSource = require("./838e26bf.js"), wonka = require("wonka"), parser = require("graphql/language/parser"), printer = require("graphql/language/printer"), kinds = require("graphql/language/kinds"), visitor = require("graphql/language/visitor"), phash = function(a, c) { | ||
var fetchSource = require("./838e26bf.js"), wonka = require("wonka"), parser = require("graphql/language/parser"), printer = require("graphql/language/printer"), kinds = require("graphql/language/kinds"), visitor = require("graphql/language/visitor"), phash = function(a, b) { | ||
a |= 0; | ||
for (var b = 0, d = 0 | c.length; b < d; b++) { | ||
a = (a << 5) + a + c.charCodeAt(b); | ||
for (var c = 0, d = 0 | b.length; c < d; c++) { | ||
a = (a << 5) + a + b.charCodeAt(c); | ||
} | ||
@@ -82,34 +82,34 @@ return a; | ||
return hash(a.replace(/[\s,]+/g, " ").trim()); | ||
}, docs = Object.create(null), keyProp = "__key", createRequest = function(a, c) { | ||
}, docs = Object.create(null), createRequest = function(a, b) { | ||
if ("string" == typeof a) { | ||
var b = hashQuery(a); | ||
a = void 0 !== docs[b] ? docs[b] : parser.parse(a); | ||
var c = hashQuery(a); | ||
a = void 0 !== docs[c] ? docs[c] : parser.parse(a); | ||
} else { | ||
void 0 !== a[keyProp] ? b = a[keyProp] : (b = hashQuery(printer.print(a)), a = void 0 !== docs[b] ? docs[b] : a); | ||
void 0 !== a.__key ? c = a.__key : (c = hashQuery(printer.print(a)), a = void 0 !== docs[c] ? docs[c] : a); | ||
} | ||
docs[b] = a; | ||
a[keyProp] = b; | ||
docs[c] = a; | ||
a.__key = c; | ||
return { | ||
key: c ? phash(b, fetchSource.stringifyVariables(c)) >>> 0 : b, | ||
key: b ? phash(c, fetchSource.stringifyVariables(b)) >>> 0 : c, | ||
query: a, | ||
variables: c || {} | ||
variables: b || {} | ||
}; | ||
}, addMetadata = function(a, c) { | ||
}, addMetadata = function(a, b) { | ||
return fetchSource._extends({}, a, { | ||
context: fetchSource._extends({}, a.context, { | ||
meta: fetchSource._extends({}, a.context.meta, c) | ||
meta: fetchSource._extends({}, a.context.meta, b) | ||
}) | ||
}); | ||
}, collectTypes = function(a, c) { | ||
void 0 === c && (c = []); | ||
}, collectTypes = function(a, b) { | ||
void 0 === b && (b = []); | ||
if (Array.isArray(a)) { | ||
a.forEach((function b(a) { | ||
collectTypes(a, c); | ||
a.forEach((function c(a) { | ||
collectTypes(a, b); | ||
})); | ||
} else if ("object" == typeof a && null !== a) { | ||
for (var d in a) { | ||
"__typename" === d && "string" == typeof a[d] ? c.push(a[d]) : collectTypes(a[d], c); | ||
"__typename" === d && "string" == typeof a[d] ? b.push(a[d]) : collectTypes(a[d], b); | ||
} | ||
} | ||
return c; | ||
return b; | ||
}, collectTypesFromResponse = function(a) { | ||
@@ -119,18 +119,24 @@ return collectTypes(a).filter(_ref2); | ||
if (a.selectionSet && !a.selectionSet.selections.some(_ref3)) { | ||
return a.selectionSet.selections.push({ | ||
kind: kinds.Kind.FIELD, | ||
name: { | ||
kind: kinds.Kind.NAME, | ||
value: "__typename" | ||
} | ||
}), a; | ||
return fetchSource._extends({}, a, { | ||
selectionSet: fetchSource._extends({}, a.selectionSet, { | ||
selections: a.selectionSet.selections.concat([ { | ||
kind: kinds.Kind.FIELD, | ||
name: { | ||
kind: kinds.Kind.NAME, | ||
value: "__typename" | ||
} | ||
} ]) | ||
}) | ||
}); | ||
} | ||
}, formatDocument = function(a) { | ||
return visitor.visit(a, { | ||
var b = visitor.visit(a, { | ||
Field: formatNode, | ||
InlineFragment: formatNode | ||
}); | ||
b.__key = a.__key; | ||
return b; | ||
}, toSuspenseSource = function(a) { | ||
return function(c) { | ||
var b = wonka.share(a), d = !1, f = !1; | ||
return function(b) { | ||
var c = wonka.share(a), d = !1, f = !1; | ||
wonka.onPush((function() { | ||
@@ -140,15 +146,15 @@ return d = !0; | ||
return !f; | ||
}))(b))(c); | ||
}))(c))(b); | ||
if (!d) { | ||
throw f = !0, c(0), wonka.toPromise(wonka.take(1)(b)); | ||
throw f = !0, b(0), wonka.toPromise(wonka.take(1)(c)); | ||
} | ||
}; | ||
}, maskTypename = function(a) { | ||
return a && "object" == typeof a ? Object.keys(a).reduce((function(c, b) { | ||
var d = a[b]; | ||
"__typename" === b ? Object.defineProperty(c, "__typename", { | ||
return a && "object" == typeof a ? Object.keys(a).reduce((function(b, c) { | ||
var d = a[c]; | ||
"__typename" === c ? Object.defineProperty(b, "__typename", { | ||
enumerable: !1, | ||
value: d | ||
}) : Array.isArray(d) ? c[b] = d.map(maskTypename) : c[b] = d && "object" == typeof d && "__typename" in d ? maskTypename(d) : d; | ||
return c; | ||
}) : Array.isArray(d) ? b[c] = d.map(maskTypename) : b[c] = d && "object" == typeof d && "__typename" in d ? maskTypename(d) : d; | ||
return b; | ||
}), {}) : a; | ||
@@ -158,3 +164,3 @@ }, noop = function() {}, shouldSkip = function(a) { | ||
}, serializeResult = function(a) { | ||
var c = a.error; | ||
var b = a.error; | ||
a = { | ||
@@ -164,63 +170,68 @@ data: a.data, | ||
}; | ||
c && (a.error = { | ||
graphQLErrors: c.graphQLErrors.map(_ref), | ||
networkError: c.networkError ? "" + c.networkError : void 0 | ||
b && (a.error = { | ||
graphQLErrors: b.graphQLErrors.map(_ref), | ||
networkError: b.networkError ? "" + b.networkError : void 0 | ||
}); | ||
return a; | ||
}, deserializeResult = function(a, c) { | ||
var b = c.error; | ||
}, deserializeResult = function(a, b) { | ||
var c = b.error; | ||
return { | ||
operation: a, | ||
data: c.data, | ||
data: b.data, | ||
extensions: void 0, | ||
error: b ? new fetchSource.CombinedError({ | ||
networkError: b.networkError ? Error(b.networkError) : void 0, | ||
graphQLErrors: b.graphQLErrors && b.graphQLErrors.length ? b.graphQLErrors : void 0 | ||
error: c ? new fetchSource.CombinedError({ | ||
networkError: c.networkError ? Error(c.networkError) : void 0, | ||
graphQLErrors: c.graphQLErrors && c.graphQLErrors.length ? c.graphQLErrors : void 0 | ||
}) : void 0 | ||
}; | ||
}, ssrExchange = function(a) { | ||
function b() { | ||
for (var a; a = l.shift(); ) { | ||
delete h[a]; | ||
} | ||
} | ||
function c(a) { | ||
return !h(a); | ||
return !k(a); | ||
} | ||
function b(a) { | ||
return deserializeResult(a, k[a.key]); | ||
} | ||
function d(a) { | ||
return h(a); | ||
return deserializeResult(a, h[a.key]); | ||
} | ||
function f(a) { | ||
var b = a.operation; | ||
shouldSkip(b) || (a = serializeResult(a), k[b.key] = a); | ||
return k(a); | ||
} | ||
function g(a) { | ||
delete k[a.operation.key]; | ||
var c = a.operation; | ||
shouldSkip(c) || (a = serializeResult(a), h[c.key] = a); | ||
} | ||
var k = {}, h = function(a) { | ||
return !shouldSkip(a) && void 0 !== k[a.key]; | ||
}, e = function(e) { | ||
var k = e.client, l = e.forward; | ||
return function(e) { | ||
var q = a && "boolean" == typeof a.isClient ? !!a.isClient : !k.suspense, h = wonka.share(e); | ||
e = l(wonka.filter(c)(h)); | ||
h = wonka.map(b)(wonka.filter(d)(h)); | ||
q ? h = wonka.tap(g)(h) : e = wonka.tap(f)(e); | ||
return wonka.merge([ e, h ]); | ||
var h = {}, l = [], e = function(a) { | ||
l.push(a.operation.key); | ||
1 === l.length && Promise.resolve().then(b); | ||
}, k = function(a) { | ||
return !shouldSkip(a) && void 0 !== h[a.key]; | ||
}, m = function(b) { | ||
var h = b.client, q = b.forward; | ||
return function(b) { | ||
var m = a && "boolean" == typeof a.isClient ? !!a.isClient : !h.suspense, k = wonka.share(b); | ||
b = q(wonka.filter(c)(k)); | ||
k = wonka.map(d)(wonka.filter(f)(k)); | ||
m ? k = wonka.tap(e)(k) : b = wonka.tap(g)(b); | ||
return wonka.merge([ b, k ]); | ||
}; | ||
}; | ||
e.restoreData = function(a) { | ||
return fetchSource._extends(k, a); | ||
m.restoreData = function(a) { | ||
return fetchSource._extends(h, a); | ||
}; | ||
e.extractData = function() { | ||
return fetchSource._extends({}, k); | ||
m.extractData = function() { | ||
return fetchSource._extends({}, h); | ||
}; | ||
a && a.initialState && e.restoreData(a.initialState); | ||
return e; | ||
a && a.initialState && m.restoreData(a.initialState); | ||
return m; | ||
}, shouldSkip$1 = function(a) { | ||
return "mutation" !== (a = a.operationName) && "query" !== a; | ||
}, cacheExchange = function(a) { | ||
function c(a) { | ||
var b = e.get(a.key); | ||
"production" !== process.env.NODE_ENV && h(fetchSource._extends({}, { | ||
function b(a) { | ||
var c = e.get(a.key); | ||
"production" !== process.env.NODE_ENV && l(fetchSource._extends({}, { | ||
operation: a | ||
}, b ? { | ||
}, c ? { | ||
type: "cacheHit", | ||
@@ -232,11 +243,11 @@ message: "The result was successfully retried from the cache" | ||
})); | ||
b = fetchSource._extends({}, b, { | ||
c = fetchSource._extends({}, c, { | ||
operation: addMetadata(a, { | ||
cacheOutcome: b ? "hit" : "miss" | ||
cacheOutcome: c ? "hit" : "miss" | ||
}) | ||
}); | ||
"cache-and-network" === a.context.requestPolicy && (b.stale = !0, reexecuteOperation(k, a)); | ||
return b; | ||
"cache-and-network" === a.context.requestPolicy && (c.stale = !0, reexecuteOperation(h, a)); | ||
return c; | ||
} | ||
function b(a) { | ||
function c(a) { | ||
return !shouldSkip$1(a) && n(a); | ||
@@ -250,33 +261,33 @@ } | ||
} | ||
var l, m, p, n, g = a.forward, k = a.client, h = a.dispatchDebug, e = new Map; | ||
var k, m, p, n, g = a.forward, h = a.client, l = a.dispatchDebug, e = new Map; | ||
a = Object.create(null); | ||
l = _ref$1, m = afterMutation(e, a, k, h), p = afterQuery(e, a), n = function(a) { | ||
var c = a.context.requestPolicy; | ||
return "query" === a.operationName && "network-only" !== c && ("cache-only" === c || e.has(a.key)); | ||
k = _ref$1, m = afterMutation(e, a, h, l), p = afterQuery(e, a), n = function(a) { | ||
var b = a.context.requestPolicy; | ||
return "query" === a.operationName && "network-only" !== b && ("cache-only" === b || e.has(a.key)); | ||
}; | ||
return function(a) { | ||
var e = wonka.share(a); | ||
a = wonka.map(c)(wonka.filter(b)(e)); | ||
e = wonka.tap(d)(g(wonka.filter(_ref5)(wonka.map(_ref6)(wonka.merge([ wonka.map(l)(wonka.filter(f)(e)), wonka.filter(_ref8)(e) ]))))); | ||
a = wonka.map(b)(wonka.filter(c)(e)); | ||
e = wonka.tap(d)(g(wonka.filter(_ref5)(wonka.map(_ref6)(wonka.merge([ wonka.map(k)(wonka.filter(f)(e)), wonka.filter(_ref8)(e) ]))))); | ||
return wonka.merge([ a, e ]); | ||
}; | ||
}, reexecuteOperation = function(a, c) { | ||
return a.reexecuteOperation(fetchSource._extends({}, c, { | ||
context: fetchSource._extends({}, c.context, { | ||
}, reexecuteOperation = function(a, b) { | ||
return a.reexecuteOperation(fetchSource._extends({}, b, { | ||
context: fetchSource._extends({}, b.context, { | ||
requestPolicy: "network-only" | ||
}) | ||
})); | ||
}, afterMutation = function(a, c, b, d) { | ||
function f(c) { | ||
if (a.has(c)) { | ||
var d = a.get(c).operation; | ||
a.delete(c); | ||
reexecuteOperation(b, d); | ||
}, afterMutation = function(a, b, c, d) { | ||
function f(b) { | ||
if (a.has(b)) { | ||
var d = a.get(b).operation; | ||
a.delete(b); | ||
reexecuteOperation(c, d); | ||
} | ||
} | ||
return function(a) { | ||
function b(a) { | ||
h.add(a); | ||
function c(a) { | ||
l.add(a); | ||
} | ||
var h = new Set, e = a.operation.context.additionalTypenames; | ||
var l = new Set, e = a.operation.context.additionalTypenames; | ||
e = collectTypesFromResponse(a.data).concat(e || []); | ||
@@ -294,29 +305,29 @@ "production" !== process.env.NODE_ENV && d({ | ||
e.forEach((function(a) { | ||
(a = c[a] || (c[a] = new Set)).forEach(b); | ||
(a = b[a] || (b[a] = new Set)).forEach(c); | ||
a.clear(); | ||
})); | ||
h.forEach(f); | ||
l.forEach(f); | ||
}; | ||
}, afterQuery = function(a, c) { | ||
return function(b) { | ||
var d = b.operation, f = b.data, g = d.context.additionalTypenames; | ||
}, afterQuery = function(a, b) { | ||
return function(c) { | ||
var d = c.operation, f = c.data, g = d.context.additionalTypenames; | ||
null != f && (a.set(d.key, { | ||
operation: d, | ||
data: f, | ||
error: b.error | ||
}), collectTypesFromResponse(b.data).concat(g || []).forEach((function(a) { | ||
(c[a] || (c[a] = new Set)).add(d.key); | ||
error: c.error | ||
}), collectTypesFromResponse(c.data).concat(g || []).forEach((function(a) { | ||
(b[a] || (b[a] = new Set)).add(d.key); | ||
}))); | ||
}; | ||
}, subscriptionExchange = function(a) { | ||
function c(a) { | ||
function b(a) { | ||
return "subscription" === (a = a.operationName) || !!d && ("query" === a || "mutation" === a); | ||
} | ||
var b = a.forwardSubscription, d = a.enableAllOperations; | ||
var c = a.forwardSubscription, d = a.enableAllOperations; | ||
return function(a) { | ||
function d(a) { | ||
return !l(a); | ||
return !k(a); | ||
} | ||
var k = a.client, f = a.forward, e = function(a) { | ||
var c = b({ | ||
var h = a.client, f = a.forward, e = function(a) { | ||
var b = c({ | ||
key: a.key.toString(36), | ||
@@ -327,19 +338,19 @@ query: printer.print(a.query), | ||
}); | ||
return wonka.make((function(b) { | ||
function e(b) { | ||
return h(fetchSource.makeResult(a, b)); | ||
return wonka.make((function(c) { | ||
function d(c) { | ||
return k(fetchSource.makeResult(a, c)); | ||
} | ||
function d(b) { | ||
return h(fetchSource.makeErrorResult(a, b)); | ||
function e(c) { | ||
return k(fetchSource.makeErrorResult(a, c)); | ||
} | ||
function f() { | ||
l || (l = !0, "subscription" === a.operationName && k.reexecuteOperation(fetchSource._extends({}, a, { | ||
g || (g = !0, "subscription" === a.operationName && h.reexecuteOperation(fetchSource._extends({}, a, { | ||
operationName: "teardown" | ||
})), g()); | ||
})), l()); | ||
} | ||
var m, h = b.next, g = b.complete, l = !1; | ||
var m, k = c.next, l = c.complete, g = !1; | ||
Promise.resolve().then((function() { | ||
l || (m = c.subscribe({ | ||
next: e, | ||
error: d, | ||
g || (m = b.subscribe({ | ||
next: d, | ||
error: e, | ||
complete: f | ||
@@ -349,17 +360,17 @@ })); | ||
return function() { | ||
l = !0; | ||
g = !0; | ||
m && m.unsubscribe(); | ||
}; | ||
})); | ||
}, l = c; | ||
}, k = b; | ||
return function(a) { | ||
var c, b = wonka.share(a); | ||
var b, c = wonka.share(a); | ||
a = wonka.mergeMap((function(a) { | ||
var c = a.key, d = wonka.filter((function(a) { | ||
return "teardown" === a.operationName && a.key === c; | ||
}))(b); | ||
var b = a.key, d = wonka.filter((function(a) { | ||
return "teardown" === a.operationName && a.key === b; | ||
}))(c); | ||
return wonka.takeUntil(d)(e(a)); | ||
}))(wonka.filter(l)(b)); | ||
c = f(wonka.filter(d)(b)); | ||
return wonka.merge([ a, c ]); | ||
}))(wonka.filter(k)(c)); | ||
b = f(wonka.filter(d)(c)); | ||
return wonka.merge([ a, b ]); | ||
}; | ||
@@ -369,12 +380,12 @@ }; | ||
var d = a.forward; | ||
return "production" === process.env.NODE_ENV ? function c(a) { | ||
return "production" === process.env.NODE_ENV ? function b(a) { | ||
return d(a); | ||
} : function b(a) { | ||
} : function c(a) { | ||
return wonka.tap(_ref2$1)(d(wonka.tap(_ref3$1)(a))); | ||
}; | ||
}, dedupExchange = function(a) { | ||
var c = a.forward, b = a.dispatchDebug, d = new Set, f = function(a) { | ||
var c = a.key, e = a.operationName; | ||
var b = a.forward, c = a.dispatchDebug, d = new Set, f = function(a) { | ||
var b = a.key, e = a.operationName; | ||
if ("teardown" === e) { | ||
return d.delete(c), !0; | ||
return d.delete(b), !0; | ||
} | ||
@@ -384,5 +395,5 @@ if ("query" !== e && "subscription" !== e) { | ||
} | ||
e = d.has(c); | ||
d.add(c); | ||
e && "production" !== process.env.NODE_ENV && b({ | ||
e = d.has(b); | ||
d.add(b); | ||
e && "production" !== process.env.NODE_ENV && c({ | ||
type: "dedup", | ||
@@ -399,13 +410,13 @@ message: "An operation has been deduped.", | ||
a = wonka.filter(f)(a); | ||
return wonka.tap(g)(c(a)); | ||
return wonka.tap(g)(b(a)); | ||
}; | ||
}, fetchExchange = function(a) { | ||
var c = a.forward, b = a.dispatchDebug; | ||
var b = a.forward, c = a.dispatchDebug; | ||
return function(a) { | ||
var g, d = wonka.share(a); | ||
a = wonka.mergeMap((function(a) { | ||
var c = a.key, e = wonka.filter((function(a) { | ||
return "teardown" === a.operationName && a.key === c; | ||
}))(d), f = fetchSource.makeFetchBody(a), g = fetchSource.makeFetchURL(a, f), k = fetchSource.makeFetchOptions(a, f); | ||
"production" !== process.env.NODE_ENV && b({ | ||
var b = a.key, e = wonka.filter((function(a) { | ||
return "teardown" === a.operationName && a.key === b; | ||
}))(d), f = fetchSource.makeFetchBody(a), g = fetchSource.makeFetchURL(a, f), h = fetchSource.makeFetchOptions(a, f); | ||
"production" !== process.env.NODE_ENV && c({ | ||
type: "fetchRequest", | ||
@@ -416,40 +427,40 @@ message: "A fetch request is being executed.", | ||
url: g, | ||
fetchOptions: k | ||
fetchOptions: h | ||
}, | ||
source: "fetchExchange" | ||
}); | ||
return wonka.onPush((function(c) { | ||
var e = c.data ? void 0 : c.error; | ||
"production" !== process.env.NODE_ENV && b({ | ||
type: e ? "fetchError" : "fetchSuccess", | ||
message: "A " + (e ? "failed" : "successful") + " fetch response has been returned.", | ||
return wonka.onPush((function(b) { | ||
var d = b.data ? void 0 : b.error; | ||
"production" !== process.env.NODE_ENV && c({ | ||
type: d ? "fetchError" : "fetchSuccess", | ||
message: "A " + (d ? "failed" : "successful") + " fetch response has been returned.", | ||
operation: a, | ||
data: { | ||
url: g, | ||
fetchOptions: k, | ||
value: e || c | ||
fetchOptions: h, | ||
value: d || b | ||
}, | ||
source: "fetchExchange" | ||
}); | ||
}))(wonka.takeUntil(e)(fetchSource.makeFetchSource(a, g, k))); | ||
}))(wonka.takeUntil(e)(fetchSource.makeFetchSource(a, g, h))); | ||
}))(wonka.filter(_ref$2)(d)); | ||
g = c(wonka.filter(_ref2$2)(d)); | ||
g = b(wonka.filter(_ref2$2)(d)); | ||
return wonka.merge([ a, g ]); | ||
}; | ||
}, fallbackExchange = function(a) { | ||
function c(a) { | ||
function b(a) { | ||
if ("teardown" !== a.operationName && "production" !== process.env.NODE_ENV) { | ||
var c = 'No exchange has handled operations of type "' + a.operationName + "\". Check whether you've added an exchange responsible for these operations."; | ||
"production" !== process.env.NODE_ENV && b({ | ||
var b = 'No exchange has handled operations of type "' + a.operationName + "\". Check whether you've added an exchange responsible for these operations."; | ||
"production" !== process.env.NODE_ENV && c({ | ||
type: "fallbackCatch", | ||
message: c, | ||
message: b, | ||
operation: a, | ||
source: "fallbackExchange" | ||
}); | ||
console.warn(c); | ||
console.warn(b); | ||
} | ||
} | ||
var b = a.dispatchDebug; | ||
var c = a.dispatchDebug; | ||
return function(a) { | ||
return wonka.filter(_ref$3)(wonka.tap(c)(a)); | ||
return wonka.filter(_ref$3)(wonka.tap(b)(a)); | ||
}; | ||
@@ -459,7 +470,7 @@ }, fallbackExchangeIO = fallbackExchange({ | ||
}), composeExchanges = function(a) { | ||
return function(c) { | ||
var b = c.client, d = c.dispatchDebug; | ||
return a.reduceRight((function(a, c) { | ||
return c({ | ||
client: b, | ||
return function(b) { | ||
var c = b.client, d = b.dispatchDebug; | ||
return a.reduceRight((function(a, b) { | ||
return b({ | ||
client: c, | ||
forward: a, | ||
@@ -469,7 +480,7 @@ dispatchDebug: function(a) { | ||
timestamp: Date.now(), | ||
source: c.name | ||
source: b.name | ||
}, a)); | ||
} | ||
}); | ||
}), c.forward); | ||
}), b.forward); | ||
}; | ||
@@ -479,3 +490,3 @@ }, defaultExchanges = [ dedupExchange, cacheExchange, fetchExchange ], createClient = function(a) { | ||
}, Client = function(a) { | ||
var d, f, g, k, h, b = this; | ||
var d, f, g, h, l, c = this; | ||
this.activeOperations = Object.create(null); | ||
@@ -485,22 +496,22 @@ this.queue = []; | ||
return fetchSource._extends({}, { | ||
url: b.url, | ||
fetchOptions: b.fetchOptions, | ||
fetch: b.fetch, | ||
preferGetMethod: b.preferGetMethod | ||
url: c.url, | ||
fetchOptions: c.fetchOptions, | ||
fetch: c.fetch, | ||
preferGetMethod: c.preferGetMethod | ||
}, a, { | ||
requestPolicy: (a || {}).requestPolicy || b.requestPolicy | ||
requestPolicy: (a || {}).requestPolicy || c.requestPolicy | ||
}); | ||
}; | ||
this.createRequestOperation = function(a, c, d) { | ||
this.createRequestOperation = function(a, b, d) { | ||
return { | ||
key: c.key, | ||
query: c.query, | ||
variables: c.variables, | ||
key: b.key, | ||
query: b.query, | ||
variables: b.variables, | ||
operationName: a, | ||
context: b.createOperationContext(d) | ||
context: c.createOperationContext(d) | ||
}; | ||
}; | ||
this.executeQuery = function(a, c) { | ||
a = b.createRequestOperation("query", a, c); | ||
var e = b.executeRequestOperation(a); | ||
this.executeQuery = function(a, b) { | ||
a = c.createRequestOperation("query", a, b); | ||
var e = c.executeRequestOperation(a); | ||
return (a = a.context.pollInterval) ? wonka.switchMap((function d() { | ||
@@ -510,9 +521,9 @@ return e; | ||
}; | ||
this.executeSubscription = function(a, c) { | ||
a = b.createRequestOperation("subscription", a, c); | ||
return b.executeRequestOperation(a); | ||
this.executeSubscription = function(a, b) { | ||
a = c.createRequestOperation("subscription", a, b); | ||
return c.executeRequestOperation(a); | ||
}; | ||
this.executeMutation = function(a, c) { | ||
a = b.createRequestOperation("mutation", a, c); | ||
return b.executeRequestOperation(a); | ||
this.executeMutation = function(a, b) { | ||
a = c.createRequestOperation("mutation", a, b); | ||
return c.executeRequestOperation(a); | ||
}; | ||
@@ -525,3 +536,3 @@ if ("production" !== process.env.NODE_ENV && !a.url) { | ||
f = (d = wonka.makeSubject()).next, g = d.source; | ||
this.subscribeToDebugTarget = function c(a) { | ||
this.subscribeToDebugTarget = function b(a) { | ||
return wonka.subscribe(a)(g); | ||
@@ -539,14 +550,14 @@ }; | ||
f = wonka.makeSubject(); | ||
k = f.next; | ||
h = f.next; | ||
this.operations$ = f.source; | ||
h = !1; | ||
l = !1; | ||
this.dispatchOperation = function(a) { | ||
h = !0; | ||
for (a && k(a); a = b.queue.shift(); ) { | ||
k(a); | ||
l = !0; | ||
for (a && h(a); a = c.queue.shift(); ) { | ||
h(a); | ||
} | ||
h = !1; | ||
l = !1; | ||
}; | ||
this.reexecuteOperation = function(a) { | ||
0 < (b.activeOperations[a.key] || 0) && (b.queue.push(a), h || Promise.resolve().then(b.dispatchOperation)); | ||
0 < (c.activeOperations[a.key] || 0) && (c.queue.push(a), l || Promise.resolve().then(c.dispatchOperation)); | ||
}; | ||
@@ -565,4 +576,4 @@ a = composeExchanges(void 0 !== a.exchanges ? a.exchanges : defaultExchanges); | ||
Client.prototype.onOperationStart = function(a) { | ||
var c = a.key; | ||
this.activeOperations[c] = (this.activeOperations[c] || 0) + 1; | ||
var b = a.key; | ||
this.activeOperations[b] = (this.activeOperations[b] || 0) + 1; | ||
this.dispatchOperation(a); | ||
@@ -572,4 +583,4 @@ }; | ||
Client.prototype.onOperationEnd = function(a) { | ||
var c = a.key, b = this.activeOperations[c] || 0; | ||
0 >= (this.activeOperations[c] = 0 >= b ? 0 : b - 1) && this.dispatchOperation(fetchSource._extends({}, a, { | ||
var b = a.key, c = this.activeOperations[b] || 0; | ||
0 >= (this.activeOperations[b] = 0 >= c ? 0 : c - 1) && this.dispatchOperation(fetchSource._extends({}, a, { | ||
operationName: "teardown" | ||
@@ -580,3 +591,3 @@ })); | ||
Client.prototype.executeRequestOperation = function(a) { | ||
var k, b = this, d = a.key, f = a.operationName, g = wonka.filter((function(a) { | ||
var h, c = this, d = a.key, f = a.operationName, g = wonka.filter((function(a) { | ||
return a.operation.key === d; | ||
@@ -586,38 +597,38 @@ }))(this.results$); | ||
if ("mutation" === f) { | ||
return wonka.take(1)(wonka.onStart((function c() { | ||
return b.dispatchOperation(a); | ||
return wonka.take(1)(wonka.onStart((function b() { | ||
return c.dispatchOperation(a); | ||
}))(g)); | ||
} | ||
k = wonka.filter((function(a) { | ||
h = wonka.filter((function(a) { | ||
return "teardown" === a.operationName && a.key === d; | ||
}))(this.operations$); | ||
g = wonka.onEnd((function() { | ||
b.onOperationEnd(a); | ||
c.onOperationEnd(a); | ||
}))(wonka.onStart((function() { | ||
b.onOperationStart(a); | ||
}))(wonka.takeUntil(k)(g))); | ||
c.onOperationStart(a); | ||
}))(wonka.takeUntil(h)(g))); | ||
return !1 !== a.context.suspense && this.suspense && "query" === f ? toSuspenseSource(g) : g; | ||
}; | ||
Client.prototype.query = function(a, c, b) { | ||
b && "boolean" == typeof b.suspense || (b = fetchSource._extends({}, b, { | ||
Client.prototype.query = function(a, b, c) { | ||
c && "boolean" == typeof c.suspense || (c = fetchSource._extends({}, c, { | ||
suspense: !1 | ||
})); | ||
return withPromise(this.executeQuery(createRequest(a, c), b)); | ||
return withPromise(this.executeQuery(createRequest(a, b), c)); | ||
}; | ||
Client.prototype.readQuery = function(a, c, b) { | ||
Client.prototype.readQuery = function(a, b, c) { | ||
var d = null; | ||
wonka.subscribe((function(a) { | ||
d = a; | ||
}))(this.executeQuery(createRequest(a, c), b)).unsubscribe(); | ||
}))(this.executeQuery(createRequest(a, b), c)).unsubscribe(); | ||
return d; | ||
}; | ||
Client.prototype.subscription = function(a, c, b) { | ||
return this.executeSubscription(createRequest(a, c), b); | ||
Client.prototype.subscription = function(a, b, c) { | ||
return this.executeSubscription(createRequest(a, b), c); | ||
}; | ||
Client.prototype.mutation = function(a, c, b) { | ||
return withPromise(this.executeMutation(createRequest(a, c), b)); | ||
Client.prototype.mutation = function(a, b, c) { | ||
return withPromise(this.executeMutation(createRequest(a, b), c)); | ||
}; | ||
@@ -624,0 +635,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("./9f3d5971.min.js"),t=require("wonka"),r=require("graphql/language/parser"),n=require("graphql/language/printer"),o=require("graphql/language/kinds"),i=require("graphql/language/visitor"),a=function(e,t){e|=0;for(var r=0,n=0|t.length;r<n;r++)e=(e<<5)+e+t.charCodeAt(r);return e},u=function(e){return function(e){return a(5381,e)>>>0}(e.replace(/[\s,]+/g," ").trim())},c=Object.create(null),s=function(t,o){if("string"==typeof t){var i=u(t);t=void 0!==c[i]?c[i]:r.parse(t)}else void 0!==t.__key?i=t.__key:(i=u(n.print(t)),t=void 0!==c[i]?c[i]:t);return c[i]=t,t.__key=i,{key:o?a(i,e.stringifyVariables(o))>>>0:i,query:t,variables:o||{}}},p=function(t,r){return e._extends({},t,{context:e._extends({},t.context,{meta:e._extends({},t.context.meta,r)})})},f=function(e,t){if(void 0===t&&(t=[]),Array.isArray(e))e.forEach((function(e){f(e,t)}));else if("object"==typeof e&&null!==e)for(var r in e)"__typename"===r&&"string"==typeof e[r]?t.push(e[r]):f(e[r],t);return t};function l(e,t,r){return r.indexOf(e)===t}var h=function(e){return f(e).filter(l)};function d(e){return e.kind===o.Kind.FIELD&&"__typename"===e.name.value}var m=function(e){if(e.selectionSet&&!e.selectionSet.selections.some(d))return e.selectionSet.selections.push({kind:o.Kind.FIELD,name:{kind:o.Kind.NAME,value:"__typename"}}),e},y=function(e){return i.visit(e,{Field:m,InlineFragment:m})},v=function(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(v):n&&"object"==typeof n&&"__typename"in n?v(n):n,t}),{}):e};function x(e){return e.toPromise=function(){return t.toPromise(t.take(1)(e))},e}var k=function(){},g=function(e){return"subscription"!==(e=e.operationName)&&"query"!==e};function q(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}var b=function(e){return"mutation"!==(e=e.operationName)&&"query"!==e};function O(t){return e._extends({},t,{query:y(t.query)})}function E(e){return"query"!==e.operationName||"cache-only"!==e.context.requestPolicy}function w(e){return p(e,{cacheOutcome:"miss"})}function _(e){return b(e)}var N=function(r){function n(t){var r=s.get(t.key);return r=e._extends({},r,{operation:p(t,{cacheOutcome:r?"hit":"miss"})}),"cache-and-network"===t.context.requestPolicy&&(r.stale=!0,S(c,t)),r}function o(e){return!b(e)&&d(e)}function i(e){e.operation&&"mutation"===e.operation.operationName?l(e):e.operation&&"query"===e.operation.operationName&&h(e)}function a(e){return!b(e)&&!d(e)}var u=r.forward,c=r.client,s=new Map;r=Object.create(null);var f=O,l=P(s,r,c),h=R(s,r),d=function(e){var t=e.context.requestPolicy;return"query"===e.operationName&&"network-only"!==t&&("cache-only"===t||s.has(e.key))};return function(e){var r=t.share(e);return e=t.map(n)(t.filter(o)(r)),r=t.tap(i)(u(t.filter(E)(t.map(w)(t.merge([t.map(f)(t.filter(a)(r)),t.filter(_)(r)]))))),t.merge([e,r])}},S=function(t,r){return t.reexecuteOperation(e._extends({},r,{context:e._extends({},r.context,{requestPolicy:"network-only"})}))},P=function(e,t,r,n){function o(t){if(e.has(t)){var n=e.get(t).operation;e.delete(t),S(r,n)}}return function(e){function r(e){n.add(e)}var n=new Set,i=e.operation.context.additionalTypenames;h(e.data).concat(i||[]).forEach((function(e){(e=t[e]||(t[e]=new Set)).forEach(r),e.clear()})),n.forEach(o)}},R=function(e,t){return function(r){var n=r.operation,o=r.data,i=n.context.additionalTypenames;null!=o&&(e.set(n.key,{operation:n,data:o,error:r.error}),h(r.data).concat(i||[]).forEach((function(e){(t[e]||(t[e]=new Set)).add(n.key)})))}},M=function(e){var r=e.forward,n=new Set,o=function(e){var t=e.key;return"teardown"===(e=e.operationName)?(n.delete(t),!0):"query"!==e&&"subscription"!==e||(e=n.has(t),n.add(t),!e)},i=function(e){n.delete(e.operation.key)};return function(e){return e=t.filter(o)(e),t.tap(i)(r(e))}};function j(e){return"query"===e.operationName||"mutation"===e.operationName}function C(e){return"query"!==e.operationName&&"mutation"!==e.operationName}var Q=function(r){var n=r.forward;return function(r){var o=t.share(r);r=t.mergeMap((function(r){var n=r.key,i=t.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(o),a=e.makeFetchBody(r),u=e.makeFetchURL(r,a);return a=e.makeFetchOptions(r,a),t.onPush((function(e){}))(t.takeUntil(i)(e.makeFetchSource(r,u,a)))}))(t.filter(j)(o));var i=n(t.filter(C)(o));return t.merge([r,i])}};function L(){return!1}var D=function(e){function r(e){}return function(e){return t.filter(L)(t.tap(r)(e))}},F=D(),A=function(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)}},T=[M,N,Q],$=function(r){var n=this;this.activeOperations=Object.create(null),this.queue=[],this.createOperationContext=function(t){return e._extends({},{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod},t,{requestPolicy:(t||{}).requestPolicy||n.requestPolicy})},this.createRequestOperation=function(e,t,r){return{key:t.key,query:t.query,variables:t.variables,operationName:e,context:n.createOperationContext(r)}},this.executeQuery=function(e,r){e=n.createRequestOperation("query",e,r);var o=n.executeRequestOperation(e);return(e=e.context.pollInterval)?t.switchMap((function(){return o}))(t.merge([t.fromValue(0),t.interval(e)])):o},this.executeSubscription=function(e,t){return e=n.createRequestOperation("subscription",e,t),n.executeRequestOperation(e)},this.executeMutation=function(e,t){return e=n.createRequestOperation("mutation",e,t),n.executeRequestOperation(e)};var o=k;this.url=r.url,this.fetchOptions=r.fetchOptions,this.fetch=r.fetch,this.suspense=!!r.suspense,this.requestPolicy=r.requestPolicy||"cache-first",this.preferGetMethod=!!r.preferGetMethod,this.maskTypename=!!r.maskTypename;var i=t.makeSubject(),a=i.next;this.operations$=i.source;var u=!1;this.dispatchOperation=function(e){for(u=!0,e&&a(e);e=n.queue.shift();)a(e);u=!1},this.reexecuteOperation=function(e){0<(n.activeOperations[e.key]||0)&&(n.queue.push(e),u||Promise.resolve().then(n.dispatchOperation))},r=A(void 0!==r.exchanges?r.exchanges:T),this.results$=t.share(r({client:this,dispatchDebug:o,forward:D()})(this.operations$)),t.publish(this.results$)};function I(e){return e.data=v(e.data),e}$.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},$.prototype.onOperationEnd=function(t){var r=t.key,n=this.activeOperations[r]||0;0>=(this.activeOperations[r]=0>=n?0:n-1)&&this.dispatchOperation(e._extends({},t,{operationName:"teardown"}))},$.prototype.executeRequestOperation=function(e){var r=this,n=e.key,o=e.operationName,i=t.filter((function(e){return e.operation.key===n}))(this.results$);if(this.maskTypename&&(i=t.map(I)(i)),"mutation"===o)return t.take(1)(t.onStart((function(){return r.dispatchOperation(e)}))(i));var a=t.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(this.operations$);return i=t.onEnd((function(){r.onOperationEnd(e)}))(t.onStart((function(){r.onOperationStart(e)}))(t.takeUntil(a)(i))),!1!==e.context.suspense&&this.suspense&&"query"===o?function(e){return function(r){var n=t.share(e),o=!1,i=!1;if(t.onPush((function(){return o=!0}))(t.takeWhile((function(){return!i}))(n))(r),!o)throw i=!0,r(0),t.toPromise(t.take(1)(n))}}(i):i},$.prototype.query=function(t,r,n){return n&&"boolean"==typeof n.suspense||(n=e._extends({},n,{suspense:!1})),x(this.executeQuery(s(t,r),n))},$.prototype.readQuery=function(e,r,n){var o=null;return t.subscribe((function(e){o=e}))(this.executeQuery(s(e,r),n)).unsubscribe(),o},$.prototype.subscription=function(e,t,r){return this.executeSubscription(s(e,t),r)},$.prototype.mutation=function(e,t,r){return x(this.executeMutation(s(e,t),r))},exports.CombinedError=e.CombinedError,exports.makeErrorResult=e.makeErrorResult,exports.makeResult=e.makeResult,exports.stringifyVariables=e.stringifyVariables,exports.Client=$,exports.cacheExchange=N,exports.composeExchanges=A,exports.createClient=function(e){return new $(e)},exports.createRequest=s,exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=M,exports.defaultExchanges=T,exports.fallbackExchangeIO=F,exports.fetchExchange=Q,exports.formatDocument=y,exports.maskTypename=v,exports.ssrExchange=function(r){function n(e){return!s(e)}function o(t){return function(t,r){var n=r.error;return{operation:t,data:r.data,extensions:void 0,error:n?new e.CombinedError({networkError:n.networkError?Error(n.networkError):void 0,graphQLErrors:n.graphQLErrors&&n.graphQLErrors.length?n.graphQLErrors:void 0}):void 0}}(t,c[t.key])}function i(e){return s(e)}function a(e){var t=e.operation;g(t)||(e=function(e){var t=e.error;return e={data:e.data,error:void 0},t&&(e.error={graphQLErrors:t.graphQLErrors.map(q),networkError:t.networkError?""+t.networkError:void 0}),e}(e),c[t.key]=e)}function u(e){delete c[e.operation.key]}var c={},s=function(e){return!g(e)&&void 0!==c[e.key]},p=function(e){var c=e.client,s=e.forward;return function(e){var p=r&&"boolean"==typeof r.isClient?!!r.isClient:!c.suspense,f=t.share(e);return e=s(t.filter(n)(f)),f=t.map(o)(t.filter(i)(f)),p?f=t.tap(u)(f):e=t.tap(a)(e),t.merge([e,f])}};return p.restoreData=function(t){return e._extends(c,t)},p.extractData=function(){return e._extends({},c)},r&&r.initialState&&p.restoreData(r.initialState),p},exports.subscriptionExchange=function(r){function o(e){return"subscription"===(e=e.operationName)||!!a&&("query"===e||"mutation"===e)}var i=r.forwardSubscription,a=r.enableAllOperations;return function(r){function a(e){return!p(e)}var u=r.client,c=r.forward,s=function(r){var o=i({key:r.key.toString(36),query:n.print(r.query),variables:r.variables,context:e._extends({},r.context)});return t.make((function(t){function n(t){return s(e.makeResult(r,t))}function i(t){return s(e.makeErrorResult(r,t))}function a(){f||(f=!0,"subscription"===r.operationName&&u.reexecuteOperation(e._extends({},r,{operationName:"teardown"})),p())}var c,s=t.next,p=t.complete,f=!1;return Promise.resolve().then((function(){f||(c=o.subscribe({next:n,error:i,complete:a}))})),function(){f=!0,c&&c.unsubscribe()}}))},p=o;return function(e){var r=t.share(e);e=t.mergeMap((function(e){var n=e.key,o=t.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(r);return t.takeUntil(o)(s(e))}))(t.filter(p)(r));var n=c(t.filter(a)(r));return t.merge([e,n])}}}; | ||
"use strict";var e=require("./9f3d5971.min.js"),t=require("wonka"),r=require("graphql/language/parser"),n=require("graphql/language/printer"),o=require("graphql/language/kinds"),i=require("graphql/language/visitor"),a=function(e,t){e|=0;for(var r=0,n=0|t.length;r<n;r++)e=(e<<5)+e+t.charCodeAt(r);return e},u=function(e){return function(e){return a(5381,e)>>>0}(e.replace(/[\s,]+/g," ").trim())},c=Object.create(null),s=function(t,o){if("string"==typeof t){var i=u(t);t=void 0!==c[i]?c[i]:r.parse(t)}else void 0!==t.__key?i=t.__key:(i=u(n.print(t)),t=void 0!==c[i]?c[i]:t);return c[i]=t,t.__key=i,{key:o?a(i,e.stringifyVariables(o))>>>0:i,query:t,variables:o||{}}},p=function(t,r){return e._extends({},t,{context:e._extends({},t.context,{meta:e._extends({},t.context.meta,r)})})},f=function(e,t){if(void 0===t&&(t=[]),Array.isArray(e))e.forEach((function(e){f(e,t)}));else if("object"==typeof e&&null!==e)for(var r in e)"__typename"===r&&"string"==typeof e[r]?t.push(e[r]):f(e[r],t);return t};function l(e,t,r){return r.indexOf(e)===t}var h=function(e){return f(e).filter(l)};function d(e){return e.kind===o.Kind.FIELD&&"__typename"===e.name.value}var m=function(t){if(t.selectionSet&&!t.selectionSet.selections.some(d))return e._extends({},t,{selectionSet:e._extends({},t.selectionSet,{selections:t.selectionSet.selections.concat([{kind:o.Kind.FIELD,name:{kind:o.Kind.NAME,value:"__typename"}}])})})},y=function(e){var t=i.visit(e,{Field:m,InlineFragment:m});return t.__key=e.__key,t},v=function(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(v):n&&"object"==typeof n&&"__typename"in n?v(n):n,t}),{}):e};function x(e){return e.toPromise=function(){return t.toPromise(t.take(1)(e))},e}var k=function(){},g=function(e){return"subscription"!==(e=e.operationName)&&"query"!==e};function q(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}var b=function(e){return"mutation"!==(e=e.operationName)&&"query"!==e};function O(t){return e._extends({},t,{query:y(t.query)})}function E(e){return"query"!==e.operationName||"cache-only"!==e.context.requestPolicy}function _(e){return p(e,{cacheOutcome:"miss"})}function w(e){return b(e)}var N=function(r){function n(t){var r=s.get(t.key);return r=e._extends({},r,{operation:p(t,{cacheOutcome:r?"hit":"miss"})}),"cache-and-network"===t.context.requestPolicy&&(r.stale=!0,S(c,t)),r}function o(e){return!b(e)&&d(e)}function i(e){e.operation&&"mutation"===e.operation.operationName?l(e):e.operation&&"query"===e.operation.operationName&&h(e)}function a(e){return!b(e)&&!d(e)}var u=r.forward,c=r.client,s=new Map;r=Object.create(null);var f=O,l=P(s,r,c),h=R(s,r),d=function(e){var t=e.context.requestPolicy;return"query"===e.operationName&&"network-only"!==t&&("cache-only"===t||s.has(e.key))};return function(e){var r=t.share(e);return e=t.map(n)(t.filter(o)(r)),r=t.tap(i)(u(t.filter(E)(t.map(_)(t.merge([t.map(f)(t.filter(a)(r)),t.filter(w)(r)]))))),t.merge([e,r])}},S=function(t,r){return t.reexecuteOperation(e._extends({},r,{context:e._extends({},r.context,{requestPolicy:"network-only"})}))},P=function(e,t,r,n){function o(t){if(e.has(t)){var n=e.get(t).operation;e.delete(t),S(r,n)}}return function(e){function r(e){n.add(e)}var n=new Set,i=e.operation.context.additionalTypenames;h(e.data).concat(i||[]).forEach((function(e){(e=t[e]||(t[e]=new Set)).forEach(r),e.clear()})),n.forEach(o)}},R=function(e,t){return function(r){var n=r.operation,o=r.data,i=n.context.additionalTypenames;null!=o&&(e.set(n.key,{operation:n,data:o,error:r.error}),h(r.data).concat(i||[]).forEach((function(e){(t[e]||(t[e]=new Set)).add(n.key)})))}},M=function(e){var r=e.forward,n=new Set,o=function(e){var t=e.key;return"teardown"===(e=e.operationName)?(n.delete(t),!0):"query"!==e&&"subscription"!==e||(e=n.has(t),n.add(t),!e)},i=function(e){n.delete(e.operation.key)};return function(e){return e=t.filter(o)(e),t.tap(i)(r(e))}};function j(e){return"query"===e.operationName||"mutation"===e.operationName}function C(e){return"query"!==e.operationName&&"mutation"!==e.operationName}var Q=function(r){var n=r.forward;return function(r){var o=t.share(r);r=t.mergeMap((function(r){var n=r.key,i=t.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(o),a=e.makeFetchBody(r),u=e.makeFetchURL(r,a);return a=e.makeFetchOptions(r,a),t.onPush((function(e){}))(t.takeUntil(i)(e.makeFetchSource(r,u,a)))}))(t.filter(j)(o));var i=n(t.filter(C)(o));return t.merge([r,i])}};function L(){return!1}var D=function(e){function r(e){}return function(e){return t.filter(L)(t.tap(r)(e))}},F=D(),A=function(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)}},T=[M,N,Q],$=function(r){var n=this;this.activeOperations=Object.create(null),this.queue=[],this.createOperationContext=function(t){return e._extends({},{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod},t,{requestPolicy:(t||{}).requestPolicy||n.requestPolicy})},this.createRequestOperation=function(e,t,r){return{key:t.key,query:t.query,variables:t.variables,operationName:e,context:n.createOperationContext(r)}},this.executeQuery=function(e,r){e=n.createRequestOperation("query",e,r);var o=n.executeRequestOperation(e);return(e=e.context.pollInterval)?t.switchMap((function(){return o}))(t.merge([t.fromValue(0),t.interval(e)])):o},this.executeSubscription=function(e,t){return e=n.createRequestOperation("subscription",e,t),n.executeRequestOperation(e)},this.executeMutation=function(e,t){return e=n.createRequestOperation("mutation",e,t),n.executeRequestOperation(e)};var o=k;this.url=r.url,this.fetchOptions=r.fetchOptions,this.fetch=r.fetch,this.suspense=!!r.suspense,this.requestPolicy=r.requestPolicy||"cache-first",this.preferGetMethod=!!r.preferGetMethod,this.maskTypename=!!r.maskTypename;var i=t.makeSubject(),a=i.next;this.operations$=i.source;var u=!1;this.dispatchOperation=function(e){for(u=!0,e&&a(e);e=n.queue.shift();)a(e);u=!1},this.reexecuteOperation=function(e){0<(n.activeOperations[e.key]||0)&&(n.queue.push(e),u||Promise.resolve().then(n.dispatchOperation))},r=A(void 0!==r.exchanges?r.exchanges:T),this.results$=t.share(r({client:this,dispatchDebug:o,forward:D()})(this.operations$)),t.publish(this.results$)};function I(e){return e.data=v(e.data),e}$.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},$.prototype.onOperationEnd=function(t){var r=t.key,n=this.activeOperations[r]||0;0>=(this.activeOperations[r]=0>=n?0:n-1)&&this.dispatchOperation(e._extends({},t,{operationName:"teardown"}))},$.prototype.executeRequestOperation=function(e){var r=this,n=e.key,o=e.operationName,i=t.filter((function(e){return e.operation.key===n}))(this.results$);if(this.maskTypename&&(i=t.map(I)(i)),"mutation"===o)return t.take(1)(t.onStart((function(){return r.dispatchOperation(e)}))(i));var a=t.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(this.operations$);return i=t.onEnd((function(){r.onOperationEnd(e)}))(t.onStart((function(){r.onOperationStart(e)}))(t.takeUntil(a)(i))),!1!==e.context.suspense&&this.suspense&&"query"===o?function(e){return function(r){var n=t.share(e),o=!1,i=!1;if(t.onPush((function(){return o=!0}))(t.takeWhile((function(){return!i}))(n))(r),!o)throw i=!0,r(0),t.toPromise(t.take(1)(n))}}(i):i},$.prototype.query=function(t,r,n){return n&&"boolean"==typeof n.suspense||(n=e._extends({},n,{suspense:!1})),x(this.executeQuery(s(t,r),n))},$.prototype.readQuery=function(e,r,n){var o=null;return t.subscribe((function(e){o=e}))(this.executeQuery(s(e,r),n)).unsubscribe(),o},$.prototype.subscription=function(e,t,r){return this.executeSubscription(s(e,t),r)},$.prototype.mutation=function(e,t,r){return x(this.executeMutation(s(e,t),r))},exports.CombinedError=e.CombinedError,exports.makeErrorResult=e.makeErrorResult,exports.makeResult=e.makeResult,exports.stringifyVariables=e.stringifyVariables,exports.Client=$,exports.cacheExchange=N,exports.composeExchanges=A,exports.createClient=function(e){return new $(e)},exports.createRequest=s,exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=M,exports.defaultExchanges=T,exports.fallbackExchangeIO=F,exports.fetchExchange=Q,exports.formatDocument=y,exports.maskTypename=v,exports.ssrExchange=function(r){function n(){for(var e;e=s.shift();)delete c[e]}function o(e){return!f(e)}function i(t){return function(t,r){var n=r.error;return{operation:t,data:r.data,extensions:void 0,error:n?new e.CombinedError({networkError:n.networkError?Error(n.networkError):void 0,graphQLErrors:n.graphQLErrors&&n.graphQLErrors.length?n.graphQLErrors:void 0}):void 0}}(t,c[t.key])}function a(e){return f(e)}function u(e){var t=e.operation;g(t)||(e=function(e){var t=e.error;return e={data:e.data,error:void 0},t&&(e.error={graphQLErrors:t.graphQLErrors.map(q),networkError:t.networkError?""+t.networkError:void 0}),e}(e),c[t.key]=e)}var c={},s=[],p=function(e){s.push(e.operation.key),1===s.length&&Promise.resolve().then(n)},f=function(e){return!g(e)&&void 0!==c[e.key]},l=function(e){var n=e.client,c=e.forward;return function(e){var s=r&&"boolean"==typeof r.isClient?!!r.isClient:!n.suspense,f=t.share(e);return e=c(t.filter(o)(f)),f=t.map(i)(t.filter(a)(f)),s?f=t.tap(p)(f):e=t.tap(u)(e),t.merge([e,f])}};return l.restoreData=function(t){return e._extends(c,t)},l.extractData=function(){return e._extends({},c)},r&&r.initialState&&l.restoreData(r.initialState),l},exports.subscriptionExchange=function(r){function o(e){return"subscription"===(e=e.operationName)||!!a&&("query"===e||"mutation"===e)}var i=r.forwardSubscription,a=r.enableAllOperations;return function(r){function a(e){return!p(e)}var u=r.client,c=r.forward,s=function(r){var o=i({key:r.key.toString(36),query:n.print(r.query),variables:r.variables,context:e._extends({},r.context)});return t.make((function(t){function n(t){return s(e.makeResult(r,t))}function i(t){return s(e.makeErrorResult(r,t))}function a(){f||(f=!0,"subscription"===r.operationName&&u.reexecuteOperation(e._extends({},r,{operationName:"teardown"})),p())}var c,s=t.next,p=t.complete,f=!1;return Promise.resolve().then((function(){f||(c=o.subscribe({next:n,error:i,complete:a}))})),function(){f=!0,c&&c.unsubscribe()}}))},p=o;return function(e){var r=t.share(e);e=t.mergeMap((function(e){var n=e.key,o=t.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(r);return t.takeUntil(o)(s(e))}))(t.filter(p)(r));var n=c(t.filter(a)(r));return t.merge([e,n])}}}; | ||
//# sourceMappingURL=urql-core.min.js.map |
{ | ||
"name": "@urql/core", | ||
"version": "1.12.1", | ||
"version": "1.12.2", | ||
"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
296610
2044