@urql/core
Advanced tools
Comparing version 2.0.0 to 2.1.0
# @urql/core | ||
## 2.1.0 | ||
### Minor Changes | ||
- With the "single-source behavior" the `Client` will now also avoid executing an operation if it's already active, has a previous result available, and is either run with the `cache-first` or `cache-only` request policies. This is similar to a "short circuiting" behavior, where unnecessary work is avoided by not issuing more operations into the exchange pipeline than expected, by [@kitten](https://github.com/kitten) (See [#1600](https://github.com/FormidableLabs/urql/pull/1600)) | ||
- Add consistent "single-source behavior" which makes the `Client` more forgiving when duplicate | ||
sources are used, which previously made it difficult to use the same operation across an app | ||
together with `cache-and-network`; This was a rare use-case, and it isn't recommended to overfetch | ||
data across an app, however, the new `Client` implementation of shared sources ensures that when an | ||
operation is active that the `Client` distributes the last known result for the active operation to | ||
any new usages of it (which is called “replaying stale results”) (See [#1515](https://github.com/FormidableLabs/urql/pull/1515)) | ||
### Patch Changes | ||
- Remove closure-compiler from the build step (See [#1570](https://github.com/FormidableLabs/urql/pull/1570)) | ||
- ⚠️ Fix inconsistency in generating keys for `DocumentNode`s, especially when using GraphQL Code Generator, which could cause SSR serialization to fail, by [@zenflow](https://github.com/zenflow) (See [#1509](https://github.com/FormidableLabs/urql/pull/1509)) | ||
## 2.0.0 | ||
@@ -4,0 +21,0 @@ |
@@ -24,5 +24,2 @@ import { Source, Subscription } from 'wonka'; | ||
} | ||
interface ActiveOperations { | ||
[operationKey: string]: number; | ||
} | ||
export declare const createClient: (opts: ClientOptions) => Client; | ||
@@ -44,3 +41,3 @@ /** The URQL application-wide client library. Each execute method starts a GraphQL request and returns a stream of results. */ | ||
results$: Source<OperationResult>; | ||
activeOperations: ActiveOperations; | ||
activeOperations: Map<number, Source<OperationResult>>; | ||
queue: Operation[]; | ||
@@ -50,6 +47,2 @@ constructor(opts: ClientOptions); | ||
createRequestOperation: <Data = any, Variables = object>(kind: OperationType, request: GraphQLRequest<Data, Variables>, opts?: Partial<OperationContext> | undefined) => Operation<Data, Variables>; | ||
/** Counts up the active operation key and dispatches the operation */ | ||
private onOperationStart; | ||
/** Deletes an active operation's result observable and sends a teardown signal through the exchange pipeline */ | ||
private onOperationEnd; | ||
/** Executes an Operation by sending it through the exchange pipeline It returns an observable that emits all related exchange results and keeps track of this observable's subscribers. A teardown signal will be emitted when no subscribers are listening anymore. */ | ||
@@ -65,2 +58,1 @@ executeRequestOperation<Data = any, Variables = object>(operation: Operation<Data, Variables>): Source<OperationResult<Data, Variables>>; | ||
} | ||
export {}; |
@@ -7,4 +7,4 @@ export * from './error'; | ||
export * from './maskTypename'; | ||
export * from './withPromise'; | ||
export * from './streamUtils'; | ||
export * from './operation'; | ||
export declare const noop: () => void; |
@@ -1,12 +0,10 @@ | ||
"use strict"; | ||
var e = require("./006e0cef.js"); | ||
var fetchSource = require("./408a05a6.js"); | ||
exports.makeFetchBody = e.makeFetchBody; | ||
exports.makeFetchBody = fetchSource.makeFetchBody; | ||
exports.makeFetchOptions = e.makeFetchOptions; | ||
exports.makeFetchOptions = fetchSource.makeFetchOptions; | ||
exports.makeFetchSource = e.makeFetchSource; | ||
exports.makeFetchSource = fetchSource.makeFetchSource; | ||
exports.makeFetchURL = fetchSource.makeFetchURL; | ||
exports.makeFetchURL = e.makeFetchURL; | ||
//# sourceMappingURL=urql-core-internal.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("./11660200.min.js");exports.makeFetchBody=e.makeFetchBody,exports.makeFetchOptions=e.makeFetchOptions,exports.makeFetchSource=e.makeFetchSource,exports.makeFetchURL=e.makeFetchURL; | ||
var e=require("./2dd3cb41.min.js");exports.makeFetchBody=e.makeFetchBody,exports.makeFetchOptions=e.makeFetchOptions,exports.makeFetchSource=e.makeFetchSource,exports.makeFetchURL=e.makeFetchURL; | ||
//# sourceMappingURL=urql-core-internal.min.js.map |
@@ -1,601 +0,572 @@ | ||
"use strict"; | ||
var e = require("graphql"); | ||
function _ref(a) { | ||
return a.kind === graphql.Kind.FIELD && "__typename" === a.name.value && !a.alias; | ||
} | ||
var t = require("./006e0cef.js"); | ||
function withPromise(a) { | ||
a.toPromise = function() { | ||
return wonka.toPromise(wonka.take(1)(a)); | ||
}; | ||
return a; | ||
} | ||
var r = require("wonka"); | ||
function makeOperation(a, b, c) { | ||
c || (c = b.context); | ||
return { | ||
key: b.key, | ||
query: b.query, | ||
variables: b.variables, | ||
kind: a, | ||
context: c | ||
}; | ||
function collectTypes(e, t) { | ||
if (Array.isArray(e)) { | ||
for (var r = 0; r < e.length; r++) { | ||
collectTypes(e[r], t); | ||
} | ||
} else if ("object" == typeof e && null !== e) { | ||
for (var n in e) { | ||
if ("__typename" === n && "string" == typeof e[n]) { | ||
t[e[n]] = 0; | ||
} else { | ||
collectTypes(e[n], t); | ||
} | ||
} | ||
} | ||
return t; | ||
} | ||
function _ref$1(a) { | ||
return a.path || a.extensions ? { | ||
message: a.message, | ||
path: a.path, | ||
extensions: a.extensions | ||
} : a.message; | ||
function collectTypesFromResponse(e) { | ||
return Object.keys(collectTypes(e, {})); | ||
} | ||
function _ref$2(a) { | ||
var b = makeOperation(a.kind, a); | ||
b.query = formatDocument(a.query); | ||
return b; | ||
} | ||
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; | ||
}))) { | ||
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" | ||
} | ||
} ]) | ||
}) | ||
}); | ||
} | ||
}; | ||
function _ref7(a) { | ||
return "query" !== a.kind || "cache-only" !== a.context.requestPolicy; | ||
} | ||
var n = new Map; | ||
function _ref8(a) { | ||
return addMetadata(a, { | ||
cacheOutcome: "miss" | ||
}); | ||
function formatDocument(r) { | ||
var i = t.keyDocument(r); | ||
var a = n.get(i.__key); | ||
if (!a) { | ||
(a = e.visit(i, { | ||
Field: formatNode, | ||
InlineFragment: formatNode | ||
})).__key = i.__key; | ||
n.set(i.__key, a); | ||
} | ||
return a; | ||
} | ||
function _ref10(a) { | ||
return shouldSkip$1(a); | ||
function maskTypename(e) { | ||
if (!e || "object" != typeof e) { | ||
return e; | ||
} | ||
return Object.keys(e).reduce((function(t, r) { | ||
var n = e[r]; | ||
if ("__typename" === r) { | ||
Object.defineProperty(t, "__typename", { | ||
enumerable: !1, | ||
value: n | ||
}); | ||
} else if (Array.isArray(n)) { | ||
t[r] = n.map(maskTypename); | ||
} else if (n && "object" == typeof n && "__typename" in n) { | ||
t[r] = maskTypename(n); | ||
} else { | ||
t[r] = n; | ||
} | ||
return t; | ||
}), {}); | ||
} | ||
function _ref2(a) { | ||
return console.log("[Exchange debug]: Completed operation: ", a); | ||
function withPromise(e) { | ||
e.toPromise = function() { | ||
return r.toPromise(r.take(1)(e)); | ||
}; | ||
return e; | ||
} | ||
function _ref3(a) { | ||
return console.log("[Exchange debug]: Incoming operation: ", a); | ||
function makeOperation(e, t, r) { | ||
if (!r) { | ||
r = t.context; | ||
} | ||
return { | ||
key: t.key, | ||
query: t.query, | ||
variables: t.variables, | ||
kind: e, | ||
context: r | ||
}; | ||
} | ||
function _ref$3(a) { | ||
return "query" === a.kind || "mutation" === a.kind; | ||
function addMetadata(e, r) { | ||
return makeOperation(e.kind, e, t._extends({}, e.context, { | ||
meta: t._extends({}, e.context.meta, r) | ||
})); | ||
} | ||
function _ref2$1(a) { | ||
return "query" !== a.kind && "mutation" !== a.kind; | ||
function noop() {} | ||
function applyDefinitions(r, n, i) { | ||
for (var a = 0; a < i.length; a++) { | ||
if (i[a].kind === e.Kind.FRAGMENT_DEFINITION) { | ||
var o = i[a].name.value; | ||
var s = t.stringifyDocument(i[a]); | ||
if (!r.has(o)) { | ||
r.set(o, s); | ||
n.push(i[a]); | ||
} else if ("production" !== process.env.NODE_ENV && r.get(o) !== s) { | ||
console.warn("[WARNING: Duplicate Fragment] A fragment with name `" + o + "` already exists in this document.\nWhile fragment names may not be unique across your source, each name must be unique per document."); | ||
} | ||
} else { | ||
n.push(i[a]); | ||
} | ||
} | ||
} | ||
function _ref$4() { | ||
return !1; | ||
function shouldSkip$1(e) { | ||
var t = e.kind; | ||
return "subscription" !== t && "query" !== t; | ||
} | ||
function _ref2$2(a) { | ||
a.data = maskTypename(a.data); | ||
return a; | ||
function shouldSkip(e) { | ||
var t = e.kind; | ||
return "mutation" !== t && "query" !== t; | ||
} | ||
var graphql = require("graphql"), fetchSource = require("./408a05a6.js"), wonka = require("wonka"), collectTypes = function(a, b) { | ||
if (Array.isArray(a)) { | ||
for (var c = 0; c < a.length; c++) { | ||
collectTypes(a[c], b); | ||
} | ||
} else if ("object" == typeof a && null !== a) { | ||
for (c in a) { | ||
"__typename" === c && "string" == typeof a[c] ? b[a[c]] = 0 : collectTypes(a[c], b); | ||
} | ||
function cacheExchange(e) { | ||
var n = e.forward; | ||
var i = e.client; | ||
var a = e.dispatchDebug; | ||
var o = new Map; | ||
var s = Object.create(null); | ||
function mapTypeNames(e) { | ||
var t = makeOperation(e.kind, e); | ||
t.query = formatDocument(e.query); | ||
return t; | ||
} | ||
return b; | ||
}, collectTypesFromResponse = function(a) { | ||
return Object.keys(collectTypes(a, {})); | ||
}, formatNode = function(a) { | ||
if (a.selectionSet && !a.selectionSet.selections.some(_ref)) { | ||
return fetchSource._extends({}, a, { | ||
selectionSet: fetchSource._extends({}, a.selectionSet, { | ||
selections: a.selectionSet.selections.concat([ { | ||
kind: graphql.Kind.FIELD, | ||
name: { | ||
kind: graphql.Kind.NAME, | ||
value: "__typename" | ||
} | ||
} ]) | ||
}) | ||
}); | ||
function isOperationCached(e) { | ||
var t = e.context.requestPolicy; | ||
return "query" === e.kind && "network-only" !== t && ("cache-only" === t || o.has(e.key)); | ||
} | ||
}, formattedDocs = new Map, formatDocument = function(a) { | ||
a = fetchSource.keyDocument(a); | ||
var b = formattedDocs.get(a.__key); | ||
b || ((b = graphql.visit(a, { | ||
Field: formatNode, | ||
InlineFragment: formatNode | ||
})).__key = a.__key, formattedDocs.set(a.__key, b)); | ||
return b; | ||
}, maskTypename = function(a) { | ||
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) ? b[c] = d.map(maskTypename) : b[c] = d && "object" == typeof d && "__typename" in d ? maskTypename(d) : d; | ||
return b; | ||
}), {}) : a; | ||
}, addMetadata = function(a, b) { | ||
return makeOperation(a.kind, a, fetchSource._extends({}, a.context, { | ||
meta: fetchSource._extends({}, a.context.meta, b) | ||
})); | ||
}, noop = function() {}, applyDefinitions = function(a, b, c) { | ||
var d, f, g; | ||
for (d = 0; d < c.length; d++) { | ||
if (c[d].kind === graphql.Kind.FRAGMENT_DEFINITION) { | ||
f = c[d].name.value, g = fetchSource.stringifyDocument(c[d]); | ||
a.has(f) ? "production" !== process.env.NODE_ENV && a.get(f) !== g && console.warn("[WARNING: Duplicate Fragment] A fragment with name `" + f + "` already exists in this document.\nWhile fragment names may not be unique across your source, each name must be unique per document.") : (a.set(f, g), | ||
b.push(c[d])); | ||
} else { | ||
b.push(c[d]); | ||
} | ||
} | ||
}, shouldSkip = function(a) { | ||
return "subscription" !== (a = a.kind) && "query" !== a; | ||
}, serializeResult = function(a) { | ||
var c, b = a.data; | ||
a = a.error; | ||
c = {}; | ||
void 0 !== b && (c.data = JSON.stringify(b)); | ||
a && (c.error = { | ||
graphQLErrors: a.graphQLErrors.map(_ref$1) | ||
}, a.networkError && (c.error.networkError = "" + a.networkError)); | ||
return c; | ||
}, deserializeResult = function(a, b) { | ||
var c = b.error; | ||
return { | ||
operation: a, | ||
data: (b = b.data) ? JSON.parse(b) : void 0, | ||
extensions: 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 = k.shift(); ) { | ||
delete e[a]; | ||
} | ||
} | ||
function c(a) { | ||
return !l(a); | ||
} | ||
function d(a) { | ||
return deserializeResult(a, e[a.key]); | ||
} | ||
function f(a) { | ||
return l(a); | ||
} | ||
function g(a) { | ||
var c = a.operation; | ||
shouldSkip(c) || (a = serializeResult(a), e[c.key] = a); | ||
} | ||
var e = {}, k = [], m = function(a) { | ||
k.push(a.operation.key); | ||
1 === k.length && Promise.resolve().then(b); | ||
}, l = function(a) { | ||
return !shouldSkip(a) && void 0 !== e[a.key]; | ||
}, h = function(b) { | ||
var e = b.client, h = b.forward; | ||
return function(b) { | ||
var q = a && "boolean" == typeof a.isClient ? !!a.isClient : !e.suspense, p = wonka.share(b); | ||
b = h(wonka.filter(c)(p)); | ||
p = wonka.map(d)(wonka.filter(f)(p)); | ||
q ? p = wonka.tap(m)(p) : b = wonka.tap(g)(b); | ||
return wonka.merge([ b, p ]); | ||
}; | ||
}; | ||
h.restoreData = function(a) { | ||
return fetchSource._extends(e, a); | ||
}; | ||
h.extractData = function() { | ||
return fetchSource._extends({}, e); | ||
}; | ||
a && a.initialState && h.restoreData(a.initialState); | ||
return h; | ||
}, shouldSkip$1 = function(a) { | ||
return "mutation" !== (a = a.kind) && "query" !== a; | ||
}, cacheExchange = function(a) { | ||
function b(a) { | ||
var c = m.get(a.key); | ||
"production" !== process.env.NODE_ENV && k(fetchSource._extends({}, { | ||
operation: a | ||
}, c ? { | ||
type: "cacheHit", | ||
message: "The result was successfully retried from the cache" | ||
} : { | ||
type: "cacheMiss", | ||
message: "The result could not be retrieved from the cache" | ||
})); | ||
c = fetchSource._extends({}, c, { | ||
operation: addMetadata(a, { | ||
cacheOutcome: c ? "hit" : "miss" | ||
}) | ||
}); | ||
"cache-and-network" === a.context.requestPolicy && (c.stale = !0, reexecuteOperation(e, a)); | ||
return c; | ||
} | ||
function c(a) { | ||
return !shouldSkip$1(a) && n(a); | ||
} | ||
function d(a) { | ||
function c(a) { | ||
h.add(a); | ||
} | ||
var f, h, g, d = a.operation; | ||
if (d) { | ||
f = collectTypesFromResponse(a.data).concat(d.context.additionalTypenames || []); | ||
if ("mutation" === a.operation.kind) { | ||
h = new Set; | ||
"production" !== process.env.NODE_ENV && k({ | ||
return function(e) { | ||
var u = r.share(e); | ||
var c = r.map((function(e) { | ||
var r = o.get(e.key); | ||
"production" !== process.env.NODE_ENV && a(t._extends({}, { | ||
operation: e | ||
}, r ? { | ||
type: "cacheHit", | ||
message: "The result was successfully retried from the cache" | ||
} : { | ||
type: "cacheMiss", | ||
message: "The result could not be retrieved from the cache" | ||
})); | ||
var n = t._extends({}, r, { | ||
operation: addMetadata(e, { | ||
cacheOutcome: r ? "hit" : "miss" | ||
}) | ||
}); | ||
if ("cache-and-network" === e.context.requestPolicy) { | ||
n.stale = !0; | ||
reexecuteOperation(i, e); | ||
} | ||
return n; | ||
}))(r.filter((function(e) { | ||
return !shouldSkip(e) && isOperationCached(e); | ||
}))(u)); | ||
var p = r.tap((function(e) { | ||
var t = e.operation; | ||
if (!t) { | ||
return; | ||
} | ||
var r = collectTypesFromResponse(e.data).concat(t.context.additionalTypenames || []); | ||
if ("mutation" === e.operation.kind) { | ||
var n = new Set; | ||
"production" !== process.env.NODE_ENV && a({ | ||
type: "cacheInvalidation", | ||
message: "The following typenames have been invalidated: " + f, | ||
operation: d, | ||
message: "The following typenames have been invalidated: " + r, | ||
operation: t, | ||
data: { | ||
typenames: f, | ||
response: a | ||
typenames: r, | ||
response: e | ||
}, | ||
source: "cacheExchange" | ||
}); | ||
for (a = 0; a < f.length; a++) { | ||
(g = l[g = f[a]] || (l[g] = new Set)).forEach(c); | ||
g.clear(); | ||
for (var u = 0; u < r.length; u++) { | ||
var c = r[u]; | ||
var p = s[c] || (s[c] = new Set); | ||
p.forEach((function(e) { | ||
n.add(e); | ||
})); | ||
p.clear(); | ||
} | ||
h.forEach((function b(a) { | ||
m.has(a) && (d = m.get(a).operation, m.delete(a), reexecuteOperation(e, d)); | ||
n.forEach((function(e) { | ||
if (o.has(e)) { | ||
t = o.get(e).operation; | ||
o.delete(e); | ||
reexecuteOperation(i, t); | ||
} | ||
})); | ||
} else if ("query" === d.kind && a.data) { | ||
for (m.set(d.key, a), a = 0; a < f.length; a++) { | ||
(l[g = f[a]] || (l[g] = new Set)).add(d.key); | ||
} else if ("query" === t.kind && e.data) { | ||
o.set(t.key, e); | ||
for (var f = 0; f < r.length; f++) { | ||
var l = r[f]; | ||
(s[l] || (s[l] = new Set)).add(t.key); | ||
} | ||
} | ||
} | ||
} | ||
function f(a) { | ||
return !shouldSkip$1(a) && !n(a); | ||
} | ||
var g = a.forward, e = a.client, k = a.dispatchDebug, m = new Map, l = Object.create(null), h = _ref$2, n = function(a) { | ||
var b = a.context.requestPolicy; | ||
return "query" === a.kind && "network-only" !== b && ("cache-only" === b || m.has(a.key)); | ||
}))(n(r.filter((function(e) { | ||
return "query" !== e.kind || "cache-only" !== e.context.requestPolicy; | ||
}))(r.map((function(e) { | ||
return addMetadata(e, { | ||
cacheOutcome: "miss" | ||
}); | ||
}))(r.merge([ r.map(mapTypeNames)(r.filter((function(e) { | ||
return !shouldSkip(e) && !isOperationCached(e); | ||
}))(u)), r.filter((function(e) { | ||
return shouldSkip(e); | ||
}))(u) ]))))); | ||
return r.merge([ c, p ]); | ||
}; | ||
return function(a) { | ||
var e = wonka.share(a); | ||
a = wonka.map(b)(wonka.filter(c)(e)); | ||
e = wonka.tap(d)(g(wonka.filter(_ref7)(wonka.map(_ref8)(wonka.merge([ wonka.map(h)(wonka.filter(f)(e)), wonka.filter(_ref10)(e) ]))))); | ||
return wonka.merge([ a, e ]); | ||
}; | ||
}, reexecuteOperation = function(a, b) { | ||
return a.reexecuteOperation(makeOperation(b.kind, b, fetchSource._extends({}, b.context, { | ||
} | ||
function reexecuteOperation(e, r) { | ||
return e.reexecuteOperation(makeOperation(r.kind, r, t._extends({}, r.context, { | ||
requestPolicy: "network-only" | ||
}))); | ||
}, subscriptionExchange = function(a) { | ||
function b(a) { | ||
return "subscription" === (a = a.kind) || !!d && ("query" === a || "mutation" === a); | ||
} | ||
var c = a.forwardSubscription, d = a.enableAllOperations; | ||
return function(a) { | ||
function d(a) { | ||
return !l(a); | ||
} | ||
function dedupExchange(e) { | ||
var t = e.forward; | ||
var n = e.dispatchDebug; | ||
var i = new Set; | ||
function filterIncomingOperation(e) { | ||
var t = e.key; | ||
var r = e.kind; | ||
if ("teardown" === r) { | ||
i.delete(t); | ||
return !0; | ||
} | ||
var e = a.client, f = a.forward, m = function(a) { | ||
var b = c({ | ||
key: a.key.toString(36), | ||
query: graphql.print(a.query), | ||
variables: a.variables, | ||
context: fetchSource._extends({}, a.context) | ||
if ("query" !== r && "subscription" !== r) { | ||
return !0; | ||
} | ||
var a = i.has(t); | ||
i.add(t); | ||
if (a) { | ||
"production" !== process.env.NODE_ENV && n({ | ||
type: "dedup", | ||
message: "An operation has been deduped.", | ||
operation: e, | ||
source: "dedupExchange" | ||
}); | ||
return wonka.make((function(c) { | ||
function d(c) { | ||
return g(fetchSource.makeResult(a, c)); | ||
} | ||
function m(c) { | ||
return g(fetchSource.makeErrorResult(a, c)); | ||
} | ||
function f() { | ||
h || (h = !0, "subscription" === a.kind && e.reexecuteOperation(makeOperation("teardown", a, a.context)), | ||
l()); | ||
} | ||
var k, g = c.next, l = c.complete, h = !1; | ||
Promise.resolve().then((function() { | ||
h || (k = b.subscribe({ | ||
next: d, | ||
error: m, | ||
complete: f | ||
})); | ||
})); | ||
return function() { | ||
h = !0; | ||
k && k.unsubscribe(); | ||
}; | ||
})); | ||
}, l = b; | ||
return function(a) { | ||
var b, c = wonka.share(a); | ||
a = wonka.mergeMap((function(a) { | ||
var b = a.key, d = wonka.filter((function(a) { | ||
return "teardown" === a.kind && a.key === b; | ||
}))(c); | ||
return wonka.takeUntil(d)(m(a)); | ||
}))(wonka.filter(l)(c)); | ||
b = f(wonka.filter(d)(c)); | ||
return wonka.merge([ a, b ]); | ||
}; | ||
}; | ||
}, debugExchange = function(a) { | ||
var d = a.forward; | ||
return "production" === process.env.NODE_ENV ? function b(a) { | ||
return d(a); | ||
} : function c(a) { | ||
return wonka.tap(_ref2)(d(wonka.tap(_ref3)(a))); | ||
}; | ||
}, dedupExchange = function(a) { | ||
var b = a.forward, c = a.dispatchDebug, d = new Set, f = function(a) { | ||
var b = a.key, e = a.kind; | ||
if ("teardown" === e) { | ||
return d.delete(b), !0; | ||
} | ||
if ("query" !== e && "subscription" !== e) { | ||
return !0; | ||
} | ||
e = d.has(b); | ||
d.add(b); | ||
e && "production" !== process.env.NODE_ENV && c({ | ||
type: "dedup", | ||
message: "An operation has been deduped.", | ||
operation: a, | ||
source: "dedupExchange" | ||
}); | ||
return !e; | ||
}, g = function(a) { | ||
d.delete(a.operation.key); | ||
return !a; | ||
} | ||
function afterOperationResult(e) { | ||
i.delete(e.operation.key); | ||
} | ||
return function(e) { | ||
var n = r.filter(filterIncomingOperation)(e); | ||
return r.tap(afterOperationResult)(t(n)); | ||
}; | ||
return function(a) { | ||
a = wonka.filter(f)(a); | ||
return wonka.tap(g)(b(a)); | ||
}; | ||
}, fetchExchange = function(a) { | ||
var b = a.forward, c = a.dispatchDebug; | ||
return function(a) { | ||
var g, d = wonka.share(a); | ||
a = wonka.mergeMap((function(a) { | ||
var b = a.key, e = wonka.filter((function(a) { | ||
return "teardown" === a.kind && a.key === b; | ||
}))(d), f = fetchSource.makeFetchBody(a), g = fetchSource.makeFetchURL(a, f), n = fetchSource.makeFetchOptions(a, f); | ||
"production" !== process.env.NODE_ENV && c({ | ||
} | ||
function fetchExchange(e) { | ||
var n = e.forward; | ||
var i = e.dispatchDebug; | ||
return function(e) { | ||
var a = r.share(e); | ||
var o = r.mergeMap((function(e) { | ||
var n = e.key; | ||
var o = r.filter((function(e) { | ||
return "teardown" === e.kind && e.key === n; | ||
}))(a); | ||
var s = t.makeFetchBody(e); | ||
var u = t.makeFetchURL(e, s); | ||
var c = t.makeFetchOptions(e, s); | ||
"production" !== process.env.NODE_ENV && i({ | ||
type: "fetchRequest", | ||
message: "A fetch request is being executed.", | ||
operation: a, | ||
operation: e, | ||
data: { | ||
url: g, | ||
fetchOptions: n | ||
url: u, | ||
fetchOptions: c | ||
}, | ||
source: "fetchExchange" | ||
}); | ||
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, | ||
return r.onPush((function(t) { | ||
var r = !t.data ? t.error : void 0; | ||
"production" !== process.env.NODE_ENV && i({ | ||
type: r ? "fetchError" : "fetchSuccess", | ||
message: "A " + (r ? "failed" : "successful") + " fetch response has been returned.", | ||
operation: e, | ||
data: { | ||
url: g, | ||
fetchOptions: n, | ||
value: d || b | ||
url: u, | ||
fetchOptions: c, | ||
value: r || t | ||
}, | ||
source: "fetchExchange" | ||
}); | ||
}))(wonka.takeUntil(e)(fetchSource.makeFetchSource(a, g, n))); | ||
}))(wonka.filter(_ref$3)(d)); | ||
g = b(wonka.filter(_ref2$1)(d)); | ||
return wonka.merge([ a, g ]); | ||
}))(r.takeUntil(o)(t.makeFetchSource(e, u, c))); | ||
}))(r.filter((function(e) { | ||
return "query" === e.kind || "mutation" === e.kind; | ||
}))(a)); | ||
var s = n(r.filter((function(e) { | ||
return "query" !== e.kind && "mutation" !== e.kind; | ||
}))(a)); | ||
return r.merge([ o, s ]); | ||
}; | ||
}, fallbackExchange = function(a) { | ||
function b(a) { | ||
if ("teardown" !== a.kind && "production" !== process.env.NODE_ENV) { | ||
var b = 'No exchange has handled operations of kind "' + a.kind + "\". Check whether you've added an exchange responsible for these operations."; | ||
"production" !== process.env.NODE_ENV && c({ | ||
type: "fallbackCatch", | ||
message: b, | ||
operation: a, | ||
source: "fallbackExchange" | ||
}); | ||
console.warn(b); | ||
} | ||
} | ||
var c = a.dispatchDebug; | ||
return function(a) { | ||
return wonka.filter(_ref$4)(wonka.tap(b)(a)); | ||
} | ||
function fallbackExchange(e) { | ||
var t = e.dispatchDebug; | ||
return function(e) { | ||
return r.filter((function() { | ||
return !1; | ||
}))(r.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({ | ||
type: "fallbackCatch", | ||
message: r, | ||
operation: e, | ||
source: "fallbackExchange" | ||
}); | ||
console.warn(r); | ||
} | ||
}))(e)); | ||
}; | ||
}, fallbackExchangeIO = fallbackExchange({ | ||
} | ||
var i = fallbackExchange({ | ||
dispatchDebug: noop | ||
}), composeExchanges = function(a) { | ||
return function(b) { | ||
var c = b.client, d = b.dispatchDebug; | ||
return a.reduceRight((function(a, b) { | ||
return b({ | ||
client: c, | ||
forward: a, | ||
dispatchDebug: function(a) { | ||
"production" !== process.env.NODE_ENV && d(fetchSource._extends({}, { | ||
}); | ||
function composeExchanges(e) { | ||
return function(r) { | ||
var n = r.client; | ||
var i = r.dispatchDebug; | ||
return e.reduceRight((function(e, r) { | ||
return r({ | ||
client: n, | ||
forward: e, | ||
dispatchDebug: function dispatchDebug$1(e) { | ||
"production" !== process.env.NODE_ENV && i(t._extends({}, { | ||
timestamp: Date.now(), | ||
source: b.name | ||
}, a)); | ||
source: r.name | ||
}, e)); | ||
} | ||
}); | ||
}), b.forward); | ||
}), r.forward); | ||
}; | ||
}, errorExchange = function(a) { | ||
function b(a) { | ||
var b = a.error; | ||
a = a.operation; | ||
b && c(b, a); | ||
} | ||
var c = a.onError; | ||
return function(a) { | ||
var c = a.forward; | ||
return function(a) { | ||
return wonka.tap(b)(c(a)); | ||
}; | ||
}; | ||
}, defaultExchanges = [ dedupExchange, cacheExchange, fetchExchange ], createClient = function(a) { | ||
return new Client(a); | ||
}, Client = function(a) { | ||
var d, f, g, e, k, c = this; | ||
this.activeOperations = Object.create(null); | ||
} | ||
var a = [ dedupExchange, cacheExchange, fetchExchange ]; | ||
function Client(e) { | ||
var n = this; | ||
this.activeOperations = new Map; | ||
this.queue = []; | ||
this.createOperationContext = function(a) { | ||
a || (a = {}); | ||
return fetchSource._extends({}, { | ||
url: c.url, | ||
fetchOptions: c.fetchOptions, | ||
fetch: c.fetch, | ||
preferGetMethod: c.preferGetMethod | ||
}, a, { | ||
suspense: a.suspense || !1 !== a.suspense && c.suspense, | ||
requestPolicy: a.requestPolicy || c.requestPolicy | ||
this.createOperationContext = function(e) { | ||
if (!e) { | ||
e = {}; | ||
} | ||
return t._extends({}, { | ||
url: n.url, | ||
fetchOptions: n.fetchOptions, | ||
fetch: n.fetch, | ||
preferGetMethod: n.preferGetMethod | ||
}, e, { | ||
suspense: e.suspense || !1 !== e.suspense && n.suspense, | ||
requestPolicy: e.requestPolicy || n.requestPolicy | ||
}); | ||
}; | ||
this.createRequestOperation = function(a, b, d) { | ||
return makeOperation(a, b, c.createOperationContext(d)); | ||
this.createRequestOperation = function(e, t, r) { | ||
return makeOperation(e, t, n.createOperationContext(r)); | ||
}; | ||
this.executeQuery = function(a, b) { | ||
a = c.createRequestOperation("query", a, b); | ||
return c.executeRequestOperation(a); | ||
this.executeQuery = function(e, t) { | ||
var r = n.createRequestOperation("query", e, t); | ||
return n.executeRequestOperation(r); | ||
}; | ||
this.executeSubscription = function(a, b) { | ||
a = c.createRequestOperation("subscription", a, b); | ||
return c.executeRequestOperation(a); | ||
this.executeSubscription = function(e, t) { | ||
var r = n.createRequestOperation("subscription", e, t); | ||
return n.executeRequestOperation(r); | ||
}; | ||
this.executeMutation = function(a, b) { | ||
a = c.createRequestOperation("mutation", a, b); | ||
return c.executeRequestOperation(a); | ||
this.executeMutation = function(e, t) { | ||
var r = n.createRequestOperation("mutation", e, t); | ||
return n.executeRequestOperation(r); | ||
}; | ||
if ("production" !== process.env.NODE_ENV && !a.url) { | ||
throw Error("You are creating an urql-client without a url."); | ||
if ("production" !== process.env.NODE_ENV && !e.url) { | ||
throw new Error("You are creating an urql-client without a url."); | ||
} | ||
d = noop; | ||
var i = noop; | ||
if ("production" !== process.env.NODE_ENV) { | ||
f = (d = wonka.makeSubject()).next, g = d.source; | ||
this.subscribeToDebugTarget = function b(a) { | ||
return wonka.subscribe(a)(g); | ||
var o = r.makeSubject(); | ||
var s = o.next; | ||
var u = o.source; | ||
this.subscribeToDebugTarget = function(e) { | ||
return r.subscribe(e)(u); | ||
}; | ||
d = f; | ||
i = s; | ||
} | ||
this.url = a.url; | ||
this.fetchOptions = a.fetchOptions; | ||
this.fetch = a.fetch; | ||
this.suspense = !!a.suspense; | ||
this.requestPolicy = a.requestPolicy || "cache-first"; | ||
this.preferGetMethod = !!a.preferGetMethod; | ||
this.maskTypename = !!a.maskTypename; | ||
f = wonka.makeSubject(); | ||
e = f.next; | ||
this.operations$ = f.source; | ||
k = !1; | ||
this.dispatchOperation = function(a) { | ||
k = !0; | ||
for (a && e(a); a = c.queue.shift(); ) { | ||
e(a); | ||
this.url = e.url; | ||
this.fetchOptions = e.fetchOptions; | ||
this.fetch = e.fetch; | ||
this.suspense = !!e.suspense; | ||
this.requestPolicy = e.requestPolicy || "cache-first"; | ||
this.preferGetMethod = !!e.preferGetMethod; | ||
this.maskTypename = !!e.maskTypename; | ||
var c = r.makeSubject(); | ||
var p = c.next; | ||
this.operations$ = c.source; | ||
var f = !1; | ||
this.dispatchOperation = function(e) { | ||
f = !0; | ||
if (e) { | ||
p(e); | ||
} | ||
k = !1; | ||
while (e = n.queue.shift()) { | ||
p(e); | ||
} | ||
f = !1; | ||
}; | ||
this.reexecuteOperation = function(a) { | ||
if ("mutation" === a.kind || 0 < (c.activeOperations[a.key] || 0)) { | ||
c.queue.push(a), k || Promise.resolve().then(c.dispatchOperation); | ||
this.reexecuteOperation = function(e) { | ||
if ("mutation" === e.kind || n.activeOperations.has(e.key)) { | ||
n.queue.push(e); | ||
if (!f) { | ||
Promise.resolve().then(n.dispatchOperation); | ||
} | ||
} | ||
}; | ||
a = composeExchanges(void 0 !== a.exchanges ? a.exchanges : defaultExchanges); | ||
this.results$ = wonka.share(a({ | ||
var l = composeExchanges(void 0 !== e.exchanges ? e.exchanges : a); | ||
this.results$ = r.share(l({ | ||
client: this, | ||
dispatchDebug: d, | ||
dispatchDebug: i, | ||
forward: fallbackExchange({ | ||
dispatchDebug: d | ||
dispatchDebug: i | ||
}) | ||
})(this.operations$)); | ||
wonka.publish(this.results$); | ||
}; | ||
r.publish(this.results$); | ||
} | ||
Client.prototype.onOperationStart = function(a) { | ||
var b = a.key; | ||
this.activeOperations[b] = (this.activeOperations[b] || 0) + 1; | ||
this.dispatchOperation(a); | ||
}; | ||
Client.prototype.onOperationEnd = function(a) { | ||
var b = a.key, c = this.activeOperations[b] || 0; | ||
if (0 >= (this.activeOperations[b] = 0 >= c ? 0 : c - 1)) { | ||
for (b = this.queue.length - 1; 0 <= b; b--) { | ||
this.queue[b].key === a.key && this.queue.splice(b, 1); | ||
} | ||
this.dispatchOperation(makeOperation("teardown", a, a.context)); | ||
Client.prototype.executeRequestOperation = function executeRequestOperation(e) { | ||
var n = this; | ||
var i = this.activeOperations.get(e.key); | ||
if (i) { | ||
return i; | ||
} | ||
}; | ||
Client.prototype.executeRequestOperation = function(a) { | ||
var f, g, c = this, d = wonka.filter((function(b) { | ||
return b.operation.key === a.key; | ||
var a = r.filter((function(t) { | ||
return t.operation.key === e.key; | ||
}))(this.results$); | ||
this.maskTypename && (d = wonka.map(_ref2$2)(d)); | ||
if ("mutation" === a.kind) { | ||
return wonka.take(1)(wonka.onStart((function b() { | ||
return c.dispatchOperation(a); | ||
}))(d)); | ||
if (this.maskTypename) { | ||
a = r.map((function(e) { | ||
return t._extends({}, e, { | ||
data: maskTypename(e.data) | ||
}); | ||
}))(a); | ||
} | ||
f = wonka.filter((function(b) { | ||
return "teardown" === b.kind && b.key === a.key; | ||
}))(this.operations$), g = wonka.filter((function(b) { | ||
return b.kind === a.kind && b.key === a.key && "cache-only" !== b.context.requestPolicy; | ||
if ("mutation" === e.kind) { | ||
return r.take(1)(r.onStart((function() { | ||
return n.dispatchOperation(e); | ||
}))(a)); | ||
} | ||
var o = r.filter((function(t) { | ||
return "teardown" === t.kind && t.key === e.key; | ||
}))(this.operations$); | ||
return wonka.onEnd((function() { | ||
c.onOperationEnd(a); | ||
}))(wonka.onStart((function() { | ||
c.onOperationStart(a); | ||
}))(wonka.switchMap((function(a) { | ||
return a.stale ? wonka.fromValue(a) : wonka.merge([ wonka.fromValue(a), wonka.map((function() { | ||
return fetchSource._extends({}, a, { | ||
var s = 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); | ||
}))(this.operations$)); | ||
a = r.onEnd((function() { | ||
n.activeOperations.delete(e.key); | ||
for (var t = n.queue.length - 1; t >= 0; t--) { | ||
if (n.queue[t].key === e.key) { | ||
n.queue.splice(t, 1); | ||
} | ||
} | ||
n.dispatchOperation(makeOperation("teardown", e, e.context)); | ||
}))(r.switchMap((function(e) { | ||
if (e.stale) { | ||
return r.fromValue(e); | ||
} | ||
return r.merge([ r.fromValue(e), r.map((function() { | ||
return t._extends({}, e, { | ||
stale: !0 | ||
}); | ||
}))(wonka.take(1)(g)) ]); | ||
}))(wonka.takeUntil(f)(d)))); | ||
}))(s) ]); | ||
}))(r.takeUntil(o)(a))); | ||
if ("subscription" === e.kind) { | ||
i = r.share(r.onStart((function() { | ||
n.activeOperations.set(e.key, i); | ||
n.dispatchOperation(e); | ||
}))(a)); | ||
} else { | ||
i = function replayOnStart(e, n) { | ||
return function(i) { | ||
var a; | ||
var o = r.share(r.onPush((function(e) { | ||
a = e; | ||
}))(r.onEnd((function() { | ||
a = void 0; | ||
}))(i))); | ||
return r.make((function(i) { | ||
var s = a; | ||
return r.subscribe(i.next)(r.onStart((function() { | ||
if ("pre" === e) { | ||
n(); | ||
} | ||
if (void 0 !== s && s === a) { | ||
i.next("pre" === e ? t._extends({}, s, { | ||
stale: !0 | ||
}) : s); | ||
} else if ("post" === e) { | ||
n(); | ||
} | ||
}))(r.onEnd(i.complete)(o))).unsubscribe; | ||
})); | ||
}; | ||
}("cache-and-network" === e.context.requestPolicy || "network-only" === e.context.requestPolicy ? "pre" : "post", (function() { | ||
n.activeOperations.set(e.key, i); | ||
n.dispatchOperation(e); | ||
}))(a); | ||
} | ||
return i; | ||
}; | ||
Client.prototype.query = function(a, b, c) { | ||
c && "boolean" == typeof c.suspense || (c = fetchSource._extends({}, c, { | ||
suspense: !1 | ||
})); | ||
return withPromise(this.executeQuery(fetchSource.createRequest(a, b), c)); | ||
Client.prototype.query = function query(e, r, n) { | ||
if (!n || "boolean" != typeof n.suspense) { | ||
n = t._extends({}, n, { | ||
suspense: !1 | ||
}); | ||
} | ||
return withPromise(this.executeQuery(t.createRequest(e, r), n)); | ||
}; | ||
Client.prototype.readQuery = function(a, b, c) { | ||
var d = null; | ||
wonka.subscribe((function(a) { | ||
d = a; | ||
}))(this.executeQuery(fetchSource.createRequest(a, b), c)).unsubscribe(); | ||
return d; | ||
Client.prototype.readQuery = function readQuery(e, t, n) { | ||
var i = null; | ||
r.subscribe((function(e) { | ||
i = e; | ||
}))(this.query(e, t, n)).unsubscribe(); | ||
return i; | ||
}; | ||
Client.prototype.subscription = function(a, b, c) { | ||
return this.executeSubscription(fetchSource.createRequest(a, b), c); | ||
Client.prototype.subscription = function subscription(e, r, n) { | ||
return this.executeSubscription(t.createRequest(e, r), n); | ||
}; | ||
Client.prototype.mutation = function(a, b, c) { | ||
return withPromise(this.executeMutation(fetchSource.createRequest(a, b), c)); | ||
Client.prototype.mutation = function mutation(e, r, n) { | ||
return withPromise(this.executeMutation(t.createRequest(e, r), n)); | ||
}; | ||
exports.CombinedError = fetchSource.CombinedError; | ||
exports.CombinedError = t.CombinedError; | ||
exports.createRequest = fetchSource.createRequest; | ||
exports.createRequest = t.createRequest; | ||
exports.getOperationName = fetchSource.getOperationName; | ||
exports.getOperationName = t.getOperationName; | ||
exports.makeErrorResult = fetchSource.makeErrorResult; | ||
exports.makeErrorResult = t.makeErrorResult; | ||
exports.makeResult = fetchSource.makeResult; | ||
exports.makeResult = t.makeResult; | ||
exports.stringifyVariables = fetchSource.stringifyVariables; | ||
exports.stringifyVariables = t.stringifyVariables; | ||
@@ -608,13 +579,43 @@ exports.Client = Client; | ||
exports.createClient = createClient; | ||
exports.createClient = function createClient(e) { | ||
return new Client(e); | ||
}; | ||
exports.debugExchange = debugExchange; | ||
exports.debugExchange = function debugExchange(e) { | ||
var t = e.forward; | ||
if ("production" === process.env.NODE_ENV) { | ||
return function(e) { | ||
return t(e); | ||
}; | ||
} else { | ||
return function(e) { | ||
return r.tap((function(e) { | ||
return console.log("[Exchange debug]: Completed operation: ", e); | ||
}))(t(r.tap((function(e) { | ||
return console.log("[Exchange debug]: Incoming operation: ", e); | ||
}))(e))); | ||
}; | ||
} | ||
}; | ||
exports.dedupExchange = dedupExchange; | ||
exports.defaultExchanges = defaultExchanges; | ||
exports.defaultExchanges = a; | ||
exports.errorExchange = errorExchange; | ||
exports.errorExchange = function errorExchange(e) { | ||
var t = 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); | ||
} | ||
}))(n(e)); | ||
}; | ||
}; | ||
}; | ||
exports.fallbackExchangeIO = fallbackExchangeIO; | ||
exports.fallbackExchangeIO = i; | ||
@@ -626,13 +627,21 @@ exports.fetchExchange = fetchExchange; | ||
exports.gql = function gql() { | ||
var a, b, c, d, f, g, e; | ||
for (a = arguments, b = new Map, c = [], d = [], f = Array.isArray(arguments[0]) ? arguments[0][0] : arguments[0] || "", | ||
g = 1; g < arguments.length; g++) { | ||
(e = a[g]) && e.definitions ? d.push.apply(d, e.definitions) : f += e; | ||
f += a[0][g]; | ||
var r = arguments; | ||
var n = new Map; | ||
var i = []; | ||
var a = []; | ||
var o = Array.isArray(arguments[0]) ? arguments[0][0] : arguments[0] || ""; | ||
for (var s = 1; s < arguments.length; s++) { | ||
var u = r[s]; | ||
if (u && u.definitions) { | ||
a.push.apply(a, u.definitions); | ||
} else { | ||
o += u; | ||
} | ||
o += r[0][s]; | ||
} | ||
applyDefinitions(b, c, fetchSource.keyDocument(f).definitions); | ||
applyDefinitions(b, c, d); | ||
return fetchSource.keyDocument({ | ||
kind: graphql.Kind.DOCUMENT, | ||
definitions: c | ||
applyDefinitions(n, i, t.keyDocument(o).definitions); | ||
applyDefinitions(n, i, a); | ||
return t.keyDocument({ | ||
kind: e.Kind.DOCUMENT, | ||
definitions: i | ||
}); | ||
@@ -645,5 +654,163 @@ }; | ||
exports.ssrExchange = ssrExchange; | ||
exports.ssrExchange = function ssrExchange(e) { | ||
var n = {}; | ||
var i = []; | ||
function invalidate(e) { | ||
i.push(e.operation.key); | ||
if (1 === i.length) { | ||
Promise.resolve().then((function() { | ||
var e; | ||
while (e = i.shift()) { | ||
delete n[e]; | ||
} | ||
})); | ||
} | ||
} | ||
function isCached(e) { | ||
return !shouldSkip$1(e) && void 0 !== n[e.key]; | ||
} | ||
var ssr = function(i) { | ||
var a = i.client; | ||
var o = i.forward; | ||
return function(i) { | ||
var s = e && "boolean" == typeof e.isClient ? !!e.isClient : !a.suspense; | ||
var u = r.share(i); | ||
var c = o(r.filter((function(e) { | ||
return !isCached(e); | ||
}))(u)); | ||
var p = r.map((function(e) { | ||
return function deserializeResult(e, r) { | ||
var n = r.error; | ||
var i = r.data; | ||
return { | ||
operation: e, | ||
data: i ? JSON.parse(i) : void 0, | ||
extensions: void 0, | ||
error: n ? new t.CombinedError({ | ||
networkError: n.networkError ? new Error(n.networkError) : void 0, | ||
graphQLErrors: n.graphQLErrors && n.graphQLErrors.length ? n.graphQLErrors : void 0 | ||
}) : void 0 | ||
}; | ||
}(e, n[e.key]); | ||
}))(r.filter((function(e) { | ||
return isCached(e); | ||
}))(u)); | ||
if (!s) { | ||
c = 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; | ||
var n = {}; | ||
if (void 0 !== t) { | ||
n.data = JSON.stringify(t); | ||
} | ||
if (r) { | ||
n.error = { | ||
graphQLErrors: r.graphQLErrors.map((function(e) { | ||
if (!e.path && !e.extensions) { | ||
return e.message; | ||
} | ||
return { | ||
message: e.message, | ||
path: e.path, | ||
extensions: e.extensions | ||
}; | ||
})) | ||
}; | ||
if (r.networkError) { | ||
n.error.networkError = "" + r.networkError; | ||
} | ||
} | ||
return n; | ||
}(e); | ||
n[t.key] = r; | ||
} | ||
}))(c); | ||
} else { | ||
p = r.tap(invalidate)(p); | ||
} | ||
return r.merge([ c, p ]); | ||
}; | ||
}; | ||
ssr.restoreData = function(e) { | ||
return t._extends(n, e); | ||
}; | ||
ssr.extractData = function() { | ||
return t._extends({}, n); | ||
}; | ||
if (e && e.initialState) { | ||
ssr.restoreData(e.initialState); | ||
} | ||
return ssr; | ||
}; | ||
exports.subscriptionExchange = subscriptionExchange; | ||
exports.subscriptionExchange = function subscriptionExchange(n) { | ||
var i = n.forwardSubscription; | ||
var a = n.enableAllOperations; | ||
return function(n) { | ||
var o = n.client; | ||
var s = n.forward; | ||
function isSubscriptionOperation(e) { | ||
var t = e.kind; | ||
return "subscription" === t || !!a && ("query" === t || "mutation" === t); | ||
} | ||
return function(n) { | ||
var a = r.share(n); | ||
var u = r.mergeMap((function(n) { | ||
var s = n.key; | ||
var u = r.filter((function(e) { | ||
return "teardown" === e.kind && e.key === s; | ||
}))(a); | ||
return r.takeUntil(u)(function createSubscriptionSource(n) { | ||
var a = i({ | ||
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 = e.next; | ||
var i = e.complete; | ||
var s = !1; | ||
var u; | ||
Promise.resolve().then((function() { | ||
if (s) { | ||
return; | ||
} | ||
u = a.subscribe({ | ||
next: function(e) { | ||
return r(t.makeResult(n, e)); | ||
}, | ||
error: function(e) { | ||
return r(t.makeErrorResult(n, e)); | ||
}, | ||
complete: function() { | ||
if (!s) { | ||
s = !0; | ||
if ("subscription" === n.kind) { | ||
o.reexecuteOperation(makeOperation("teardown", n, n.context)); | ||
} | ||
i(); | ||
} | ||
} | ||
}); | ||
})); | ||
return function() { | ||
s = !0; | ||
if (u) { | ||
u.unsubscribe(); | ||
} | ||
}; | ||
})); | ||
}(n)); | ||
}))(r.filter(isSubscriptionOperation)(a)); | ||
var c = s(r.filter((function(e) { | ||
return !isSubscriptionOperation(e); | ||
}))(a)); | ||
return r.merge([ u, c ]); | ||
}; | ||
}; | ||
}; | ||
//# sourceMappingURL=urql-core.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var e=require("graphql"),t=require("./11660200.min.js"),r=require("wonka"),n=function(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(r in e)"__typename"===r&&"string"==typeof e[r]?t[e[r]]=0:n(e[r],t);return t};function i(t){return t.kind===e.Kind.FIELD&&"__typename"===t.name.value&&!t.alias}var o=function(r){if(r.selectionSet&&!r.selectionSet.selections.some(i))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,a=function(r){r=t.keyDocument(r);var n=u.get(r.__key);return n||((n=e.visit(r,{Field:o,InlineFragment:o})).__key=r.__key,u.set(r.__key,n)),n},s=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(s):n&&"object"==typeof n&&"__typename"in n?s(n):n,t}),{}):e};function c(e){return e.toPromise=function(){return r.toPromise(r.take(1)(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}}var p=function(e,r){return f(e.kind,e,t._extends({},e.context,{meta:t._extends({},e.context.meta,r)}))},l=function(){},h=function(r,n,i){for(var o=0;o<i.length;o++)if(i[o].kind===e.Kind.FRAGMENT_DEFINITION){var u=i[o].name.value,a=t.stringifyDocument(i[o]);r.has(u)||(r.set(u,a),n.push(i[o]))}else n.push(i[o])},d=function(e){return"subscription"!==(e=e.kind)&&"query"!==e};function y(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}var k=function(e){return"mutation"!==(e=e.kind)&&"query"!==e};function m(e){var t=f(e.kind,e);return t.query=a(e.query),t}function v(e){return"query"!==e.kind||"cache-only"!==e.context.requestPolicy}function x(e){return p(e,{cacheOutcome:"miss"})}function g(e){return k(e)}var q=function(e){function i(e){var r=f.get(e.key);return r=t._extends({},r,{operation:p(e,{cacheOutcome:r?"hit":"miss"})}),"cache-and-network"===e.context.requestPolicy&&(r.stale=!0,O(c,e)),r}function o(e){return!k(e)&&d(e)}function u(e){function t(e){o.add(e)}var r=e.operation;if(r){var i=function(e){return Object.keys(n(e,{}))}(e.data).concat(r.context.additionalTypenames||[]);if("mutation"===e.operation.kind){var o=new Set;for(e=0;e<i.length;e++){var u=i[e];(u=l[u]||(l[u]=new Set)).forEach(t),u.clear()}o.forEach((function(e){f.has(e)&&(r=f.get(e).operation,f.delete(e),O(c,r))}))}else if("query"===r.kind&&e.data)for(f.set(r.key,e),e=0;e<i.length;e++)(l[u=i[e]]||(l[u]=new Set)).add(r.key)}}function a(e){return!k(e)&&!d(e)}var s=e.forward,c=e.client,f=new Map,l=Object.create(null),h=m,d=function(e){var t=e.context.requestPolicy;return"query"===e.kind&&"network-only"!==t&&("cache-only"===t||f.has(e.key))};return function(e){var t=r.share(e);return e=r.map(i)(r.filter(o)(t)),t=r.tap(u)(s(r.filter(v)(r.map(x)(r.merge([r.map(h)(r.filter(a)(t)),r.filter(g)(t)]))))),r.merge([e,t])}},O=function(e,r){return e.reexecuteOperation(f(r.kind,r,t._extends({},r.context,{requestPolicy:"network-only"})))},b=function(e){var t=e.forward,n=new Set,i=function(e){var t=e.key;return"teardown"===(e=e.kind)?(n.delete(t),!0):"query"!==e&&"subscription"!==e||(e=n.has(t),n.add(t),!e)},o=function(e){n.delete(e.operation.key)};return function(e){return e=r.filter(i)(e),r.tap(o)(t(e))}};function E(e){return"query"===e.kind||"mutation"===e.kind}function w(e){return"query"!==e.kind&&"mutation"!==e.kind}var _=function(e){var n=e.forward;return function(e){var i=r.share(e);e=r.mergeMap((function(e){var n=e.key,o=r.filter((function(e){return"teardown"===e.kind&&e.key===n}))(i),u=t.makeFetchBody(e),a=t.makeFetchURL(e,u);return u=t.makeFetchOptions(e,u),r.onPush((function(e){}))(r.takeUntil(o)(t.makeFetchSource(e,a,u)))}))(r.filter(E)(i));var o=n(r.filter(w)(i));return r.merge([e,o])}};function R(){return!1}var S=function(e){function t(e){}return function(e){return r.filter(R)(r.tap(t)(e))}},P=S(),M=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)}},D=[b,q,_],j=function(e){var n=this;this.activeOperations=Object.create(null),this.queue=[],this.createOperationContext=function(e){return e||(e={}),t._extends({},{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod},e,{suspense:e.suspense||!1!==e.suspense&&n.suspense,requestPolicy:e.requestPolicy||n.requestPolicy})},this.createRequestOperation=function(e,t,r){return f(e,t,n.createOperationContext(r))},this.executeQuery=function(e,t){return e=n.createRequestOperation("query",e,t),n.executeRequestOperation(e)},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 i=l;this.url=e.url,this.fetchOptions=e.fetchOptions,this.fetch=e.fetch,this.suspense=!!e.suspense,this.requestPolicy=e.requestPolicy||"cache-first",this.preferGetMethod=!!e.preferGetMethod,this.maskTypename=!!e.maskTypename;var o=r.makeSubject(),u=o.next;this.operations$=o.source;var a=!1;this.dispatchOperation=function(e){for(a=!0,e&&u(e);e=n.queue.shift();)u(e);a=!1},this.reexecuteOperation=function(e){("mutation"===e.kind||0<(n.activeOperations[e.key]||0))&&(n.queue.push(e),a||Promise.resolve().then(n.dispatchOperation))},e=M(void 0!==e.exchanges?e.exchanges:D),this.results$=r.share(e({client:this,dispatchDebug:i,forward:S()})(this.operations$)),r.publish(this.results$)};function C(e){return e.data=s(e.data),e}j.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},j.prototype.onOperationEnd=function(e){var t=e.key,r=this.activeOperations[t]||0;if(0>=(this.activeOperations[t]=0>=r?0:r-1)){for(t=this.queue.length-1;0<=t;t--)this.queue[t].key===e.key&&this.queue.splice(t,1);this.dispatchOperation(f("teardown",e,e.context))}},j.prototype.executeRequestOperation=function(e){var n=this,i=r.filter((function(t){return t.operation.key===e.key}))(this.results$);if(this.maskTypename&&(i=r.map(C)(i)),"mutation"===e.kind)return r.take(1)(r.onStart((function(){return n.dispatchOperation(e)}))(i));var o=r.filter((function(t){return"teardown"===t.kind&&t.key===e.key}))(this.operations$),u=r.filter((function(t){return t.kind===e.kind&&t.key===e.key&&"cache-only"!==t.context.requestPolicy}))(this.operations$);return r.onEnd((function(){n.onOperationEnd(e)}))(r.onStart((function(){n.onOperationStart(e)}))(r.switchMap((function(e){return e.stale?r.fromValue(e):r.merge([r.fromValue(e),r.map((function(){return t._extends({},e,{stale:!0})}))(r.take(1)(u))])}))(r.takeUntil(o)(i))))},j.prototype.query=function(e,r,n){return n&&"boolean"==typeof n.suspense||(n=t._extends({},n,{suspense:!1})),c(this.executeQuery(t.createRequest(e,r),n))},j.prototype.readQuery=function(e,n,i){var o=null;return r.subscribe((function(e){o=e}))(this.executeQuery(t.createRequest(e,n),i)).unsubscribe(),o},j.prototype.subscription=function(e,r,n){return this.executeSubscription(t.createRequest(e,r),n)},j.prototype.mutation=function(e,r,n){return c(this.executeMutation(t.createRequest(e,r),n))},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=j,exports.cacheExchange=q,exports.composeExchanges=M,exports.createClient=function(e){return new j(e)},exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=b,exports.defaultExchanges=D,exports.errorExchange=function(e){function t(e){var t=e.error;e=e.operation,t&&n(t,e)}var n=e.onError;return function(e){var n=e.forward;return function(e){return r.tap(t)(n(e))}}},exports.fallbackExchangeIO=P,exports.fetchExchange=_,exports.formatDocument=a,exports.gql=function(){for(var r=arguments,n=new Map,i=[],o=[],u=Array.isArray(arguments[0])?arguments[0][0]:arguments[0]||"",a=1;a<arguments.length;a++){var s=r[a];s&&s.definitions?o.push.apply(o,s.definitions):u+=s,u+=r[0][a]}return h(n,i,t.keyDocument(u).definitions),h(n,i,o),t.keyDocument({kind:e.Kind.DOCUMENT,definitions:i})},exports.makeOperation=f,exports.maskTypename=s,exports.ssrExchange=function(e){function n(){for(var e;e=c.shift();)delete s[e]}function i(e){return!p(e)}function o(e){return function(e,r){var n=r.error;return{operation:e,data:(r=r.data)?JSON.parse(r):void 0,extensions:void 0,error:n?new t.CombinedError({networkError:n.networkError?Error(n.networkError):void 0,graphQLErrors:n.graphQLErrors&&n.graphQLErrors.length?n.graphQLErrors:void 0}):void 0}}(e,s[e.key])}function u(e){return p(e)}function a(e){var t=e.operation;d(t)||(e=function(e){var t=e.data;e=e.error;var r={};return void 0!==t&&(r.data=JSON.stringify(t)),e&&(r.error={graphQLErrors:e.graphQLErrors.map(y)},e.networkError&&(r.error.networkError=""+e.networkError)),r}(e),s[t.key]=e)}var s={},c=[],f=function(e){c.push(e.operation.key),1===c.length&&Promise.resolve().then(n)},p=function(e){return!d(e)&&void 0!==s[e.key]},l=function(t){var n=t.client,s=t.forward;return function(t){var c=e&&"boolean"==typeof e.isClient?!!e.isClient:!n.suspense,p=r.share(t);return t=s(r.filter(i)(p)),p=r.map(o)(r.filter(u)(p)),c?p=r.tap(f)(p):t=r.tap(a)(t),r.merge([t,p])}};return l.restoreData=function(e){return t._extends(s,e)},l.extractData=function(){return t._extends({},s)},e&&e.initialState&&l.restoreData(e.initialState),l},exports.subscriptionExchange=function(n){function i(e){return"subscription"===(e=e.kind)||!!u&&("query"===e||"mutation"===e)}var o=n.forwardSubscription,u=n.enableAllOperations;return function(n){function u(e){return!p(e)}var a=n.client,s=n.forward,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){function r(e){return c(t.makeResult(n,e))}function o(e){return c(t.makeErrorResult(n,e))}function u(){l||(l=!0,"subscription"===n.kind&&a.reexecuteOperation(f("teardown",n,n.context)),p())}var s,c=e.next,p=e.complete,l=!1;return Promise.resolve().then((function(){l||(s=i.subscribe({next:r,error:o,complete:u}))})),function(){l=!0,s&&s.unsubscribe()}}))},p=i;return function(e){var t=r.share(e);e=r.mergeMap((function(e){var n=e.key,i=r.filter((function(e){return"teardown"===e.kind&&e.key===n}))(t);return r.takeUntil(i)(c(e))}))(r.filter(p)(t));var n=s(r.filter(u)(t));return r.merge([e,n])}}}; | ||
var e=require("graphql"),t=require("./2dd3cb41.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 i in e)"__typename"===i&&"string"==typeof e[i]?t[e[i]]=0:n(e[i],t);return t}function i(e){return Object.keys(n(e,{}))}var o=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),i=u.get(n.__key);return i||((i=e.visit(n,{Field:o,InlineFragment:o})).__key=n.__key,u.set(n.__key,i)),i}function s(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(s):n&&"object"==typeof n&&"__typename"in n?s(n):n,t}),{}):e}function c(e){return e.toPromise=function(){return r.toPromise(r.take(1)(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,i){for(var o=0;o<i.length;o++)if(i[o].kind===e.Kind.FRAGMENT_DEFINITION){var u=i[o].name.value,a=t.stringifyDocument(i[o]);r.has(u)||(r.set(u,a),n.push(i[o]))}else n.push(i[o])}function h(e){var t=e.kind;return"subscription"!==t&&"query"!==t}function y(e){var t=e.kind;return"mutation"!==t&&"query"!==t}function k(e){var n=e.forward,o=e.client,u=new Map,s=Object.create(null);function c(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,v(o,e)),n}))(r.filter((function(e){return!y(e)&&l(e)}))(a)),d=r.tap((function(e){var t=e.operation;if(t){var r=i(e.data).concat(t.context.additionalTypenames||[]);if("mutation"===e.operation.kind){for(var n=new Set,a=0;a<r.length;a++){var c=r[a],f=s[c]||(s[c]=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),v(o,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];(s[l]||(s[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(c)(r.filter((function(e){return!y(e)&&!l(e)}))(a)),r.filter((function(e){return y(e)}))(a)])))));return r.merge([f,d])}}function v(e,r){return e.reexecuteOperation(f(r.kind,r,t._extends({},r.context,{requestPolicy:"network-only"})))}function m(e){var t=e.forward,n=new Set;function i(e){var t=e.key,r=e.kind;if("teardown"===r)return n.delete(t),!0;if("query"!==r&&"subscription"!==r)return!0;var i=n.has(t);return n.add(t),!i}function o(e){n.delete(e.operation.key)}return function(e){var n=r.filter(i)(e);return r.tap(o)(t(n))}}function x(e){var n=e.forward;return function(e){var i=r.share(e),o=r.mergeMap((function(e){var n=e.key,o=r.filter((function(e){return"teardown"===e.kind&&e.key===n}))(i),u=t.makeFetchBody(e),a=t.makeFetchURL(e,u),s=t.makeFetchOptions(e,u);return r.onPush((function(e){}))(r.takeUntil(o)(t.makeFetchSource(e,a,s)))}))(r.filter((function(e){return"query"===e.kind||"mutation"===e.kind}))(i)),u=n(r.filter((function(e){return"query"!==e.kind&&"mutation"!==e.kind}))(i));return r.merge([o,u])}}function g(e){return function(e){return r.filter((function(){return!1}))(r.tap((function(e){}))(e))}}var q=g();function b(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 O=[m,k,x];function w(e){var n=this;this.activeOperations=new Map,this.queue=[],this.createOperationContext=function(e){return e||(e={}),t._extends({},{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod},e,{suspense:e.suspense||!1!==e.suspense&&n.suspense,requestPolicy:e.requestPolicy||n.requestPolicy})},this.createRequestOperation=function(e,t,r){return f(e,t,n.createOperationContext(r))},this.executeQuery=function(e,t){var r=n.createRequestOperation("query",e,t);return n.executeRequestOperation(r)},this.executeSubscription=function(e,t){var r=n.createRequestOperation("subscription",e,t);return n.executeRequestOperation(r)},this.executeMutation=function(e,t){var r=n.createRequestOperation("mutation",e,t);return n.executeRequestOperation(r)};var i=l;this.url=e.url,this.fetchOptions=e.fetchOptions,this.fetch=e.fetch,this.suspense=!!e.suspense,this.requestPolicy=e.requestPolicy||"cache-first",this.preferGetMethod=!!e.preferGetMethod,this.maskTypename=!!e.maskTypename;var o=r.makeSubject(),u=o.next;this.operations$=o.source;var a=!1;this.dispatchOperation=function(e){for(a=!0,e&&u(e);e=n.queue.shift();)u(e);a=!1},this.reexecuteOperation=function(e){("mutation"===e.kind||n.activeOperations.has(e.key))&&(n.queue.push(e),a||Promise.resolve().then(n.dispatchOperation))};var s=b(void 0!==e.exchanges?e.exchanges:O);this.results$=r.share(s({client:this,dispatchDebug:i,forward:g()})(this.operations$)),r.publish(this.results$)}w.prototype.executeRequestOperation=function(e){var n=this,i=this.activeOperations.get(e.key);if(i)return i;var o=r.filter((function(t){return t.operation.key===e.key}))(this.results$);if(this.maskTypename&&(o=r.map((function(e){return t._extends({},e,{data:s(e.data)})}))(o)),"mutation"===e.kind)return r.take(1)(r.onStart((function(){return n.dispatchOperation(e)}))(o));var u,a,c=r.filter((function(t){return"teardown"===t.kind&&t.key===e.key}))(this.operations$),p=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)}))(this.operations$));return o=r.onEnd((function(){n.activeOperations.delete(e.key);for(var t=n.queue.length-1;t>=0;t--)n.queue[t].key===e.key&&n.queue.splice(t,1);n.dispatchOperation(f("teardown",e,e.context))}))(r.switchMap((function(e){return e.stale?r.fromValue(e):r.merge([r.fromValue(e),r.map((function(){return t._extends({},e,{stale:!0})}))(p)])}))(r.takeUntil(c)(o))),i="subscription"===e.kind?r.share(r.onStart((function(){n.activeOperations.set(e.key,i),n.dispatchOperation(e)}))(o)):(u="cache-and-network"===e.context.requestPolicy||"network-only"===e.context.requestPolicy?"pre":"post",a=function(){n.activeOperations.set(e.key,i),n.dispatchOperation(e)},function(e){var n,i=r.share(r.onPush((function(e){n=e}))(r.onEnd((function(){n=void 0}))(e)));return r.make((function(e){var o=n;return r.subscribe(e.next)(r.onStart((function(){"pre"===u&&a(),void 0!==o&&o===n?e.next("pre"===u?t._extends({},o,{stale:!0}):o):"post"===u&&a()}))(r.onEnd(e.complete)(i))).unsubscribe}))})(o)},w.prototype.query=function(e,r,n){return n&&"boolean"==typeof n.suspense||(n=t._extends({},n,{suspense:!1})),c(this.executeQuery(t.createRequest(e,r),n))},w.prototype.readQuery=function(e,t,n){var i=null;return r.subscribe((function(e){i=e}))(this.query(e,t,n)).unsubscribe(),i},w.prototype.subscription=function(e,r,n){return this.executeSubscription(t.createRequest(e,r),n)},w.prototype.mutation=function(e,r,n){return c(this.executeMutation(t.createRequest(e,r),n))},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=w,exports.cacheExchange=k,exports.composeExchanges=b,exports.createClient=function(e){return new w(e)},exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=m,exports.defaultExchanges=O,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=q,exports.fetchExchange=x,exports.formatDocument=a,exports.gql=function(){for(var r=arguments,n=new Map,i=[],o=[],u=Array.isArray(arguments[0])?arguments[0][0]:arguments[0]||"",a=1;a<arguments.length;a++){var s=r[a];s&&s.definitions?o.push.apply(o,s.definitions):u+=s,u+=r[0][a]}return d(n,i,t.keyDocument(u).definitions),d(n,i,o),t.keyDocument({kind:e.Kind.DOCUMENT,definitions:i})},exports.makeOperation=f,exports.maskTypename=s,exports.ssrExchange=function(e){var n={},i=[];function o(e){i.push(e.operation.key),1===i.length&&Promise.resolve().then((function(){for(var e;e=i.shift();)delete n[e]}))}function u(e){return!h(e)&&void 0!==n[e.key]}var a=function(i){var a=i.client,s=i.forward;return function(i){var c=e&&"boolean"==typeof e.isClient?!!e.isClient:!a.suspense,f=r.share(i),p=s(r.filter((function(e){return!u(e)}))(f)),l=r.map((function(e){var r,i,o;return i=(r=n[e.key]).error,{operation:e,data:(o=r.data)?JSON.parse(o):void 0,extensions:void 0,error:i?new t.CombinedError({networkError:i.networkError?new Error(i.networkError):void 0,graphQLErrors:i.graphQLErrors&&i.graphQLErrors.length?i.graphQLErrors:void 0}):void 0}}))(r.filter((function(e){return u(e)}))(f));return c?l=r.tap(o)(l):p=r.tap((function(e){var t=e.operation;if(!h(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){return t._extends(n,e)},a.extractData=function(){return t._extends({},n)},e&&e.initialState&&a.restoreData(e.initialState),a},exports.subscriptionExchange=function(n){var i=n.forwardSubscription,o=n.enableAllOperations;return function(n){var u=n.client,a=n.forward;function s(e){var t=e.kind;return"subscription"===t||!!o&&("query"===t||"mutation"===t)}return function(n){var o=r.share(n),c=r.mergeMap((function(n){var a=n.key,s=r.filter((function(e){return"teardown"===e.kind&&e.key===a}))(o);return r.takeUntil(s)(function(n){var o=i({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,i=e.next,a=e.complete,s=!1;return Promise.resolve().then((function(){s||(r=o.subscribe({next:function(e){return i(t.makeResult(n,e))},error:function(e){return i(t.makeErrorResult(n,e))},complete:function(){s||(s=!0,"subscription"===n.kind&&u.reexecuteOperation(f("teardown",n,n.context)),a())}}))})),function(){s=!0,r&&r.unsubscribe()}}))}(n))}))(r.filter(s)(o)),p=a(r.filter((function(e){return!s(e)}))(o));return r.merge([c,p])}}}; | ||
//# sourceMappingURL=urql-core.min.js.map |
{ | ||
"name": "urql-core-internal", | ||
"private": true, | ||
"version": "0.0.0", | ||
"main": "../dist/urql-core-internal", | ||
@@ -5,0 +6,0 @@ "module": "../dist/urql-core-internal.mjs", |
{ | ||
"name": "@urql/core", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
353931
2563
5