Socket
Socket
Sign inDemoInstall

@urql/core

Package Overview
Dependencies
Maintainers
29
Versions
259
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@urql/core - npm Package Compare versions

Comparing version 1.15.2 to 1.16.0

dist/2e89d385.js

11

CHANGELOG.md
# @urql/core
## 1.16.0
### Minor Changes
- Add a built-in `gql` tag function helper to `@urql/core`. This behaves similarly to `graphql-tag` but only warns about _locally_ duplicated fragment names rather than globally. It also primes `@urql/core`'s key cache with the parsed `DocumentNode`, by [@kitten](https://github.com/kitten) (See [#1187](https://github.com/FormidableLabs/urql/pull/1187))
### Patch Changes
- ⚠️ Fix edge case in `formatDocument`, which fails to add a `__typename` field if it has been aliased to a different name, by [@kitten](https://github.com/kitten) (See [#1186](https://github.com/FormidableLabs/urql/pull/1186))
- Cache results of `formatDocument` by the input document's key, by [@kitten](https://github.com/kitten) (See [#1186](https://github.com/FormidableLabs/urql/pull/1186))
## 1.15.2

@@ -4,0 +15,0 @@

9

dist/types/exchanges/cache.d.ts

@@ -1,9 +0,2 @@

import { Client } from '../client';
import { Exchange, OperationResult, ExchangeInput } from '../types';
declare type ResultCache = Map<number, OperationResult>;
interface OperationCache {
[key: string]: Set<number>;
}
import { Exchange } from '../types';
export declare const cacheExchange: Exchange;
export declare const afterMutation: (resultCache: ResultCache, operationCache: OperationCache, client: Client, dispatchDebug: ExchangeInput['dispatchDebug']) => (response: OperationResult) => void;
export {};
export { TypedDocumentNode } from '@graphql-typed-document-node/core';
export { gql } from './gql';
export * from './client';

@@ -3,0 +4,0 @@ export * from './exchanges';

import { TypedDocumentNode } from '@graphql-typed-document-node/core';
import { DocumentNode } from 'graphql';
import { GraphQLRequest } from '../types';
export interface KeyedDocumentNode extends DocumentNode {
__key: number;
}
export declare const keyDocument: (q: string | DocumentNode | TypedDocumentNode) => KeyedDocumentNode;
export declare const createRequest: <Data = any, Variables = object>(q: string | DocumentNode | TypedDocumentNode<Data, Variables>, vars?: Variables | undefined) => GraphQLRequest<Data, Variables>;

@@ -5,0 +9,0 @@ /**

"use strict";
var fetchSource = require("./aa6c4fd3.js");
var fetchSource = require("./2e89d385.js");

@@ -5,0 +5,0 @@ exports.makeFetchBody = fetchSource.makeFetchBody;

@@ -1,2 +0,2 @@

"use strict";var e=require("./de338699.min.js");exports.makeFetchBody=e.makeFetchBody,exports.makeFetchOptions=e.makeFetchOptions,exports.makeFetchSource=e.makeFetchSource,exports.makeFetchURL=e.makeFetchURL;
"use strict";var e=require("./4e272566.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
"use strict";
function _ref2(a, b, c) {
return c.indexOf(a) === b;
function _ref(a) {
return a.kind === graphql.Kind.FIELD && "__typename" === a.name.value && !a.alias;
}
function _ref3(a) {
return a.kind === graphql.Kind.FIELD && "__typename" === a.name.value;
}
function withPromise(a) {

@@ -33,3 +29,3 @@ a.toPromise = function() {

function _ref(a) {
function _ref$1(a) {
return a.path || a.extensions ? {

@@ -42,3 +38,3 @@ message: a.message,

function _ref$1(a) {
function _ref$2(a) {
var b = makeOperation(a.kind, a);

@@ -49,7 +45,7 @@ b.query = formatDocument(a.query);

function _ref5(a) {
function _ref7(a) {
return "query" !== a.kind || "cache-only" !== a.context.requestPolicy;
}
function _ref6(a) {
function _ref8(a) {
return addMetadata(a, {

@@ -60,27 +56,27 @@ cacheOutcome: "miss"

function _ref8(a) {
function _ref10(a) {
return shouldSkip$1(a);
}
function _ref2$1(a) {
function _ref2(a) {
return console.log("[Exchange debug]: Completed operation: ", a);
}
function _ref3$1(a) {
function _ref3(a) {
return console.log("[Exchange debug]: Incoming operation: ", a);
}
function _ref$2(a) {
function _ref$3(a) {
return "query" === a.kind || "mutation" === a.kind;
}
function _ref2$2(a) {
function _ref2$1(a) {
return "query" !== a.kind && "mutation" !== a.kind;
}
function _ref$3() {
function _ref$4() {
return !1;
}
function _ref2$3(a) {
function _ref2$2(a) {
a.data = maskTypename(a.data);

@@ -90,11 +86,10 @@ return a;

var fetchSource = require("./aa6c4fd3.js"), wonka = require("wonka"), graphql = require("graphql"), collectTypes = function(a, b) {
void 0 === b && (b = []);
var graphql = require("graphql"), fetchSource = require("./2e89d385.js"), wonka = require("wonka"), collectTypes = function(a, b) {
if (Array.isArray(a)) {
a.forEach((function c(a) {
collectTypes(a, b);
}));
for (var c = 0; c < a.length; c++) {
collectTypes(a[c], b);
}
} else if ("object" == typeof a && null !== a) {
for (var d in a) {
"__typename" === d && "string" == typeof a[d] ? b.push(a[d]) : collectTypes(a[d], b);
for (c in a) {
"__typename" === c && "string" == typeof a[c] ? b[a[c]] = 0 : collectTypes(a[c], b);
}

@@ -104,5 +99,5 @@ }

}, collectTypesFromResponse = function(a) {
return collectTypes(a).filter(_ref2);
return Object.keys(collectTypes(a, {}));
}, formatNode = function(a) {
if (a.selectionSet && !a.selectionSet.selections.some(_ref3)) {
if (a.selectionSet && !a.selectionSet.selections.some(_ref)) {
return fetchSource._extends({}, a, {

@@ -120,8 +115,9 @@ selectionSet: fetchSource._extends({}, a.selectionSet, {

}
}, formatDocument = function(a) {
var b = graphql.visit(a, {
}, 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
});
b.__key = a.__key;
})).__key = a.__key, formattedDocs.set(a.__key, b));
return b;

@@ -156,3 +152,3 @@ }, maskTypename = function(a) {

a && (c.error = {
graphQLErrors: a.graphQLErrors.map(_ref)
graphQLErrors: a.graphQLErrors.map(_ref$1)
}, a.networkError && (c.error.networkError = "" + a.networkError));

@@ -173,4 +169,4 @@ return c;

function b() {
for (var a; a = g.shift(); ) {
delete h[a];
for (var a; a = k.shift(); ) {
delete g[a];
}

@@ -182,34 +178,34 @@ }

function d(a) {
return deserializeResult(a, h[a.key]);
return deserializeResult(a, g[a.key]);
}
function f(a) {
function e(a) {
return m(a);
}
function k(a) {
var b = a.operation;
shouldSkip(b) || (a = serializeResult(a), h[b.key] = a);
function n(a) {
var c = a.operation;
shouldSkip(c) || (a = serializeResult(a), g[c.key] = a);
}
var h = {}, g = [], e = function(a) {
g.push(a.operation.key);
1 === g.length && Promise.resolve().then(b);
var g = {}, k = [], f = function(a) {
k.push(a.operation.key);
1 === k.length && Promise.resolve().then(b);
}, m = function(a) {
return !shouldSkip(a) && void 0 !== h[a.key];
}, l = function(b) {
var h = b.client, q = b.forward;
return !shouldSkip(a) && void 0 !== g[a.key];
}, h = function(b) {
var l = b.client, g = b.forward;
return function(b) {
var l = a && "boolean" == typeof a.isClient ? !!a.isClient : !h.suspense, g = wonka.share(b);
b = q(wonka.filter(c)(g));
g = wonka.map(d)(wonka.filter(f)(g));
l ? g = wonka.tap(e)(g) : b = wonka.tap(k)(b);
return wonka.merge([ b, g ]);
var h = a && "boolean" == typeof a.isClient ? !!a.isClient : !l.suspense, p = wonka.share(b);
b = g(wonka.filter(c)(p));
p = wonka.map(d)(wonka.filter(e)(p));
h ? p = wonka.tap(f)(p) : b = wonka.tap(n)(b);
return wonka.merge([ b, p ]);
};
};
l.restoreData = function(a) {
return fetchSource._extends(h, a);
h.restoreData = function(a) {
return fetchSource._extends(g, a);
};
l.extractData = function() {
return fetchSource._extends({}, h);
h.extractData = function() {
return fetchSource._extends({}, g);
};
a && a.initialState && l.restoreData(a.initialState);
return l;
a && a.initialState && h.restoreData(a.initialState);
return h;
}, shouldSkip$1 = function(a) {

@@ -219,4 +215,4 @@ return "mutation" !== (a = a.kind) && "query" !== a;

function b(a) {
var b = e.get(a.key);
"production" !== process.env.NODE_ENV && g(fetchSource._extends({}, {
var b = f.get(a.key);
"production" !== process.env.NODE_ENV && k(fetchSource._extends({}, {
operation: a

@@ -235,25 +231,53 @@ }, b ? {

});
"cache-and-network" === a.context.requestPolicy && (b.stale = !0, reexecuteOperation(h, a));
"cache-and-network" === a.context.requestPolicy && (b.stale = !0, reexecuteOperation(g, a));
return b;
}
function c(a) {
return !shouldSkip$1(a) && n(a);
return !shouldSkip$1(a) && q(a);
}
function d(a) {
a.operation && "mutation" === a.operation.kind ? l(a) : a.operation && "query" === a.operation.kind && p(a);
function b(a) {
h.add(a);
}
var e, h, l, d = a.operation;
if (d) {
e = collectTypesFromResponse(a.data).concat(d.context.additionalTypenames || []);
if ("mutation" === a.operation.kind) {
h = new Set;
"production" !== process.env.NODE_ENV && k({
type: "cacheInvalidation",
message: "The following typenames have been invalidated: " + e,
operation: d,
data: {
typenames: e,
response: a
},
source: "cacheExchange"
});
for (a = 0; a < e.length; a++) {
(l = m[l = e[a]] || (m[l] = new Set)).forEach(b);
l.clear();
}
h.forEach((function c(a) {
f.has(a) && (d = f.get(a).operation, f.delete(a), reexecuteOperation(g, d));
}));
} else if ("query" === d.kind && a.data) {
for (f.set(d.key, a), a = 0; a < e.length; a++) {
(m[l = e[a]] || (m[l] = new Set)).add(d.key);
}
}
}
}
function f(a) {
return !shouldSkip$1(a) && !n(a);
function e(a) {
return !shouldSkip$1(a) && !q(a);
}
var m, l, p, n, k = a.forward, h = a.client, g = a.dispatchDebug, e = new Map;
a = Object.create(null);
m = _ref$1, l = afterMutation(e, a, h, g), p = afterQuery(e, a), n = function(a) {
var n = a.forward, g = a.client, k = a.dispatchDebug, f = new Map, m = Object.create(null), h = _ref$2, q = function(a) {
var c = a.context.requestPolicy;
return "query" === a.kind && "network-only" !== c && ("cache-only" === c || e.has(a.key));
return "query" === a.kind && "network-only" !== c && ("cache-only" === c || f.has(a.key));
};
return function(a) {
var e = wonka.share(a);
a = wonka.map(b)(wonka.filter(c)(e));
e = wonka.tap(d)(k(wonka.filter(_ref5)(wonka.map(_ref6)(wonka.merge([ wonka.map(m)(wonka.filter(f)(e)), wonka.filter(_ref8)(e) ])))));
return wonka.merge([ a, e ]);
var f = wonka.share(a);
a = wonka.map(b)(wonka.filter(c)(f));
f = wonka.tap(d)(n(wonka.filter(_ref7)(wonka.map(_ref8)(wonka.merge([ wonka.map(h)(wonka.filter(e)(f)), wonka.filter(_ref10)(f) ])))));
return wonka.merge([ a, f ]);
};

@@ -264,43 +288,2 @@ }, reexecuteOperation = function(a, b) {

})));
}, afterMutation = function(a, b, c, d) {
function f(b) {
if (a.has(b)) {
var d = a.get(b).operation;
a.delete(b);
reexecuteOperation(c, d);
}
}
return function(a) {
function c(a) {
g.add(a);
}
var g = new Set, e = a.operation.context.additionalTypenames;
e = collectTypesFromResponse(a.data).concat(e || []);
"production" !== process.env.NODE_ENV && d({
type: "cacheInvalidation",
message: "The following typenames have been invalidated: " + e,
operation: a.operation,
data: {
typenames: e,
response: a
},
source: "cacheExchange"
});
e.forEach((function(a) {
(a = b[a] || (b[a] = new Set)).forEach(c);
a.clear();
}));
g.forEach(f);
};
}, afterQuery = function(a, b) {
return function(c) {
var d = c.operation, f = c.data, k = d.context.additionalTypenames;
null != f && (a.set(d.key, {
operation: d,
data: f,
error: c.error
}), collectTypesFromResponse(c.data).concat(k || []).forEach((function(a) {
(b[a] || (b[a] = new Set)).add(d.key);
})));
};
}, subscriptionExchange = function(a) {

@@ -315,3 +298,3 @@ function b(a) {

}
var f = a.client, g = a.forward, e = function(a) {
var e = a.client, k = a.forward, f = function(a) {
var b = c({

@@ -325,21 +308,21 @@ key: a.key.toString(36),

function d(b) {
return g(fetchSource.makeResult(a, b));
return k(fetchSource.makeResult(a, b));
}
function e(b) {
return g(fetchSource.makeErrorResult(a, b));
function f(b) {
return k(fetchSource.makeErrorResult(a, b));
}
function h() {
k || (k = !0, "subscription" === a.kind && f.reexecuteOperation(makeOperation("teardown", a, a.context)),
function g() {
h || (h = !0, "subscription" === a.kind && e.reexecuteOperation(makeOperation("teardown", a, a.context)),
m());
}
var l, g = c.next, m = c.complete, k = !1;
var l, k = c.next, m = c.complete, h = !1;
Promise.resolve().then((function() {
k || (l = b.subscribe({
h || (l = b.subscribe({
next: d,
error: e,
complete: h
error: f,
complete: g
}));
}));
return function() {
k = !0;
h = !0;
l && l.unsubscribe();

@@ -355,5 +338,5 @@ };

}))(b);
return wonka.takeUntil(d)(e(a));
return wonka.takeUntil(d)(f(a));
}))(wonka.filter(m)(b));
c = g(wonka.filter(d)(b));
c = k(wonka.filter(d)(b));
return wonka.merge([ a, c ]);

@@ -367,16 +350,16 @@ };

} : function c(a) {
return wonka.tap(_ref2$1)(d(wonka.tap(_ref3$1)(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) {
var b = a.forward, c = a.dispatchDebug, d = new Set, e = function(a) {
var b = a.key, f = a.kind;
if ("teardown" === f) {
return d.delete(b), !0;
}
if ("query" !== e && "subscription" !== e) {
if ("query" !== f && "subscription" !== f) {
return !0;
}
e = d.has(b);
f = d.has(b);
d.add(b);
e && "production" !== process.env.NODE_ENV && c({
f && "production" !== process.env.NODE_ENV && c({
type: "dedup",

@@ -387,9 +370,9 @@ message: "An operation has been deduped.",

});
return !e;
}, k = function(a) {
return !f;
}, n = function(a) {
d.delete(a.operation.key);
};
return function(a) {
a = wonka.filter(f)(a);
return wonka.tap(k)(b(a));
a = wonka.filter(e)(a);
return wonka.tap(n)(b(a));
};

@@ -399,7 +382,7 @@ }, fetchExchange = function(a) {

return function(a) {
var k, d = wonka.share(a);
var n, d = wonka.share(a);
a = wonka.mergeMap((function(a) {
var b = a.key, e = wonka.filter((function(a) {
var b = a.key, f = wonka.filter((function(a) {
return "teardown" === a.kind && a.key === b;
}))(d), f = fetchSource.makeFetchBody(a), k = fetchSource.makeFetchURL(a, f), h = fetchSource.makeFetchOptions(a, f);
}))(d), e = fetchSource.makeFetchBody(a), h = fetchSource.makeFetchURL(a, e), g = fetchSource.makeFetchOptions(a, e);
"production" !== process.env.NODE_ENV && c({

@@ -410,4 +393,4 @@ type: "fetchRequest",

data: {
url: k,
fetchOptions: h
url: h,
fetchOptions: g
},

@@ -423,4 +406,4 @@ source: "fetchExchange"

data: {
url: k,
fetchOptions: h,
url: h,
fetchOptions: g,
value: d || b

@@ -430,6 +413,6 @@ },

});
}))(wonka.takeUntil(e)(fetchSource.makeFetchSource(a, k, h)));
}))(wonka.filter(_ref$2)(d));
k = b(wonka.filter(_ref2$2)(d));
return wonka.merge([ a, k ]);
}))(wonka.takeUntil(f)(fetchSource.makeFetchSource(a, h, g)));
}))(wonka.filter(_ref$3)(d));
n = b(wonka.filter(_ref2$1)(d));
return wonka.merge([ a, n ]);
};

@@ -451,3 +434,3 @@ }, fallbackExchange = function(a) {

return function(a) {
return wonka.filter(_ref$3)(wonka.tap(b)(a));
return wonka.filter(_ref$4)(wonka.tap(b)(a));
};

@@ -488,3 +471,3 @@ }, fallbackExchangeIO = fallbackExchange({

}, Client = function(a) {
var d, f, k, h, g, c = this;
var d, e, n, g, k, c = this;
this.activeOperations = Object.create(null);

@@ -524,7 +507,7 @@ this.queue = [];

if ("production" !== process.env.NODE_ENV) {
f = (d = wonka.makeSubject()).next, k = d.source;
e = (d = wonka.makeSubject()).next, n = d.source;
this.subscribeToDebugTarget = function b(a) {
return wonka.subscribe(a)(k);
return wonka.subscribe(a)(n);
};
d = f;
d = e;
}

@@ -538,16 +521,16 @@ this.url = a.url;

this.maskTypename = !!a.maskTypename;
f = wonka.makeSubject();
h = f.next;
this.operations$ = f.source;
g = !1;
e = wonka.makeSubject();
g = e.next;
this.operations$ = e.source;
k = !1;
this.dispatchOperation = function(a) {
g = !0;
for (a && h(a); a = c.queue.shift(); ) {
h(a);
k = !0;
for (a && g(a); a = c.queue.shift(); ) {
g(a);
}
g = !1;
k = !1;
};
this.reexecuteOperation = function(a) {
if ("mutation" === a.kind || 0 < (c.activeOperations[a.key] || 0)) {
c.queue.push(a), g || Promise.resolve().then(c.dispatchOperation);
c.queue.push(a), k || Promise.resolve().then(c.dispatchOperation);
}

@@ -583,21 +566,21 @@ };

Client.prototype.executeRequestOperation = function(a) {
var k, h, d = this, f = wonka.filter((function(b) {
var n, g, d = this, e = wonka.filter((function(b) {
return b.operation.key === a.key;
}))(this.results$);
this.maskTypename && (f = wonka.map(_ref2$3)(f));
this.maskTypename && (e = wonka.map(_ref2$2)(e));
if ("mutation" === a.kind) {
return wonka.take(1)(wonka.onStart((function b() {
return d.dispatchOperation(a);
}))(f));
}))(e));
}
k = wonka.filter((function(b) {
n = wonka.filter((function(b) {
return "teardown" === b.kind && b.key === a.key;
}))(this.operations$), h = wonka.onEnd((function() {
}))(this.operations$), g = wonka.onEnd((function() {
d.onOperationEnd(a);
}))(wonka.onStart((function() {
d.onOperationStart(a);
}))(wonka.takeUntil(k)(f)));
}))(wonka.takeUntil(n)(e)));
return "query" === a.kind && a.context.pollInterval ? wonka.switchMap((function c() {
return h;
}))(wonka.merge([ wonka.fromValue(0), wonka.interval(a.context.pollInterval) ])) : h;
return g;
}))(wonka.merge([ wonka.fromValue(0), wonka.interval(a.context.pollInterval) ])) : g;
};

@@ -662,2 +645,23 @@

exports.gql = function gql() {
var a, b, c, d, e;
for (a = arguments, b = Array.isArray(arguments[0]) ? arguments[0][0] : arguments[0] || "",
c = 1; c < arguments.length; c++) {
b += (d = a[c]) && d.kind === graphql.Kind.DOCUMENT ? d.loc ? d.loc.source.body : graphql.print(d) : d;
b += a[0][c];
}
a = fetchSource.keyDocument(b);
if ("production" !== process.env.NODE_ENV) {
for (c = new Set, d = 0; d < a.definitions.length; d++) {
(e = a.definitions[d]).kind === graphql.Kind.FRAGMENT_DEFINITION && (c.has(e = e.name.value) ? 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.") : c.add(e));
}
}
a.loc = {
start: 0,
end: b.length,
source: new graphql.Source(b, "gql")
};
return a;
};
exports.makeOperation = makeOperation;

@@ -664,0 +668,0 @@

@@ -1,2 +0,2 @@

"use strict";var e=require("./de338699.min.js"),t=require("wonka"),r=require("graphql"),n=function(e,t){if(void 0===t&&(t=[]),Array.isArray(e))e.forEach((function(e){n(e,t)}));else if("object"==typeof e&&null!==e)for(var r in e)"__typename"===r&&"string"==typeof e[r]?t.push(e[r]):n(e[r],t);return t};function o(e,t,r){return r.indexOf(e)===t}var i=function(e){return n(e).filter(o)};function u(e){return e.kind===r.Kind.FIELD&&"__typename"===e.name.value}var a=function(t){if(t.selectionSet&&!t.selectionSet.selections.some(u))return e._extends({},t,{selectionSet:e._extends({},t.selectionSet,{selections:t.selectionSet.selections.concat([{kind:r.Kind.FIELD,name:{kind:r.Kind.NAME,value:"__typename"}}])})})},c=function(e){var t=r.visit(e,{Field:a,InlineFragment:a});return t.__key=e.__key,t},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 f(e){return e.toPromise=function(){return t.toPromise(t.take(1)(e))},e}function p(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 l=function(t,r){return p(t.kind,t,e._extends({},t.context,{meta:e._extends({},t.context.meta,r)}))},h=function(){},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=p(e.kind,e);return t.query=c(e.query),t}function x(e){return"query"!==e.kind||"cache-only"!==e.context.requestPolicy}function v(e){return l(e,{cacheOutcome:"miss"})}function q(e){return k(e)}var g=function(r){function n(t){var r=s.get(t.key);return r=e._extends({},r,{operation:l(t,{cacheOutcome:r?"hit":"miss"})}),"cache-and-network"===t.context.requestPolicy&&(r.stale=!0,O(c,t)),r}function o(e){return!k(e)&&y(e)}function i(e){e.operation&&"mutation"===e.operation.kind?h(e):e.operation&&"query"===e.operation.kind&&d(e)}function u(e){return!k(e)&&!y(e)}var a=r.forward,c=r.client;r=r.dispatchDebug;var s=new Map,f=Object.create(null),p=m,h=b(s,f,c,r),d=E(s,f),y=function(e){var t=e.context.requestPolicy;return"query"===e.kind&&"network-only"!==t&&("cache-only"===t||s.has(e.key))};return function(e){var r=t.share(e);return e=t.map(n)(t.filter(o)(r)),r=t.tap(i)(a(t.filter(x)(t.map(v)(t.merge([t.map(p)(t.filter(u)(r)),t.filter(q)(r)]))))),t.merge([e,r])}},O=function(t,r){return t.reexecuteOperation(p(r.kind,r,e._extends({},r.context,{requestPolicy:"network-only"})))},b=function(e,t,r,n){function o(t){if(e.has(t)){var n=e.get(t).operation;e.delete(t),O(r,n)}}return function(e){function r(e){n.add(e)}var n=new Set,u=e.operation.context.additionalTypenames;(e=i(e.data).concat(u||[])).forEach((function(e){(e=t[e]||(t[e]=new Set)).forEach(r),e.clear()})),n.forEach(o)}},E=function(e,t){return function(r){var n=r.operation,o=r.data,u=n.context.additionalTypenames;null!=o&&(e.set(n.key,{operation:n,data:o,error:r.error}),i(r.data).concat(u||[]).forEach((function(e){(t[e]||(t[e]=new Set)).add(n.key)})))}},w=function(e){var r=e.forward,n=new Set,o=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)},i=function(e){n.delete(e.operation.key)};return function(e){return e=t.filter(o)(e),t.tap(i)(r(e))}};function _(e){return"query"===e.kind||"mutation"===e.kind}function S(e){return"query"!==e.kind&&"mutation"!==e.kind}var R=function(r){var n=r.forward;return function(r){var o=t.share(r);r=t.mergeMap((function(r){var n=r.key,i=t.filter((function(e){return"teardown"===e.kind&&e.key===n}))(o),u=e.makeFetchBody(r),a=e.makeFetchURL(r,u);return u=e.makeFetchOptions(r,u),t.onPush((function(e){}))(t.takeUntil(i)(e.makeFetchSource(r,a,u)))}))(t.filter(_)(o));var i=n(t.filter(S)(o));return t.merge([r,i])}};function P(){return!1}var M=function(e){function r(e){}return function(e){return t.filter(P)(t.tap(r)(e))}},Q=M(),j=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)}},C=[w,g,R],D=function(r){var n=this;this.activeOperations=Object.create(null),this.queue=[],this.createOperationContext=function(t){return t||(t={}),e._extends({},{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod},t,{suspense:t.suspense||!1!==t.suspense&&n.suspense,requestPolicy:t.requestPolicy||n.requestPolicy})},this.createRequestOperation=function(e,t,r){return p(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 o=h;this.url=r.url,this.fetchOptions=r.fetchOptions,this.fetch=r.fetch,this.suspense=!!r.suspense,this.requestPolicy=r.requestPolicy||"cache-first",this.preferGetMethod=!!r.preferGetMethod,this.maskTypename=!!r.maskTypename;var i=t.makeSubject(),u=i.next;this.operations$=i.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))},r=j(void 0!==r.exchanges?r.exchanges:C),this.results$=t.share(r({client:this,dispatchDebug:o,forward:M()})(this.operations$)),t.publish(this.results$)};function L(e){return e.data=s(e.data),e}D.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},D.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(p("teardown",e,e.context))}},D.prototype.executeRequestOperation=function(e){var r=this,n=t.filter((function(t){return t.operation.key===e.key}))(this.results$);if(this.maskTypename&&(n=t.map(L)(n)),"mutation"===e.kind)return t.take(1)(t.onStart((function(){return r.dispatchOperation(e)}))(n));var o=t.filter((function(t){return"teardown"===t.kind&&t.key===e.key}))(this.operations$),i=t.onEnd((function(){r.onOperationEnd(e)}))(t.onStart((function(){r.onOperationStart(e)}))(t.takeUntil(o)(n)));return"query"===e.kind&&e.context.pollInterval?t.switchMap((function(){return i}))(t.merge([t.fromValue(0),t.interval(e.context.pollInterval)])):i},D.prototype.query=function(t,r,n){return n&&"boolean"==typeof n.suspense||(n=e._extends({},n,{suspense:!1})),f(this.executeQuery(e.createRequest(t,r),n))},D.prototype.readQuery=function(r,n,o){var i=null;return t.subscribe((function(e){i=e}))(this.executeQuery(e.createRequest(r,n),o)).unsubscribe(),i},D.prototype.subscription=function(t,r,n){return this.executeSubscription(e.createRequest(t,r),n)},D.prototype.mutation=function(t,r,n){return f(this.executeMutation(e.createRequest(t,r),n))},exports.CombinedError=e.CombinedError,exports.createRequest=e.createRequest,exports.getOperationName=e.getOperationName,exports.makeErrorResult=e.makeErrorResult,exports.makeResult=e.makeResult,exports.stringifyVariables=e.stringifyVariables,exports.Client=D,exports.cacheExchange=g,exports.composeExchanges=j,exports.createClient=function(e){return new D(e)},exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=w,exports.defaultExchanges=C,exports.errorExchange=function(e){function r(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 t.tap(r)(n(e))}}},exports.fallbackExchangeIO=Q,exports.fetchExchange=R,exports.formatDocument=c,exports.makeOperation=p,exports.maskTypename=s,exports.ssrExchange=function(r){function n(){for(var e;e=s.shift();)delete c[e]}function o(e){return!p(e)}function i(t){return function(t,r){var n=r.error;return{operation:t,data:(r=r.data)?JSON.parse(r):void 0,extensions:void 0,error:n?new e.CombinedError({networkError:n.networkError?Error(n.networkError):void 0,graphQLErrors:n.graphQLErrors&&n.graphQLErrors.length?n.graphQLErrors:void 0}):void 0}}(t,c[t.key])}function 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),c[t.key]=e)}var c={},s=[],f=function(e){s.push(e.operation.key),1===s.length&&Promise.resolve().then(n)},p=function(e){return!d(e)&&void 0!==c[e.key]},l=function(e){var n=e.client,c=e.forward;return function(e){var s=r&&"boolean"==typeof r.isClient?!!r.isClient:!n.suspense,p=t.share(e);return e=c(t.filter(o)(p)),p=t.map(i)(t.filter(u)(p)),s?p=t.tap(f)(p):e=t.tap(a)(e),t.merge([e,p])}};return l.restoreData=function(t){return e._extends(c,t)},l.extractData=function(){return e._extends({},c)},r&&r.initialState&&l.restoreData(r.initialState),l},exports.subscriptionExchange=function(n){function o(e){return"subscription"===(e=e.kind)||!!u&&("query"===e||"mutation"===e)}var i=n.forwardSubscription,u=n.enableAllOperations;return function(n){function u(e){return!f(e)}var a=n.client,c=n.forward,s=function(n){var o=i({key:n.key.toString(36),query:r.print(n.query),variables:n.variables,context:e._extends({},n.context)});return t.make((function(t){function r(t){return s(e.makeResult(n,t))}function i(t){return s(e.makeErrorResult(n,t))}function u(){l||(l=!0,"subscription"===n.kind&&a.reexecuteOperation(p("teardown",n,n.context)),f())}var c,s=t.next,f=t.complete,l=!1;return Promise.resolve().then((function(){l||(c=o.subscribe({next:r,error:i,complete:u}))})),function(){l=!0,c&&c.unsubscribe()}}))},f=o;return function(e){var r=t.share(e);e=t.mergeMap((function(e){var n=e.key,o=t.filter((function(e){return"teardown"===e.kind&&e.key===n}))(r);return t.takeUntil(o)(s(e))}))(t.filter(f)(r));var n=c(t.filter(u)(r));return t.merge([e,n])}}};
"use strict";var e=require("graphql"),t=require("./4e272566.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 o(t){return t.kind===e.Kind.FIELD&&"__typename"===t.name.value&&!t.alias}var i=function(r){if(r.selectionSet&&!r.selectionSet.selections.some(o))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:i,InlineFragment:i})).__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(e){return"subscription"!==(e=e.kind)&&"query"!==e};function d(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}var y=function(e){return"mutation"!==(e=e.kind)&&"query"!==e};function k(e){var t=f(e.kind,e);return t.query=a(e.query),t}function m(e){return"query"!==e.kind||"cache-only"!==e.context.requestPolicy}function v(e){return p(e,{cacheOutcome:"miss"})}function x(e){return y(e)}var g=function(e){function o(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,q(c,e)),r}function i(e){return!y(e)&&d(e)}function u(e){function t(e){i.add(e)}var r=e.operation;if(r){var o=function(e){return Object.keys(n(e,{}))}(e.data).concat(r.context.additionalTypenames||[]);if("mutation"===e.operation.kind){var i=new Set;for(e=0;e<o.length;e++){var u=o[e];(u=l[u]||(l[u]=new Set)).forEach(t),u.clear()}i.forEach((function(e){f.has(e)&&(r=f.get(e).operation,f.delete(e),q(c,r))}))}else if("query"===r.kind&&e.data)for(f.set(r.key,e),e=0;e<o.length;e++)(l[u=o[e]]||(l[u]=new Set)).add(r.key)}}function a(e){return!y(e)&&!d(e)}var s=e.forward,c=e.client,f=new Map,l=Object.create(null),h=k,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(o)(r.filter(i)(t)),t=r.tap(u)(s(r.filter(m)(r.map(v)(r.merge([r.map(h)(r.filter(a)(t)),r.filter(x)(t)]))))),r.merge([e,t])}},q=function(e,r){return e.reexecuteOperation(f(r.kind,r,t._extends({},r.context,{requestPolicy:"network-only"})))},O=function(e){var t=e.forward,n=new Set,o=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)},i=function(e){n.delete(e.operation.key)};return function(e){return e=r.filter(o)(e),r.tap(i)(t(e))}};function b(e){return"query"===e.kind||"mutation"===e.kind}function E(e){return"query"!==e.kind&&"mutation"!==e.kind}var w=function(e){var n=e.forward;return function(e){var o=r.share(e);e=r.mergeMap((function(e){var n=e.key,i=r.filter((function(e){return"teardown"===e.kind&&e.key===n}))(o),u=t.makeFetchBody(e),a=t.makeFetchURL(e,u);return u=t.makeFetchOptions(e,u),r.onPush((function(e){}))(r.takeUntil(i)(t.makeFetchSource(e,a,u)))}))(r.filter(b)(o));var i=n(r.filter(E)(o));return r.merge([e,i])}};function _(){return!1}var S=function(e){function t(e){}return function(e){return r.filter(_)(r.tap(t)(e))}},R=S(),P=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)}},M=[O,g,w],D=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 o=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 i=r.makeSubject(),u=i.next;this.operations$=i.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=P(void 0!==e.exchanges?e.exchanges:M),this.results$=r.share(e({client:this,dispatchDebug:o,forward:S()})(this.operations$)),r.publish(this.results$)};function j(e){return e.data=s(e.data),e}D.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},D.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))}},D.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(j)(n)),"mutation"===e.kind)return r.take(1)(r.onStart((function(){return t.dispatchOperation(e)}))(n));var o=r.filter((function(t){return"teardown"===t.kind&&t.key===e.key}))(this.operations$),i=r.onEnd((function(){t.onOperationEnd(e)}))(r.onStart((function(){t.onOperationStart(e)}))(r.takeUntil(o)(n)));return"query"===e.kind&&e.context.pollInterval?r.switchMap((function(){return i}))(r.merge([r.fromValue(0),r.interval(e.context.pollInterval)])):i},D.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))},D.prototype.readQuery=function(e,n,o){var i=null;return r.subscribe((function(e){i=e}))(this.executeQuery(t.createRequest(e,n),o)).unsubscribe(),i},D.prototype.subscription=function(e,r,n){return this.executeSubscription(t.createRequest(e,r),n)},D.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=D,exports.cacheExchange=g,exports.composeExchanges=P,exports.createClient=function(e){return new D(e)},exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=O,exports.defaultExchanges=M,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=R,exports.fetchExchange=w,exports.formatDocument=a,exports.gql=function(){for(var r=arguments,n=Array.isArray(arguments[0])?arguments[0][0]:arguments[0]||"",o=1;o<arguments.length;o++){var i=r[o];n+=i&&i.kind===e.Kind.DOCUMENT?i.loc?i.loc.source.body:e.print(i):i,n+=r[0][o]}return(r=t.keyDocument(n)).loc={start:0,end:n.length,source:new e.Source(n,"gql")},r},exports.makeOperation=f,exports.maskTypename=s,exports.ssrExchange=function(e){function n(){for(var e;e=c.shift();)delete s[e]}function o(e){return!p(e)}function i(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;h(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(d)},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!h(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(o)(p)),p=r.map(i)(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 o(e){return"subscription"===(e=e.kind)||!!u&&("query"===e||"mutation"===e)}var i=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 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){function r(e){return c(t.makeResult(n,e))}function i(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=o.subscribe({next:r,error:i,complete:u}))})),function(){l=!0,s&&s.unsubscribe()}}))},p=o;return function(e){var t=r.share(e);e=r.mergeMap((function(e){var n=e.key,o=r.filter((function(e){return"teardown"===e.kind&&e.key===n}))(t);return r.takeUntil(o)(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.15.2",
"version": "1.16.0",
"description": "The shared core for the highly customizable and versatile GraphQL client",

@@ -59,4 +59,3 @@ "sideEffects": false,

"devDependencies": {
"graphql": "^15.4.0",
"graphql-tag": "^2.10.1"
"graphql": "^15.4.0"
},

@@ -63,0 +62,0 @@ "peerDependencies": {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc