Socket
Socket
Sign inDemoInstall

@urql/core

Package Overview
Dependencies
Maintainers
31
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.10.6 to 1.10.7

6

CHANGELOG.md
# @urql/core
## 1.10.7
### Patch Changes
- ⚠️ Fix oversight in edge case for #662. The operation queue wasn't marked as being active which caused `stale` results and `cache-and-network` operations from reissuing operations immediately (unqueued essentially) which would then be filtered out by the `dedupExchange`, by [@kitten](https://github.com/kitten) (See [#669](https://github.com/FormidableLabs/urql/pull/669))
## 1.10.6

@@ -4,0 +10,0 @@

1

dist/types/client.d.ts

@@ -32,3 +32,2 @@ import { Source } from 'wonka';

fetchOptions?: RequestInit | (() => RequestInit);
exchange: Exchange;
suspense: boolean;

@@ -35,0 +34,0 @@ preferGetMethod: boolean;

@@ -27,3 +27,3 @@ "use strict";

function b(b) {
var c = b.networkError, e = b.response;
var c = b.networkError, f = b.response;
var g = function(a, b) {

@@ -44,3 +44,3 @@ var d = "";

this.networkError = c;
this.response = e;
this.response = f;
}

@@ -70,4 +70,4 @@ a && (b.__proto__ = a);

0 < c && (b += ",");
var e = stringify(a[c]);
b += 0 < e.length ? e : "null";
var f = stringify(a[c]);
b += 0 < f.length ? f : "null";
}

@@ -83,5 +83,5 @@ return b + "]";

d = 0;
for (e = b.length; d < e; d++) {
var g = b[d], f = stringify(a[g]);
f && (1 < c.length && (c += ","), c += stringify(g) + ":" + f);
for (f = b.length; d < f; d++) {
var g = b[d], e = stringify(a[g]);
e && (1 < c.length && (c += ","), c += stringify(g) + ":" + e);
}

@@ -145,4 +145,3 @@ seen.delete(a);

for (var d in a) {
var e = a[d];
"__typename" === d && "string" == typeof e ? b.push(e) : collectTypes(e, b);
"__typename" === d && "string" == typeof a[d] ? b.push(a[d]) : collectTypes(a[d], b);
}

@@ -166,8 +165,3 @@ }

