@urql/core
Advanced tools
Comparing version 1.16.2 to 2.0.0
# @urql/core | ||
## 2.0.0 | ||
### Major Changes | ||
- **Breaking**: Remove `pollInterval` feature from `OperationContext`. Instead consider using a source that uses `Wonka.interval` and `Wonka.switchMap` over `client.query()`'s source, by [@kitten](https://github.com/kitten) (See [#1374](https://github.com/FormidableLabs/urql/pull/1374)) | ||
- Remove deprecated `operationName` property from `Operation`s. The new `Operation.kind` property is now preferred. If you're creating new operations you may also use the `makeOperation` utility instead. | ||
When upgrading `@urql/core` please ensure that your package manager didn't install any duplicates of it. You may deduplicate it manually using `npx yarn-deduplicate` (for Yarn) or `npm dedupe` (for npm), by [@kitten](https://github.com/kitten) (See [#1357](https://github.com/FormidableLabs/urql/pull/1357)) | ||
### Minor Changes | ||
- Reemit an `OperationResult` as `stale: true` if it's being reexecuted as `network-only` operation to give bindings immediate feedback on background refetches, by [@kitten](https://github.com/kitten) (See [#1375](https://github.com/FormidableLabs/urql/pull/1375)) | ||
## 1.16.2 | ||
@@ -4,0 +16,0 @@ |
@@ -38,3 +38,2 @@ import { TypedDocumentNode } from '@graphql-typed-document-node/core'; | ||
url: string; | ||
pollInterval?: number; | ||
meta?: OperationDebugMeta; | ||
@@ -48,4 +47,2 @@ suspense?: boolean; | ||
context: OperationContext; | ||
/** @deprecated use Operation.kind instead */ | ||
readonly operationName: OperationType; | ||
} | ||
@@ -52,0 +49,0 @@ /** Resulting data from an [operation]{@link Operation}. */ |
@@ -9,3 +9,2 @@ export * from './error'; | ||
export * from './operation'; | ||
export * from './deprecation'; | ||
export declare const noop: () => void; |
@@ -21,7 +21,3 @@ "use strict"; | ||
kind: a, | ||
context: c, | ||
get operationName() { | ||
"production" !== process.env.NODE_ENV && deprecationWarning(DEPRECATED_operationName); | ||
return this.kind; | ||
} | ||
context: c | ||
}; | ||
@@ -127,9 +123,2 @@ } | ||
}), {}) : a; | ||
}, issuedWarnings = {}, deprecationWarning = function(a) { | ||
var b = a.key; | ||
a = a.message; | ||
issuedWarnings[b] || (console.warn("[WARNING: Deprecated] " + a), issuedWarnings[b] = !0); | ||
}, DEPRECATED_operationName = { | ||
key: "Operation.operationName", | ||
message: 'The "Operation.operationName" property has been deprecated and will be removed in a future release of urql. Use "Operation.kind" instead.' | ||
}, addMetadata = function(a, b) { | ||
@@ -140,7 +129,7 @@ return makeOperation(a.kind, a, fetchSource._extends({}, a.context, { | ||
}, noop = function() {}, applyDefinitions = function(a, b, c) { | ||
var d, e, f; | ||
var d, f, g; | ||
for (d = 0; d < c.length; d++) { | ||
if (c[d].kind === graphql.Kind.FRAGMENT_DEFINITION) { | ||
e = c[d].name.value, f = fetchSource.stringifyDocument(c[d]); | ||
a.has(e) ? "production" !== process.env.NODE_ENV && a.get(e) !== f && console.warn("[WARNING: Duplicate Fragment] A fragment with name `" + e + "` already exists in this document.\nWhile fragment names may not be unique across your source, each name must be unique per document.") : (a.set(e, f), | ||
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])); | ||
@@ -175,42 +164,42 @@ } else { | ||
function b() { | ||
for (var a; a = m.shift(); ) { | ||
delete g[a]; | ||
for (var a; a = k.shift(); ) { | ||
delete e[a]; | ||
} | ||
} | ||
function c(a) { | ||
return !k(a); | ||
return !l(a); | ||
} | ||
function d(a) { | ||
return deserializeResult(a, g[a.key]); | ||
return deserializeResult(a, e[a.key]); | ||
} | ||
function e(a) { | ||
return k(a); | ||
function f(a) { | ||
return l(a); | ||
} | ||
function f(a) { | ||
function g(a) { | ||
var c = a.operation; | ||
shouldSkip(c) || (a = serializeResult(a), g[c.key] = a); | ||
shouldSkip(c) || (a = serializeResult(a), e[c.key] = a); | ||
} | ||
var g = {}, m = [], h = function(a) { | ||
m.push(a.operation.key); | ||
1 === m.length && Promise.resolve().then(b); | ||
}, k = function(a) { | ||
return !shouldSkip(a) && void 0 !== g[a.key]; | ||
}, l = function(b) { | ||
var q = b.client, g = b.forward; | ||
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 l = a && "boolean" == typeof a.isClient ? !!a.isClient : !q.suspense, n = wonka.share(b); | ||
b = g(wonka.filter(c)(n)); | ||
n = wonka.map(d)(wonka.filter(e)(n)); | ||
l ? n = wonka.tap(h)(n) : b = wonka.tap(f)(b); | ||
return wonka.merge([ b, n ]); | ||
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 ]); | ||
}; | ||
}; | ||
l.restoreData = function(a) { | ||
return fetchSource._extends(g, a); | ||
h.restoreData = function(a) { | ||
return fetchSource._extends(e, a); | ||
}; | ||
l.extractData = function() { | ||
return fetchSource._extends({}, g); | ||
h.extractData = function() { | ||
return fetchSource._extends({}, e); | ||
}; | ||
a && a.initialState && l.restoreData(a.initialState); | ||
return l; | ||
a && a.initialState && h.restoreData(a.initialState); | ||
return h; | ||
}, shouldSkip$1 = function(a) { | ||
@@ -220,6 +209,6 @@ return "mutation" !== (a = a.kind) && "query" !== a; | ||
function b(a) { | ||
var b = h.get(a.key); | ||
"production" !== process.env.NODE_ENV && m(fetchSource._extends({}, { | ||
var c = m.get(a.key); | ||
"production" !== process.env.NODE_ENV && k(fetchSource._extends({}, { | ||
operation: a | ||
}, b ? { | ||
}, c ? { | ||
type: "cacheHit", | ||
@@ -231,28 +220,28 @@ 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(g, a)); | ||
return b; | ||
"cache-and-network" === a.context.requestPolicy && (c.stale = !0, reexecuteOperation(e, a)); | ||
return c; | ||
} | ||
function c(a) { | ||
return !shouldSkip$1(a) && p(a); | ||
return !shouldSkip$1(a) && n(a); | ||
} | ||
function d(a) { | ||
function b(a) { | ||
l.add(a); | ||
function c(a) { | ||
h.add(a); | ||
} | ||
var e, l, f, d = a.operation; | ||
var f, h, g, d = a.operation; | ||
if (d) { | ||
e = collectTypesFromResponse(a.data).concat(d.context.additionalTypenames || []); | ||
f = collectTypesFromResponse(a.data).concat(d.context.additionalTypenames || []); | ||
if ("mutation" === a.operation.kind) { | ||
l = new Set; | ||
"production" !== process.env.NODE_ENV && m({ | ||
h = new Set; | ||
"production" !== process.env.NODE_ENV && k({ | ||
type: "cacheInvalidation", | ||
message: "The following typenames have been invalidated: " + e, | ||
message: "The following typenames have been invalidated: " + f, | ||
operation: d, | ||
data: { | ||
typenames: e, | ||
typenames: f, | ||
response: a | ||
@@ -262,12 +251,12 @@ }, | ||
}); | ||
for (a = 0; a < e.length; a++) { | ||
(f = k[f = e[a]] || (k[f] = new Set)).forEach(b); | ||
f.clear(); | ||
for (a = 0; a < f.length; a++) { | ||
(g = l[g = f[a]] || (l[g] = new Set)).forEach(c); | ||
g.clear(); | ||
} | ||
l.forEach((function c(a) { | ||
h.has(a) && (d = h.get(a).operation, h.delete(a), reexecuteOperation(g, d)); | ||
h.forEach((function b(a) { | ||
m.has(a) && (d = m.get(a).operation, m.delete(a), reexecuteOperation(e, d)); | ||
})); | ||
} else if ("query" === d.kind && a.data) { | ||
for (h.set(d.key, a), a = 0; a < e.length; a++) { | ||
(k[f = e[a]] || (k[f] = new Set)).add(d.key); | ||
for (m.set(d.key, a), a = 0; a < f.length; a++) { | ||
(l[g = f[a]] || (l[g] = new Set)).add(d.key); | ||
} | ||
@@ -277,14 +266,14 @@ } | ||
} | ||
function e(a) { | ||
return !shouldSkip$1(a) && !p(a); | ||
function f(a) { | ||
return !shouldSkip$1(a) && !n(a); | ||
} | ||
var f = a.forward, g = a.client, m = a.dispatchDebug, h = new Map, k = Object.create(null), l = _ref$2, p = function(a) { | ||
var c = a.context.requestPolicy; | ||
return "query" === a.kind && "network-only" !== c && ("cache-only" === c || h.has(a.key)); | ||
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)); | ||
}; | ||
return function(a) { | ||
var h = wonka.share(a); | ||
a = wonka.map(b)(wonka.filter(c)(h)); | ||
h = wonka.tap(d)(f(wonka.filter(_ref7)(wonka.map(_ref8)(wonka.merge([ wonka.map(l)(wonka.filter(e)(h)), wonka.filter(_ref10)(h) ]))))); | ||
return wonka.merge([ a, h ]); | ||
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 ]); | ||
}; | ||
@@ -302,5 +291,5 @@ }, reexecuteOperation = function(a, b) { | ||
function d(a) { | ||
return !k(a); | ||
return !l(a); | ||
} | ||
var e = a.client, m = a.forward, h = function(a) { | ||
var e = a.client, f = a.forward, m = function(a) { | ||
var b = c({ | ||
@@ -313,36 +302,36 @@ key: a.key.toString(36), | ||
return wonka.make((function(c) { | ||
function d(b) { | ||
return f(fetchSource.makeResult(a, b)); | ||
function d(c) { | ||
return g(fetchSource.makeResult(a, c)); | ||
} | ||
function h(b) { | ||
return f(fetchSource.makeErrorResult(a, b)); | ||
function m(c) { | ||
return g(fetchSource.makeErrorResult(a, c)); | ||
} | ||
function g() { | ||
k || (k = !0, "subscription" === a.kind && e.reexecuteOperation(makeOperation("teardown", a, a.context)), | ||
m()); | ||
function f() { | ||
h || (h = !0, "subscription" === a.kind && e.reexecuteOperation(makeOperation("teardown", a, a.context)), | ||
l()); | ||
} | ||
var l, f = c.next, m = c.complete, k = !1; | ||
var k, g = c.next, l = c.complete, h = !1; | ||
Promise.resolve().then((function() { | ||
k || (l = b.subscribe({ | ||
h || (k = b.subscribe({ | ||
next: d, | ||
error: h, | ||
complete: g | ||
error: m, | ||
complete: f | ||
})); | ||
})); | ||
return function() { | ||
k = !0; | ||
l && l.unsubscribe(); | ||
h = !0; | ||
k && k.unsubscribe(); | ||
}; | ||
})); | ||
}, k = b; | ||
}, l = 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.kind && a.key === c; | ||
}))(b); | ||
return wonka.takeUntil(d)(h(a)); | ||
}))(wonka.filter(k)(b)); | ||
c = m(wonka.filter(d)(b)); | ||
return wonka.merge([ a, c ]); | ||
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 ]); | ||
}; | ||
@@ -358,13 +347,13 @@ }; | ||
}, dedupExchange = function(a) { | ||
var b = a.forward, c = a.dispatchDebug, d = new Set, e = function(a) { | ||
var b = a.key, h = a.kind; | ||
if ("teardown" === h) { | ||
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" !== h && "subscription" !== h) { | ||
if ("query" !== e && "subscription" !== e) { | ||
return !0; | ||
} | ||
h = d.has(b); | ||
e = d.has(b); | ||
d.add(b); | ||
h && "production" !== process.env.NODE_ENV && c({ | ||
e && "production" !== process.env.NODE_ENV && c({ | ||
type: "dedup", | ||
@@ -375,9 +364,9 @@ message: "An operation has been deduped.", | ||
}); | ||
return !h; | ||
}, f = function(a) { | ||
return !e; | ||
}, g = function(a) { | ||
d.delete(a.operation.key); | ||
}; | ||
return function(a) { | ||
a = wonka.filter(e)(a); | ||
return wonka.tap(f)(b(a)); | ||
a = wonka.filter(f)(a); | ||
return wonka.tap(g)(b(a)); | ||
}; | ||
@@ -387,7 +376,7 @@ }, fetchExchange = function(a) { | ||
return function(a) { | ||
var f, d = wonka.share(a); | ||
var g, d = wonka.share(a); | ||
a = wonka.mergeMap((function(a) { | ||
var b = a.key, h = wonka.filter((function(a) { | ||
var b = a.key, e = wonka.filter((function(a) { | ||
return "teardown" === a.kind && a.key === b; | ||
}))(d), e = fetchSource.makeFetchBody(a), f = fetchSource.makeFetchURL(a, e), g = fetchSource.makeFetchOptions(a, e); | ||
}))(d), f = fetchSource.makeFetchBody(a), g = fetchSource.makeFetchURL(a, f), n = fetchSource.makeFetchOptions(a, f); | ||
"production" !== process.env.NODE_ENV && c({ | ||
@@ -398,4 +387,4 @@ type: "fetchRequest", | ||
data: { | ||
url: f, | ||
fetchOptions: g | ||
url: g, | ||
fetchOptions: n | ||
}, | ||
@@ -411,4 +400,4 @@ source: "fetchExchange" | ||
data: { | ||
url: f, | ||
fetchOptions: g, | ||
url: g, | ||
fetchOptions: n, | ||
value: d || b | ||
@@ -418,6 +407,6 @@ }, | ||
}); | ||
}))(wonka.takeUntil(h)(fetchSource.makeFetchSource(a, f, g))); | ||
}))(wonka.takeUntil(e)(fetchSource.makeFetchSource(a, g, n))); | ||
}))(wonka.filter(_ref$3)(d)); | ||
f = b(wonka.filter(_ref2$1)(d)); | ||
return wonka.merge([ a, f ]); | ||
g = b(wonka.filter(_ref2$1)(d)); | ||
return wonka.merge([ a, g ]); | ||
}; | ||
@@ -475,3 +464,3 @@ }, fallbackExchange = function(a) { | ||
}, Client = function(a) { | ||
var d, e, f, g, m, c = this; | ||
var d, f, g, e, k, c = this; | ||
this.activeOperations = Object.create(null); | ||
@@ -511,7 +500,7 @@ this.queue = []; | ||
if ("production" !== process.env.NODE_ENV) { | ||
e = (d = wonka.makeSubject()).next, f = d.source; | ||
f = (d = wonka.makeSubject()).next, g = d.source; | ||
this.subscribeToDebugTarget = function b(a) { | ||
return wonka.subscribe(a)(f); | ||
return wonka.subscribe(a)(g); | ||
}; | ||
d = e; | ||
d = f; | ||
} | ||
@@ -525,16 +514,16 @@ this.url = a.url; | ||
this.maskTypename = !!a.maskTypename; | ||
e = wonka.makeSubject(); | ||
g = e.next; | ||
this.operations$ = e.source; | ||
m = !1; | ||
f = wonka.makeSubject(); | ||
e = f.next; | ||
this.operations$ = f.source; | ||
k = !1; | ||
this.dispatchOperation = function(a) { | ||
m = !0; | ||
for (a && g(a); a = c.queue.shift(); ) { | ||
g(a); | ||
k = !0; | ||
for (a && e(a); a = c.queue.shift(); ) { | ||
e(a); | ||
} | ||
m = !1; | ||
k = !1; | ||
}; | ||
this.reexecuteOperation = function(a) { | ||
if ("mutation" === a.kind || 0 < (c.activeOperations[a.key] || 0)) { | ||
c.queue.push(a), m || Promise.resolve().then(c.dispatchOperation); | ||
c.queue.push(a), k || Promise.resolve().then(c.dispatchOperation); | ||
} | ||
@@ -570,21 +559,27 @@ }; | ||
Client.prototype.executeRequestOperation = function(a) { | ||
var f, g, d = this, e = wonka.filter((function(b) { | ||
var f, g, c = this, d = wonka.filter((function(b) { | ||
return b.operation.key === a.key; | ||
}))(this.results$); | ||
this.maskTypename && (e = wonka.map(_ref2$2)(e)); | ||
this.maskTypename && (d = wonka.map(_ref2$2)(d)); | ||
if ("mutation" === a.kind) { | ||
return wonka.take(1)(wonka.onStart((function b() { | ||
return d.dispatchOperation(a); | ||
}))(e)); | ||
return c.dispatchOperation(a); | ||
}))(d)); | ||
} | ||
f = wonka.filter((function(b) { | ||
return "teardown" === b.kind && b.key === a.key; | ||
}))(this.operations$), g = wonka.onEnd((function() { | ||
d.onOperationEnd(a); | ||
}))(this.operations$), g = wonka.filter((function(b) { | ||
return b.kind === a.kind && b.key === a.key && "cache-only" !== b.context.requestPolicy; | ||
}))(this.operations$); | ||
return wonka.onEnd((function() { | ||
c.onOperationEnd(a); | ||
}))(wonka.onStart((function() { | ||
d.onOperationStart(a); | ||
}))(wonka.takeUntil(f)(e))); | ||
return "query" === a.kind && a.context.pollInterval ? wonka.switchMap((function c() { | ||
return g; | ||
}))(wonka.merge([ wonka.fromValue(0), wonka.interval(a.context.pollInterval) ])) : g; | ||
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, { | ||
stale: !0 | ||
}); | ||
}))(wonka.take(1)(g)) ]); | ||
}))(wonka.takeUntil(f)(d)))); | ||
}; | ||
@@ -650,9 +645,9 @@ | ||
exports.gql = function gql() { | ||
var a, b, c, d, e, f, g; | ||
for (a = arguments, b = new Map, c = [], d = [], e = Array.isArray(arguments[0]) ? arguments[0][0] : arguments[0] || "", | ||
f = 1; f < arguments.length; f++) { | ||
(g = a[f]) && g.definitions ? d.push.apply(d, g.definitions) : e += g; | ||
e += a[0][f]; | ||
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]; | ||
} | ||
applyDefinitions(b, c, fetchSource.keyDocument(e).definitions); | ||
applyDefinitions(b, c, fetchSource.keyDocument(f).definitions); | ||
applyDefinitions(b, c, d); | ||
@@ -659,0 +654,0 @@ return fetchSource.keyDocument({ |
@@ -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,get operationName(){return this.kind}}}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 t=this,n=r.filter((function(t){return t.operation.key===e.key}))(this.results$);if(this.maskTypename&&(n=r.map(C)(n)),"mutation"===e.kind)return r.take(1)(r.onStart((function(){return t.dispatchOperation(e)}))(n));var i=r.filter((function(t){return"teardown"===t.kind&&t.key===e.key}))(this.operations$),o=r.onEnd((function(){t.onOperationEnd(e)}))(r.onStart((function(){t.onOperationStart(e)}))(r.takeUntil(i)(n)));return"query"===e.kind&&e.context.pollInterval?r.switchMap((function(){return o}))(r.merge([r.fromValue(0),r.interval(e.context.pollInterval)])):o},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])}}}; | ||
"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])}}}; | ||
//# sourceMappingURL=urql-core.min.js.map |
{ | ||
"name": "@urql/core", | ||
"version": "1.16.2", | ||
"version": "2.0.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
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
24
333025
56
2136