var formatNode = function(a) {
if (!a.selectionSet) {
return !1;
}
if (!function(a) {
return a.selections.some(_ref3);
}(a.selectionSet)) {
if (a.selectionSet && !a.selectionSet.selections.some(_ref3)) {
return a.selectionSet.selections.push({

@@ -248,3 +242,3 @@ kind: graphql.Kind.FIELD,

});
"cache-and-network" === a.context.requestPolicy && (b.stale = !0, reexecuteOperation(f, a));
"cache-and-network" === a.context.requestPolicy && (b.stale = !0, reexecuteOperation(e, a));
return b;

@@ -258,8 +252,8 @@ }

}
function e(a) {
function f(a) {
return !shouldSkip$1(a) && !n(a);
}
var g = a.forward, f = a.client, h = new Map;
var g = a.forward, e = a.client, h = new Map;
a = Object.create(null);
var k = _ref$1, l = afterMutation(h, a, f), m = afterQuery(h, a), n = function(a) {
var k = _ref$1, l = afterMutation(h, a, e), m = afterQuery(h, a), n = function(a) {
var c = a.context.requestPolicy;

@@ -269,6 +263,6 @@ return "query" === a.operationName && "network-only" !== c && ("cache-only" === c || h.has(a.key));

return function(a) {
var f = wonka.share(a);
a = wonka.map(b)(wonka.filter(c)(f));
f = wonka.tap(d)(g(wonka.filter(_ref5)(wonka.map(_ref6)(wonka.merge([ wonka.map(k)(wonka.filter(e)(f)), wonka.filter(_ref8)(f) ])))));
return wonka.merge([ a, f ]);
var e = wonka.share(a);
a = wonka.map(b)(wonka.filter(c)(e));
e = wonka.tap(d)(g(wonka.filter(_ref5)(wonka.map(_ref6)(wonka.merge([ wonka.map(k)(wonka.filter(f)(e)), wonka.filter(_ref8)(e) ])))));
return wonka.merge([ a, e ]);
};

@@ -293,4 +287,4 @@ }, reexecuteOperation = function(a, b) {

}
var e = new Set, h = a.operation.context.additionalTypenames;
collectTypesFromResponse(a.data).concat(h || []).forEach((function(a) {
var e = new Set, f = a.operation.context.additionalTypenames;
collectTypesFromResponse(a.data).concat(f || []).forEach((function(a) {
(a = b[a] || (b[a] = new Set)).forEach(c);

@@ -303,6 +297,6 @@ a.clear();

return function(c) {
var d = c.operation, e = c.data, g = d.context.additionalTypenames;
null != e && (a.set(d.key, {
var d = c.operation, f = c.data, g = d.context.additionalTypenames;
null != f && (a.set(d.key, {
operation: d,
data: e,
data: f,
error: c.error

@@ -335,3 +329,3 @@ }), collectTypesFromResponse(c.data).concat(g || []).forEach((function(a) {

return !a;
}, e = function(a) {
}, f = function(a) {
c.delete(a.operation.key);

@@ -341,3 +335,3 @@ };

a = wonka.filter(d)(a);
return wonka.tap(e)(b(a));
return wonka.tap(f)(b(a));
};

@@ -364,4 +358,4 @@ };

}))(wonka.filter(_ref$2)(c));
var e = b(wonka.filter(_ref2$2)(c));
return wonka.merge([ a, e ]);
var f = b(wonka.filter(_ref2$2)(c));
return wonka.merge([ a, f ]);
};

@@ -379,5 +373,5 @@ };

return wonka.make((function(c) {
var d = c.next, e = c.complete, g = "undefined" != typeof AbortController ? new AbortController : void 0;
var d = c.next, f = c.complete, g = "undefined" != typeof AbortController ? new AbortController : void 0;
c = "function" == typeof (c = a.context).fetchOptions ? c.fetchOptions() : c.fetchOptions || {};
var f = function(a) {
var e = function(a) {
return (a = a.definitions.find(_ref3$2)) ? a.name.value : null;

@@ -388,3 +382,3 @@ }(a.query), h = {

};
null !== f && (h.operationName = f);
null !== e && (h.operationName = e);
var k = _extends({}, c, {

@@ -403,3 +397,3 @@ body: b ? void 0 : JSON.stringify(h),

})).then((function(a) {
l || (l = !0, a && d(a), e());
l || (l = !0, a && d(a), f());
}));

@@ -480,6 +474,6 @@ return function() {

a = b.createRequestOperation("query", a, c);
var e = b.executeRequestOperation(a);
var g = b.executeRequestOperation(a);
return (a = a.context.pollInterval) ? wonka.switchMap((function d() {
return e;
}))(wonka.merge([ wonka.fromValue(0), wonka.interval(a) ])) : e;
return g;
}))(wonka.merge([ wonka.fromValue(0), wonka.interval(a) ])) : g;
};

@@ -506,14 +500,16 @@ this.executeSubscription = function(a, c) {

this.operations$ = c.source;
var e = !1;
var f = !1;
this.dispatchOperation = function(a) {
a && d(a);
if (!e) {
for (e = !0; a = b.queue.shift(); ) {
if (f) {
a && d(a);
} else {
f = !0;
for (a && d(a); a = b.queue.shift(); ) {
d(a);
}
e = !1;
f = !1;
}
};
this.exchange = composeExchanges(void 0 !== a.exchanges ? a.exchanges : defaultExchanges);
this.results$ = wonka.share(this.exchange({
a = composeExchanges(void 0 !== a.exchanges ? a.exchanges : defaultExchanges);
this.results$ = wonka.share(a({
client: this,

@@ -544,7 +540,7 @@ forward: fallbackExchangeIO

Client.prototype.executeRequestOperation = function(a) {
var c = this, d = a.key, e = a.operationName, g = wonka.filter((function(a) {
var c = this, d = a.key, f = a.operationName, g = wonka.filter((function(a) {
return a.operation.key === d;
}))(this.results$);
this.maskTypename && (g = wonka.map(_ref2$4)(g));
if ("mutation" === e) {
if ("mutation" === f) {
return wonka.take(1)(wonka.onStart((function b() {

@@ -554,3 +550,3 @@ return c.dispatchOperation(a);

}
var f = wonka.filter((function(a) {
var e = wonka.filter((function(a) {
return "teardown" === a.operationName && a.key === d;

@@ -562,13 +558,13 @@ }))(this.operations$);

c.onOperationStart(a);
}))(wonka.takeUntil(f)(g)));
return !1 !== a.context.suspense && this.suspense && "query" === e ? function(a) {
}))(wonka.takeUntil(e)(g)));
return !1 !== a.context.suspense && this.suspense && "query" === f ? function(a) {
return function(b) {
var c = wonka.share(a), d = !1, e = !1;
var c = wonka.share(a), d = !1, f = !1;
wonka.onPush((function() {
return d = !0;
}))(wonka.takeWhile((function() {
return !e;
return !f;
}))(c))(b);
if (!d) {
throw e = !0, b(0), wonka.toPromise(wonka.take(1)(c));
throw f = !0, b(0), wonka.toPromise(wonka.take(1)(c));
}

@@ -653,3 +649,3 @@ };

};
}(a, f[a.key]);
}(a, e[a.key]);
}

@@ -659,3 +655,3 @@ function d(a) {

}
function e(a) {
function f(a) {
var b = a.operation;

@@ -673,24 +669,24 @@ shouldSkip(b) || (a = function(a) {

return a;
}(a), f[b.key] = a);
}(a), e[b.key] = a);
}
function g(a) {
delete f[a.operation.key];
delete e[a.operation.key];
}
var f = {}, h = function(a) {
return !shouldSkip(a) && void 0 !== f[a.key];
}, k = function(f) {
var h = f.client, k = f.forward;
return function(f) {
var p = a && "boolean" == typeof a.isClient ? !!a.isClient : !h.suspense, m = wonka.share(f);
f = k(wonka.filter(b)(m));
var e = {}, h = function(a) {
return !shouldSkip(a) && void 0 !== e[a.key];
}, k = function(e) {
var h = e.client, k = e.forward;
return function(e) {
var p = a && "boolean" == typeof a.isClient ? !!a.isClient : !h.suspense, m = wonka.share(e);
e = k(wonka.filter(b)(m));
m = wonka.map(c)(wonka.filter(d)(m));
p ? m = wonka.tap(g)(m) : f = wonka.tap(e)(f);
return wonka.merge([ f, m ]);
p ? m = wonka.tap(g)(m) : e = wonka.tap(f)(e);
return wonka.merge([ e, m ]);
};
};
k.restoreData = function(a) {
return _extends(f, a);
return _extends(e, a);
};
k.extractData = function() {
return _extends({}, f);
return _extends({}, e);
};

@@ -712,3 +708,3 @@ a && a.initialState && k.restoreData(a.initialState);

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

@@ -754,3 +750,3 @@ key: a.key.toString(36),

}))(wonka.filter(l)(b));
var c = e(wonka.filter(g)(b));
var c = f(wonka.filter(g)(b));
return wonka.merge([ a, c ]);

@@ -757,0 +753,0 @@ };

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

"use strict";var e=require("wonka"),t=require("graphql");function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n=function(e){return"string"==typeof e?new t.GraphQLError(e):"object"==typeof e&&e.message?new t.GraphQLError(e.message,e.nodes,e.source,e.positions,e.path,e,e.extensions||{}):e};function o(){return this.message}var i=function(e){function t(t){var r=t.networkError,o=t.response,i=function(e,t){var r="";return void 0!==e?r="[Network] "+e.message:(void 0!==t&&t.forEach((function(e){r+="[GraphQL] "+e.message+"\n"})),r.trim())}(r,t=(t.graphQLErrors||[]).map(n));e.call(this,i),this.name="CombinedError",this.message=i,this.graphQLErrors=t,this.networkError=r,this.response=o}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.toString=o,t}(Error),a=function(e,t){e|=0;for(var r=0,n=0|t.length;r<n;r++)e=(e<<5)+e+t.charCodeAt(r);return e},u=new Set,c=new WeakMap,s=function(e){if(null===e||u.has(e))return"null";if("object"!=typeof e)return JSON.stringify(e)||"";if(e.toJSON)return e.toJSON();if(Array.isArray(e)){for(var t="[",r=0,n=e.length;r<n;r++){0<r&&(t+=",");var o=s(e[r]);t+=0<o.length?o:"null"}return t+"]"}if(!(t=Object.keys(e).sort()).length&&e.constructor&&e.constructor!==Object)return t=c.get(e)||Math.random().toString(36).slice(2),c.set(e,t),'{"__key":"'+t+'"}';for(u.add(e),r="{",n=0,o=t.length;n<o;n++){var i=t[n],a=s(e[i]);a&&(1<r.length&&(r+=","),r+=s(i)+":"+a)}return u.delete(e),r+"}"},f=function(e){return u.clear(),s(e)},p=function(e){return function(e){return a(5381,e)>>>0}(e.replace(/[\s,]+/g," ").trim())},l=Object.create(null),h=function(e,r){if("string"==typeof e){var n=p(e);e=void 0!==l[n]?l[n]:t.parse(e)}else void 0!==e.__key?n=e.__key:(n=p(t.print(e)),e=void 0!==l[n]?l[n]:e);return l[n]=e,e.__key=n,{key:r?a(n,f(r))>>>0:n,query:e,variables:r||{}}},y=function(e,t){return r({},e,{context:r({},e.context,{meta:r({},e.context.meta,t)})})},d=function(e,t,r){return{operation:e,data:t.data,error:Array.isArray(t.errors)?new i({graphQLErrors:t.errors,response:r}):void 0,extensions:"object"==typeof t.extensions&&t.extensions||void 0}},v=function(e,t,r){return{operation:e,data:void 0,error:new i({networkError:t,response:r}),extensions:void 0}},m=function(e,t){if(void 0===t&&(t=[]),Array.isArray(e))e.forEach((function(e){m(e,t)}));else if("object"==typeof e&&null!==e)for(var r in e){var n=e[r];"__typename"===r&&"string"==typeof n?t.push(n):m(n,t)}return t};function x(e,t,r){return r.indexOf(e)===t}var g=function(e){return m(e).filter(x)};function k(e){return e.kind===t.Kind.FIELD&&"__typename"===e.name.value}var O=function(e){return!!e.selectionSet&&(function(e){return e.selections.some(k)}(e.selectionSet)?void 0:(e.selectionSet.selections.push({kind:t.Kind.FIELD,name:{kind:t.Kind.NAME,value:"__typename"}}),e))},b=function(e){return t.visit(e,{Field:O,InlineFragment:O})},E=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(E):n&&"object"==typeof n&&"__typename"in n?E(n):n,t}),{}):e};function q(t){return t.toPromise=function(){return e.toPromise(e.take(1)(t))},t}var w=function(e){return"subscription"!==(e=e.operationName)&&"query"!==e};function N(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}var S=function(e){return"mutation"!==(e=e.operationName)&&"query"!==e};function _(e){return r({},e,{query:b(e.query)})}function j(e){return"query"!==e.operationName||"cache-only"!==e.context.requestPolicy}function P(e){return y(e,{cacheOutcome:"miss"})}function Q(e){return S(e)}var A=function(t){function n(e){var t=s.get(e.key);return t=r({},t,{operation:y(e,{cacheOutcome:t?"hit":"miss"})}),"cache-and-network"===e.context.requestPolicy&&(t.stale=!0,R(c,e)),t}function o(e){return!S(e)&&h(e)}function i(e){e.operation&&"mutation"===e.operation.operationName?p(e):e.operation&&"query"===e.operation.operationName&&l(e)}function a(e){return!S(e)&&!h(e)}var u=t.forward,c=t.client,s=new Map;t=Object.create(null);var f=_,p=L(s,t,c),l=M(s,t),h=function(e){var t=e.context.requestPolicy;return"query"===e.operationName&&"network-only"!==t&&("cache-only"===t||s.has(e.key))};return function(t){var r=e.share(t);return t=e.map(n)(e.filter(o)(r)),r=e.tap(i)(u(e.filter(j)(e.map(P)(e.merge([e.map(f)(e.filter(a)(r)),e.filter(Q)(r)]))))),e.merge([t,r])}},R=function(e,t){return e.reexecuteOperation(r({},t,{context:r({},t.context,{requestPolicy:"network-only"})}))},L=function(e,t,r){function n(t){if(e.has(t)){var n=e.get(t).operation;e.delete(t),R(r,n)}}return function(e){function r(e){o.add(e)}var o=new Set,i=e.operation.context.additionalTypenames;g(e.data).concat(i||[]).forEach((function(e){(e=t[e]||(t[e]=new Set)).forEach(r),e.clear()})),o.forEach(n)}},M=function(e,t){return function(r){var n=r.operation,o=r.data,i=n.context.additionalTypenames;null!=o&&(e.set(n.key,{operation:n,data:o,error:r.error}),g(r.data).concat(i||[]).forEach((function(e){(t[e]||(t[e]=new Set)).add(n.key)})))}},C=function(t){var r=t.forward,n=new Set,o=function(e){var t=e.key;return"teardown"===(e=e.operationName)?(n.delete(t),!0):"query"!==e&&"subscription"!==e||(e=n.has(t),n.add(t),!e)},i=function(e){n.delete(e.operation.key)};return function(t){return t=e.filter(o)(t),e.tap(i)(r(t))}};function I(e){return"query"===e.operationName||"mutation"===e.operationName}function T(e){return"query"!==e.operationName&&"mutation"!==e.operationName}var G=function(t){var r=t.forward;return function(t){var n=e.share(t);t=e.mergeMap((function(t){var r=t.key,o=e.filter((function(e){return"teardown"===e.operationName&&e.key===r}))(n);return e.takeUntil(o)($(t,"query"===t.operationName&&!!t.context.preferGetMethod))}))(e.filter(I)(n));var o=r(e.filter(T)(n));return e.merge([t,o])}};function D(e){return e.kind===t.Kind.OPERATION_DEFINITION&&e.name}var $=function(n,o){return e.make((function(e){var i=e.next,a=e.complete,u="undefined"!=typeof AbortController?new AbortController:void 0;e="function"==typeof(e=n.context).fetchOptions?e.fetchOptions():e.fetchOptions||{};var c=function(e){return(e=e.definitions.find(D))?e.name.value:null}(n.query),s={query:t.print(n.query),variables:n.variables};null!==c&&(s.operationName=c);var f=r({},e,{body:o?void 0:JSON.stringify(s),method:o?"GET":"POST",headers:r({},{"content-type":"application/json"},e.headers),signal:void 0!==u?u.signal:void 0});o&&(n.context.url=J(n.context.url,s));var p=!1;return Promise.resolve().then((function(){return p?void 0:F(n,f)})).then((function(e){p||(p=!0,e&&i(e),a())})),function(){p=!0,void 0!==u&&u.abort()}}))},F=function(e,t){var r,n=e.context;return(n.fetch||fetch)(n.url,t).then((function(e){var n=e.status;if(r=e,200>n||n>=("manual"===t.redirect?400:300))throw Error(e.statusText);return e.json()})).then((function(t){return d(e,t,r)})).catch((function(t){if("AbortError"!==t.name)return v(e,t,r)}))},J=function(e,t){var r=["query="+encodeURIComponent(t.query)];return t.variables&&r.push("variables="+encodeURIComponent(JSON.stringify(t.variables))),e+"?"+r.join("&")};function U(){return!1}function K(e){}var V=function(t){return e.filter(U)(e.tap(K)(t))},W=function(e){return 1===e.length?e[0]:function(t){return e.reduceRight((function(e,r){return r({client:t.client,forward:e})}),t.forward)}},z=[C,A,G],B=function(t){var n=this;this.activeOperations=Object.create(null),this.queue=[],this.createOperationContext=function(e){return r({},{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod},e,{requestPolicy:(e||{}).requestPolicy||n.requestPolicy})},this.createRequestOperation=function(e,t,r){return{key:t.key,query:t.query,variables:t.variables,operationName:e,context:n.createOperationContext(r)}},this.reexecuteOperation=function(e){0<(n.activeOperations[e.key]||0)&&(n.queue.push(e),n.dispatchOperation())},this.executeQuery=function(t,r){t=n.createRequestOperation("query",t,r);var o=n.executeRequestOperation(t);return(t=t.context.pollInterval)?e.switchMap((function(){return o}))(e.merge([e.fromValue(0),e.interval(t)])):o},this.executeSubscription=function(e,t){return e=n.createRequestOperation("subscription",e,t),n.executeRequestOperation(e)},this.executeMutation=function(e,t){return e=n.createRequestOperation("mutation",e,t),n.executeRequestOperation(e)},this.url=t.url,this.fetchOptions=t.fetchOptions,this.fetch=t.fetch,this.suspense=!!t.suspense,this.requestPolicy=t.requestPolicy||"cache-first",this.preferGetMethod=!!t.preferGetMethod,this.maskTypename=!!t.maskTypename;var o=e.makeSubject(),i=o.next;this.operations$=o.source;var a=!1;this.dispatchOperation=function(e){if(e&&i(e),!a){for(a=!0;e=n.queue.shift();)i(e);a=!1}},this.exchange=W(void 0!==t.exchanges?t.exchanges:z),this.results$=e.share(this.exchange({client:this,forward:V})(this.operations$)),e.publish(this.results$)};function H(e){return e.data=E(e.data),e}B.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},B.prototype.onOperationEnd=function(e){var t=e.key,n=this.activeOperations[t]||0;0>=(this.activeOperations[t]=0>=n?0:n-1)&&this.dispatchOperation(r({},e,{operationName:"teardown"}))},B.prototype.executeRequestOperation=function(t){var r=this,n=t.key,o=t.operationName,i=e.filter((function(e){return e.operation.key===n}))(this.results$);if(this.maskTypename&&(i=e.map(H)(i)),"mutation"===o)return e.take(1)(e.onStart((function(){return r.dispatchOperation(t)}))(i));var a=e.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(this.operations$);return i=e.onEnd((function(){r.onOperationEnd(t)}))(e.onStart((function(){r.onOperationStart(t)}))(e.takeUntil(a)(i))),!1!==t.context.suspense&&this.suspense&&"query"===o?function(t){return function(r){var n=e.share(t),o=!1,i=!1;if(e.onPush((function(){return o=!0}))(e.takeWhile((function(){return!i}))(n))(r),!o)throw i=!0,r(0),e.toPromise(e.take(1)(n))}}(i):i},B.prototype.query=function(e,t,n){return n&&"boolean"==typeof n.suspense||(n=r({},n,{suspense:!1})),q(this.executeQuery(h(e,t),n))},B.prototype.readQuery=function(t,r,n){var o=null;return e.subscribe((function(e){o=e}))(this.executeQuery(h(t,r),n)).unsubscribe(),o},B.prototype.mutation=function(e,t,r){return q(this.executeMutation(h(e,t),r))},exports.Client=B,exports.CombinedError=i,exports.cacheExchange=A,exports.composeExchanges=W,exports.createClient=function(e){return new B(e)},exports.createRequest=h,exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=C,exports.defaultExchanges=z,exports.fallbackExchangeIO=V,exports.fetchExchange=G,exports.formatDocument=b,exports.makeErrorResult=v,exports.makeResult=d,exports.maskTypename=E,exports.ssrExchange=function(t){function n(e){return!f(e)}function o(e){return function(e,t){var r=t.error;return{operation:e,data:t.data,extensions:void 0,error:r?new i({networkError:r.networkError?Error(r.networkError):void 0,graphQLErrors:r.graphQLErrors&&r.graphQLErrors.length?r.graphQLErrors:void 0}):void 0}}(e,s[e.key])}function a(e){return f(e)}function u(e){var t=e.operation;w(t)||(e=function(e){var t=e.error;return e={data:e.data,error:void 0},t&&(e.error={graphQLErrors:t.graphQLErrors.map(N),networkError:t.networkError?""+t.networkError:void 0}),e}(e),s[t.key]=e)}function c(e){delete s[e.operation.key]}var s={},f=function(e){return!w(e)&&void 0!==s[e.key]},p=function(r){var i=r.client,s=r.forward;return function(r){var f=t&&"boolean"==typeof t.isClient?!!t.isClient:!i.suspense,p=e.share(r);return r=s(e.filter(n)(p)),p=e.map(o)(e.filter(a)(p)),f?p=e.tap(c)(p):r=e.tap(u)(r),e.merge([r,p])}};return p.restoreData=function(e){return r(s,e)},p.extractData=function(){return r({},s)},t&&t.initialState&&p.restoreData(t.initialState),p},exports.stringifyVariables=f,exports.subscriptionExchange=function(n){function o(e){return"subscription"===(e=e.operationName)||!!a&&("query"===e||"mutation"===e)}var i=n.forwardSubscription,a=n.enableAllOperations;return function(n){function a(e){return!f(e)}var u=n.client,c=n.forward,s=function(n){var o=i({key:n.key.toString(36),query:t.print(n.query),variables:n.variables,context:r({},n.context)});return e.make((function(e){function t(e){return s(d(n,e))}function i(e){return s(v(n,e))}function a(){p||(p=!0,"subscription"===n.operationName&&u.reexecuteOperation(r({},n,{operationName:"teardown"})),f())}var c,s=e.next,f=e.complete,p=!1;return Promise.resolve().then((function(){p||(c=o.subscribe({next:t,error:i,complete:a}))})),function(){p=!0,c&&c.unsubscribe()}}))},f=o;return function(t){var r=e.share(t);t=e.mergeMap((function(t){var n=t.key,o=e.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(r);return e.takeUntil(o)(s(t))}))(e.filter(f)(r));var n=c(e.filter(a)(r));return e.merge([t,n])}}};
"use strict";var e=require("wonka"),t=require("graphql");function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n=function(e){return"string"==typeof e?new t.GraphQLError(e):"object"==typeof e&&e.message?new t.GraphQLError(e.message,e.nodes,e.source,e.positions,e.path,e,e.extensions||{}):e};function o(){return this.message}var i=function(e){function t(t){var r=t.networkError,o=t.response,i=function(e,t){var r="";return void 0!==e?r="[Network] "+e.message:(void 0!==t&&t.forEach((function(e){r+="[GraphQL] "+e.message+"\n"})),r.trim())}(r,t=(t.graphQLErrors||[]).map(n));e.call(this,i),this.name="CombinedError",this.message=i,this.graphQLErrors=t,this.networkError=r,this.response=o}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.toString=o,t}(Error),a=function(e,t){e|=0;for(var r=0,n=0|t.length;r<n;r++)e=(e<<5)+e+t.charCodeAt(r);return e},u=new Set,c=new WeakMap,s=function(e){if(null===e||u.has(e))return"null";if("object"!=typeof e)return JSON.stringify(e)||"";if(e.toJSON)return e.toJSON();if(Array.isArray(e)){for(var t="[",r=0,n=e.length;r<n;r++){0<r&&(t+=",");var o=s(e[r]);t+=0<o.length?o:"null"}return t+"]"}if(!(t=Object.keys(e).sort()).length&&e.constructor&&e.constructor!==Object)return t=c.get(e)||Math.random().toString(36).slice(2),c.set(e,t),'{"__key":"'+t+'"}';for(u.add(e),r="{",n=0,o=t.length;n<o;n++){var i=t[n],a=s(e[i]);a&&(1<r.length&&(r+=","),r+=s(i)+":"+a)}return u.delete(e),r+"}"},f=function(e){return u.clear(),s(e)},p=function(e){return function(e){return a(5381,e)>>>0}(e.replace(/[\s,]+/g," ").trim())},l=Object.create(null),h=function(e,r){if("string"==typeof e){var n=p(e);e=void 0!==l[n]?l[n]:t.parse(e)}else void 0!==e.__key?n=e.__key:(n=p(t.print(e)),e=void 0!==l[n]?l[n]:e);return l[n]=e,e.__key=n,{key:r?a(n,f(r))>>>0:n,query:e,variables:r||{}}},y=function(e,t){return r({},e,{context:r({},e.context,{meta:r({},e.context.meta,t)})})},d=function(e,t,r){return{operation:e,data:t.data,error:Array.isArray(t.errors)?new i({graphQLErrors:t.errors,response:r}):void 0,extensions:"object"==typeof t.extensions&&t.extensions||void 0}},v=function(e,t,r){return{operation:e,data:void 0,error:new i({networkError:t,response:r}),extensions:void 0}},m=function(e,t){if(void 0===t&&(t=[]),Array.isArray(e))e.forEach((function(e){m(e,t)}));else if("object"==typeof e&&null!==e)for(var r in e)"__typename"===r&&"string"==typeof e[r]?t.push(e[r]):m(e[r],t);return t};function x(e,t,r){return r.indexOf(e)===t}var g=function(e){return m(e).filter(x)};function k(e){return e.kind===t.Kind.FIELD&&"__typename"===e.name.value}var O=function(e){if(e.selectionSet&&!e.selectionSet.selections.some(k))return e.selectionSet.selections.push({kind:t.Kind.FIELD,name:{kind:t.Kind.NAME,value:"__typename"}}),e},b=function(e){return t.visit(e,{Field:O,InlineFragment:O})},E=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(E):n&&"object"==typeof n&&"__typename"in n?E(n):n,t}),{}):e};function q(t){return t.toPromise=function(){return e.toPromise(e.take(1)(t))},t}var w=function(e){return"subscription"!==(e=e.operationName)&&"query"!==e};function N(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}var S=function(e){return"mutation"!==(e=e.operationName)&&"query"!==e};function _(e){return r({},e,{query:b(e.query)})}function j(e){return"query"!==e.operationName||"cache-only"!==e.context.requestPolicy}function P(e){return y(e,{cacheOutcome:"miss"})}function Q(e){return S(e)}var A=function(t){function n(e){var t=s.get(e.key);return t=r({},t,{operation:y(e,{cacheOutcome:t?"hit":"miss"})}),"cache-and-network"===e.context.requestPolicy&&(t.stale=!0,R(c,e)),t}function o(e){return!S(e)&&h(e)}function i(e){e.operation&&"mutation"===e.operation.operationName?p(e):e.operation&&"query"===e.operation.operationName&&l(e)}function a(e){return!S(e)&&!h(e)}var u=t.forward,c=t.client,s=new Map;t=Object.create(null);var f=_,p=L(s,t,c),l=M(s,t),h=function(e){var t=e.context.requestPolicy;return"query"===e.operationName&&"network-only"!==t&&("cache-only"===t||s.has(e.key))};return function(t){var r=e.share(t);return t=e.map(n)(e.filter(o)(r)),r=e.tap(i)(u(e.filter(j)(e.map(P)(e.merge([e.map(f)(e.filter(a)(r)),e.filter(Q)(r)]))))),e.merge([t,r])}},R=function(e,t){return e.reexecuteOperation(r({},t,{context:r({},t.context,{requestPolicy:"network-only"})}))},L=function(e,t,r){function n(t){if(e.has(t)){var n=e.get(t).operation;e.delete(t),R(r,n)}}return function(e){function r(e){o.add(e)}var o=new Set,i=e.operation.context.additionalTypenames;g(e.data).concat(i||[]).forEach((function(e){(e=t[e]||(t[e]=new Set)).forEach(r),e.clear()})),o.forEach(n)}},M=function(e,t){return function(r){var n=r.operation,o=r.data,i=n.context.additionalTypenames;null!=o&&(e.set(n.key,{operation:n,data:o,error:r.error}),g(r.data).concat(i||[]).forEach((function(e){(t[e]||(t[e]=new Set)).add(n.key)})))}},C=function(t){var r=t.forward,n=new Set,o=function(e){var t=e.key;return"teardown"===(e=e.operationName)?(n.delete(t),!0):"query"!==e&&"subscription"!==e||(e=n.has(t),n.add(t),!e)},i=function(e){n.delete(e.operation.key)};return function(t){return t=e.filter(o)(t),e.tap(i)(r(t))}};function I(e){return"query"===e.operationName||"mutation"===e.operationName}function T(e){return"query"!==e.operationName&&"mutation"!==e.operationName}var G=function(t){var r=t.forward;return function(t){var n=e.share(t);t=e.mergeMap((function(t){var r=t.key,o=e.filter((function(e){return"teardown"===e.operationName&&e.key===r}))(n);return e.takeUntil(o)($(t,"query"===t.operationName&&!!t.context.preferGetMethod))}))(e.filter(I)(n));var o=r(e.filter(T)(n));return e.merge([t,o])}};function D(e){return e.kind===t.Kind.OPERATION_DEFINITION&&e.name}var $=function(n,o){return e.make((function(e){var i=e.next,a=e.complete,u="undefined"!=typeof AbortController?new AbortController:void 0;e="function"==typeof(e=n.context).fetchOptions?e.fetchOptions():e.fetchOptions||{};var c=function(e){return(e=e.definitions.find(D))?e.name.value:null}(n.query),s={query:t.print(n.query),variables:n.variables};null!==c&&(s.operationName=c);var f=r({},e,{body:o?void 0:JSON.stringify(s),method:o?"GET":"POST",headers:r({},{"content-type":"application/json"},e.headers),signal:void 0!==u?u.signal:void 0});o&&(n.context.url=J(n.context.url,s));var p=!1;return Promise.resolve().then((function(){return p?void 0:F(n,f)})).then((function(e){p||(p=!0,e&&i(e),a())})),function(){p=!0,void 0!==u&&u.abort()}}))},F=function(e,t){var r,n=e.context;return(n.fetch||fetch)(n.url,t).then((function(e){var n=e.status;if(r=e,200>n||n>=("manual"===t.redirect?400:300))throw Error(e.statusText);return e.json()})).then((function(t){return d(e,t,r)})).catch((function(t){if("AbortError"!==t.name)return v(e,t,r)}))},J=function(e,t){var r=["query="+encodeURIComponent(t.query)];return t.variables&&r.push("variables="+encodeURIComponent(JSON.stringify(t.variables))),e+"?"+r.join("&")};function U(){return!1}function K(e){}var V=function(t){return e.filter(U)(e.tap(K)(t))},W=function(e){return 1===e.length?e[0]:function(t){return e.reduceRight((function(e,r){return r({client:t.client,forward:e})}),t.forward)}},z=[C,A,G],B=function(t){var n=this;this.activeOperations=Object.create(null),this.queue=[],this.createOperationContext=function(e){return r({},{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod},e,{requestPolicy:(e||{}).requestPolicy||n.requestPolicy})},this.createRequestOperation=function(e,t,r){return{key:t.key,query:t.query,variables:t.variables,operationName:e,context:n.createOperationContext(r)}},this.reexecuteOperation=function(e){0<(n.activeOperations[e.key]||0)&&(n.queue.push(e),n.dispatchOperation())},this.executeQuery=function(t,r){t=n.createRequestOperation("query",t,r);var o=n.executeRequestOperation(t);return(t=t.context.pollInterval)?e.switchMap((function(){return o}))(e.merge([e.fromValue(0),e.interval(t)])):o},this.executeSubscription=function(e,t){return e=n.createRequestOperation("subscription",e,t),n.executeRequestOperation(e)},this.executeMutation=function(e,t){return e=n.createRequestOperation("mutation",e,t),n.executeRequestOperation(e)},this.url=t.url,this.fetchOptions=t.fetchOptions,this.fetch=t.fetch,this.suspense=!!t.suspense,this.requestPolicy=t.requestPolicy||"cache-first",this.preferGetMethod=!!t.preferGetMethod,this.maskTypename=!!t.maskTypename;var o=e.makeSubject(),i=o.next;this.operations$=o.source;var a=!1;this.dispatchOperation=function(e){if(a)e&&i(e);else{for(a=!0,e&&i(e);e=n.queue.shift();)i(e);a=!1}},t=W(void 0!==t.exchanges?t.exchanges:z),this.results$=e.share(t({client:this,forward:V})(this.operations$)),e.publish(this.results$)};function H(e){return e.data=E(e.data),e}B.prototype.onOperationStart=function(e){var t=e.key;this.activeOperations[t]=(this.activeOperations[t]||0)+1,this.dispatchOperation(e)},B.prototype.onOperationEnd=function(e){var t=e.key,n=this.activeOperations[t]||0;0>=(this.activeOperations[t]=0>=n?0:n-1)&&this.dispatchOperation(r({},e,{operationName:"teardown"}))},B.prototype.executeRequestOperation=function(t){var r=this,n=t.key,o=t.operationName,i=e.filter((function(e){return e.operation.key===n}))(this.results$);if(this.maskTypename&&(i=e.map(H)(i)),"mutation"===o)return e.take(1)(e.onStart((function(){return r.dispatchOperation(t)}))(i));var a=e.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(this.operations$);return i=e.onEnd((function(){r.onOperationEnd(t)}))(e.onStart((function(){r.onOperationStart(t)}))(e.takeUntil(a)(i))),!1!==t.context.suspense&&this.suspense&&"query"===o?function(t){return function(r){var n=e.share(t),o=!1,i=!1;if(e.onPush((function(){return o=!0}))(e.takeWhile((function(){return!i}))(n))(r),!o)throw i=!0,r(0),e.toPromise(e.take(1)(n))}}(i):i},B.prototype.query=function(e,t,n){return n&&"boolean"==typeof n.suspense||(n=r({},n,{suspense:!1})),q(this.executeQuery(h(e,t),n))},B.prototype.readQuery=function(t,r,n){var o=null;return e.subscribe((function(e){o=e}))(this.executeQuery(h(t,r),n)).unsubscribe(),o},B.prototype.mutation=function(e,t,r){return q(this.executeMutation(h(e,t),r))},exports.Client=B,exports.CombinedError=i,exports.cacheExchange=A,exports.composeExchanges=W,exports.createClient=function(e){return new B(e)},exports.createRequest=h,exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=C,exports.defaultExchanges=z,exports.fallbackExchangeIO=V,exports.fetchExchange=G,exports.formatDocument=b,exports.makeErrorResult=v,exports.makeResult=d,exports.maskTypename=E,exports.ssrExchange=function(t){function n(e){return!f(e)}function o(e){return function(e,t){var r=t.error;return{operation:e,data:t.data,extensions:void 0,error:r?new i({networkError:r.networkError?Error(r.networkError):void 0,graphQLErrors:r.graphQLErrors&&r.graphQLErrors.length?r.graphQLErrors:void 0}):void 0}}(e,s[e.key])}function a(e){return f(e)}function u(e){var t=e.operation;w(t)||(e=function(e){var t=e.error;return e={data:e.data,error:void 0},t&&(e.error={graphQLErrors:t.graphQLErrors.map(N),networkError:t.networkError?""+t.networkError:void 0}),e}(e),s[t.key]=e)}function c(e){delete s[e.operation.key]}var s={},f=function(e){return!w(e)&&void 0!==s[e.key]},p=function(r){var i=r.client,s=r.forward;return function(r){var f=t&&"boolean"==typeof t.isClient?!!t.isClient:!i.suspense,p=e.share(r);return r=s(e.filter(n)(p)),p=e.map(o)(e.filter(a)(p)),f?p=e.tap(c)(p):r=e.tap(u)(r),e.merge([r,p])}};return p.restoreData=function(e){return r(s,e)},p.extractData=function(){return r({},s)},t&&t.initialState&&p.restoreData(t.initialState),p},exports.stringifyVariables=f,exports.subscriptionExchange=function(n){function o(e){return"subscription"===(e=e.operationName)||!!a&&("query"===e||"mutation"===e)}var i=n.forwardSubscription,a=n.enableAllOperations;return function(n){function a(e){return!f(e)}var u=n.client,c=n.forward,s=function(n){var o=i({key:n.key.toString(36),query:t.print(n.query),variables:n.variables,context:r({},n.context)});return e.make((function(e){function t(e){return s(d(n,e))}function i(e){return s(v(n,e))}function a(){p||(p=!0,"subscription"===n.operationName&&u.reexecuteOperation(r({},n,{operationName:"teardown"})),f())}var c,s=e.next,f=e.complete,p=!1;return Promise.resolve().then((function(){p||(c=o.subscribe({next:t,error:i,complete:a}))})),function(){p=!0,c&&c.unsubscribe()}}))},f=o;return function(t){var r=e.share(t);t=e.mergeMap((function(t){var n=t.key,o=e.filter((function(e){return"teardown"===e.operationName&&e.key===n}))(r);return e.takeUntil(o)(s(t))}))(e.filter(f)(r));var n=c(e.filter(a)(r));return e.merge([t,n])}}};
//# sourceMappingURL=urql-core.min.js.map
{
"name": "@urql/core",
"version": "1.10.6",
"version": "1.10.7",
"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

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