Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@urql/core

Package Overview
Dependencies
Maintainers
19
Versions
265
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 5.0.1 to 5.0.2-canary-0f3c5c01

37

dist/urql-core.js

@@ -1046,8 +1046,13 @@ Object.defineProperty(exports, '__esModule', { value: true });

if (result.stale) {
// If the current result has queued up an operation of the same
// key, then `stale` refers to it
for (var _operation of queue) {
if (_operation.key === result.operation.key) {
dispatched.delete(_operation.key);
break;
if (!result.hasNext) {
// we are dealing with an optimistic mutation or a partial result
dispatched.delete(operation.key);
} else {
// If the current result has queued up an operation of the same
// key, then `stale` refers to it
for (var _operation of queue) {
if (_operation.key === result.operation.key) {
dispatched.delete(_operation.key);
break;
}
}

@@ -1078,8 +1083,20 @@ }

dispatchOperation(operation);
} else if (operation.kind === 'mutation' || active.has(operation.key)) {
var queued = false;
for (var i = 0; i < queue.length; i++) queued = queued || queue[i].key === operation.key;
if (!queued) dispatched.delete(operation.key);
} else if (operation.kind === 'mutation') {
queue.push(operation);
Promise.resolve().then(dispatchOperation);
} else if (active.has(operation.key)) {
var queued = false;
for (var i = 0; i < queue.length; i++) {
if (queue[i].key === operation.key) {
queue[i] = operation;
queued = true;
}
}
if (!queued && (!dispatched.has(operation.key) || operation.context.requestPolicy === 'network-only')) {
queue.push(operation);
Promise.resolve().then(dispatchOperation);
} else {
dispatched.delete(operation.key);
Promise.resolve().then(dispatchOperation);
}
}

@@ -1086,0 +1103,0 @@ },

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

Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@0no-co/graphql.web"),r=require("./urql-core-chunk.min.js"),t=require("wonka"),n=(e,r)=>{if(Array.isArray(e))for(var t of e)n(t,r);else if("object"==typeof e&&null!==e)for(var a in e)"__typename"===a&&"string"==typeof e[a]?r.add(e[a]):n(e[a],r);return r},a=r=>{if("definitions"in r){var t=[];for(var n of r.definitions){var o=a(n);t.push(o)}return{...r,definitions:t}}if("directives"in r&&r.directives&&r.directives.length){var i=[],s={};for(var u of r.directives){var c=u.name.value;"_"!==c[0]?i.push(u):c=c.slice(1),s[c]=u}r={...r,directives:i,_directives:s}}if("selectionSet"in r){var l=[],d=r.kind===e.Kind.OPERATION_DEFINITION;if(r.selectionSet){for(var p of r.selectionSet.selections||[]){d=d||p.kind===e.Kind.FIELD&&"__typename"===p.name.value&&!p.alias;var k=a(p);l.push(k)}return d||l.push({kind:e.Kind.FIELD,name:{kind:e.Kind.NAME,value:"__typename"},_generated:!0}),{...r,selectionSet:{...r.selectionSet,selections:l}}}}return r},o=new Map,i=e=>{var t=r.keyDocument(e),n=o.get(t.__key);return n||(o.set(t.__key,n=a(t)),Object.defineProperty(n,"__key",{value:t.__key,enumerable:!1})),n};function s(e,r,t){return{...r,kind:e,context:r.context?{...r.context,...t}:t||r.context}}var u=()=>{},c=({kind:e})=>"mutation"!==e&&"query"!==e,l=e=>{var r=i(e.query);if(r!==e.query){var t=s(e.kind,e);return t.query=r,t}return e},d=(e,r)=>e.reexecuteOperation(s(r.kind,r,{requestPolicy:"network-only"})),p=new Set,k=e=>({client:r,forward:n})=>e.reduceRight(((e,n)=>n({client:r,forward:r=>t.share(e(t.share(r))),dispatchDebug(e){}})),n),f=({onOperation:e,onResult:r,onError:n})=>({forward:a})=>o=>t.mergeMap((e=>{n&&e.error&&n(e.error,e.operation);var a=r&&r(e)||e;return"then"in a?t.fromPromise(a):t.fromValue(a)}))(a(t.mergeMap((r=>{var n=e&&e(r)||r;return"then"in n?t.fromPromise(n):t.fromValue(n)}))(o))),y=({})=>e=>t.filter((e=>!1))(e),h=function e(n){var a=0,o=new Map,i=new Map,c=new Set,l=[],d={url:n.url,fetchSubscriptions:n.fetchSubscriptions,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod,requestPolicy:n.requestPolicy||"cache-first"},p=t.makeSubject();function f(e){"mutation"!==e.kind&&"teardown"!==e.kind&&c.has(e.key)||("teardown"===e.kind?c.delete(e.key):"mutation"!==e.kind&&c.add(e.key),p.next(e))}var h=!1;function m(e){if(e&&f(e),!h){for(h=!0;h&&(e=l.shift());)f(e);h=!1}}var v=e=>{var r=t.takeUntil(t.filter((r=>"teardown"===r.kind&&r.key===e.key))(p.source))(t.filter((r=>r.operation.kind===e.kind&&r.operation.key===e.key&&(!r.operation.context._instance||r.operation.context._instance===e.context._instance)))(q));return r="query"!==e.kind?t.takeWhile((e=>!!e.hasNext),!0)(r):t.switchMap((r=>{var n=t.fromValue(r);return r.stale||r.hasNext?n:t.merge([n,t.map((()=>(r.stale=!0,r)))(t.take(1)(t.filter((r=>r.key===e.key))(p.source)))])}))(r),r="mutation"!==e.kind?t.onEnd((()=>{c.delete(e.key),o.delete(e.key),i.delete(e.key),h=!1;for(var r=l.length-1;r>=0;r--)l[r].key===e.key&&l.splice(r,1);f(s("teardown",e,e.context))}))(t.onPush((r=>{if(r.stale){for(var t of l)if(t.key===r.operation.key){c.delete(t.key);break}}else r.hasNext||c.delete(e.key);o.set(e.key,r)}))(r)):t.onStart((()=>{f(e)}))(r),t.share(r)},x=this instanceof e?this:Object.create(e.prototype),g=Object.assign(x,{suspense:!!n.suspense,operations$:p.source,reexecuteOperation(e){if("teardown"===e.kind)m(e);else if("mutation"===e.kind||i.has(e.key)){for(var r=!1,t=0;t<l.length;t++)r=r||l[t].key===e.key;r||c.delete(e.key),l.push(e),Promise.resolve().then(m)}},createRequestOperation:(e,r,t)=>(t||(t={}),s(e,r,{_instance:"mutation"===e?a=a+1|0:void 0,...d,...t,requestPolicy:t.requestPolicy||d.requestPolicy,suspense:t.suspense||!1!==t.suspense&&g.suspense})),executeRequestOperation:e=>{return r="mutation"===e.kind?v(e):t.lazy((()=>{var r=i.get(e.key);r||i.set(e.key,r=v(e)),r=t.onStart((()=>{m(e)}))(r);var n=o.get(e.key);return"query"===e.kind&&n&&(n.stale||n.hasNext)?t.switchMap(t.fromValue)(t.merge([r,t.filter((r=>r===o.get(e.key)))(t.fromValue(n))])):r})),(n=e=>r(e)).toPromise=()=>t.toPromise(t.take(1)(t.filter((e=>!e.stale&&!e.hasNext))(n))),n.then=(e,r)=>n.toPromise().then(e,r),n.subscribe=e=>t.subscribe(e)(n),n;var r,n},executeQuery(e,r){var t=g.createRequestOperation("query",e,r);return g.executeRequestOperation(t)},executeSubscription(e,r){var t=g.createRequestOperation("subscription",e,r);return g.executeRequestOperation(t)},executeMutation(e,r){var t=g.createRequestOperation("mutation",e,r);return g.executeRequestOperation(t)},readQuery(e,r,n){var a=null;return t.subscribe((e=>{a=e}))(g.query(e,r,n)).unsubscribe(),a},query:(e,t,n)=>g.executeQuery(r.createRequest(e,t),n),subscription:(e,t,n)=>g.executeSubscription(r.createRequest(e,t),n),mutation:(e,t,n)=>g.executeMutation(r.createRequest(e,t),n)}),w=u,b=k(n.exchanges),q=t.share(b({client:g,dispatchDebug:w,forward:y({dispatchDebug:w})})(p.source));return t.publish(q),g},m=h;exports.CombinedError=r.CombinedError,exports.createRequest=r.createRequest,exports.makeErrorResult=r.makeErrorResult,exports.makeResult=r.makeResult,exports.mergeResultPatch=r.mergeResultPatch,exports.stringifyDocument=r.stringifyDocument,exports.stringifyVariables=r.stringifyVariables,exports.Client=h,exports.cacheExchange=({forward:e,client:a})=>{var o=new Map,i=new Map,s=e=>"query"===e.kind&&"network-only"!==e.context.requestPolicy&&("cache-only"===e.context.requestPolicy||o.has(e.key));return u=>{var p=t.map((e=>{var t=o.get(e.key)||r.makeResult(e,{data:null});return t={...t,operation:e},"cache-and-network"===e.context.requestPolicy&&(t.stale=!0,d(a,e)),t}))(t.filter((e=>!c(e)&&s(e)))(u)),k=t.tap((e=>{var{operation:r}=e;if(r){var t=r.context.additionalTypenames||[];if("subscription"!==e.operation.kind&&(t=(e=>[...n(e,new Set)])(e.data).concat(t)),"mutation"===e.operation.kind||"subscription"===e.operation.kind){for(var s=new Set,u=0;u<t.length;u++){var c=t[u],l=i.get(c);for(var p of(l||i.set(c,l=new Set),l.values()))s.add(p);l.clear()}for(var k of s.values())o.has(k)&&(r=o.get(k).operation,o.delete(k),d(a,r))}else if("query"===r.kind&&e.data){o.set(r.key,e);for(var f=0;f<t.length;f++){var y=t[f],h=i.get(y);h||i.set(y,h=new Set),h.add(r.key)}}}}))(e(t.filter((e=>"query"!==e.kind||"cache-only"!==e.context.requestPolicy))(t.map((e=>e))(t.merge([t.map(l)(t.filter((e=>!c(e)&&!s(e)))(u)),t.filter((e=>c(e)))(u)])))));return t.merge([p,k])}},exports.composeExchanges=k,exports.createClient=m,exports.debugExchange=({forward:e})=>r=>e(r),exports.errorExchange=f,exports.fetchExchange=({forward:e})=>n=>{var a=t.mergeMap((e=>{var a=r.makeFetchBody(e),o=r.makeFetchURL(e,a),i=r.makeFetchOptions(e,a);return t.takeUntil(t.filter((r=>"teardown"===r.kind&&r.key===e.key))(n))(r.makeFetchSource(e,o,i))}))(t.filter((e=>"teardown"!==e.kind&&("subscription"!==e.kind||!!e.context.fetchSubscriptions)))(n)),o=e(t.filter((e=>"teardown"===e.kind||"subscription"===e.kind&&!e.context.fetchSubscriptions))(n));return t.merge([a,o])},exports.formatDocument=i,exports.gql=function(t){for(var n=new Map,a=[],o=[],i=Array.isArray(t)?t[0]:t||"",s=1;s<arguments.length;s++){var u=arguments[s];u&&u.definitions?o.push(u):i+=u,i+=arguments[0][s]}for(var c of(o.unshift(r.keyDocument(i)),o))for(var l of c.definitions)if(l.kind===e.Kind.FRAGMENT_DEFINITION){var d=l.name.value,p=r.stringifyDocument(l);n.has(d)||(n.set(d,p),a.push(l))}else a.push(l);return r.keyDocument({kind:e.Kind.DOCUMENT,definitions:a})},exports.makeOperation=s,exports.mapExchange=f,exports.ssrExchange=(e={})=>{var n=!!e.staleWhileRevalidate,a=!!e.includeExtensions,o={},i=[],s=e=>{i.push(e.operation.key),1===i.length&&Promise.resolve().then((()=>{for(var e;e=i.shift();)o[e]=null}))},u=({client:i,forward:u})=>c=>{var k=e&&"boolean"==typeof e.isClient?!!e.isClient:!i.suspense,f=u(t.map(l)(t.filter((e=>"teardown"===e.kind||!o[e.key]||!!o[e.key].hasNext||"network-only"===e.context.requestPolicy))(c))),y=t.map((e=>{var t=((e,t,n)=>({operation:e,data:t.data?JSON.parse(t.data):void 0,extensions:n&&t.extensions?JSON.parse(t.extensions):void 0,error:t.error?new r.CombinedError({networkError:t.error.networkError?new Error(t.error.networkError):void 0,graphQLErrors:t.error.graphQLErrors}):void 0,stale:!1,hasNext:!!t.hasNext}))(e,o[e.key],a);return n&&!p.has(e.key)&&(t.stale=!0,p.add(e.key),d(i,e)),{...t,operation:e}}))(t.filter((e=>"teardown"!==e.kind&&!!o[e.key]&&"network-only"!==e.context.requestPolicy))(c));return k?y=t.tap(s)(y):f=t.tap((e=>{var{operation:r}=e;if("mutation"!==r.kind){var t=((e,r)=>{var t={data:JSON.stringify(e.data),hasNext:e.hasNext};return void 0!==e.data&&(t.data=JSON.stringify(e.data)),r&&void 0!==e.extensions&&(t.extensions=JSON.stringify(e.extensions)),e.error&&(t.error={graphQLErrors:e.error.graphQLErrors.map((e=>e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message))},e.error.networkError&&(t.error.networkError=""+e.error.networkError)),t})(e,a);o[r.key]=t}}))(f),t.merge([f,y])};return u.restoreData=e=>{for(var r in e)null!==o[r]&&(o[r]=e[r])},u.extractData=()=>{var e={};for(var r in o)null!=o[r]&&(e[r]=o[r]);return e},e&&e.initialState&&u.restoreData(e.initialState),u},exports.subscriptionExchange=({forwardSubscription:e,enableAllOperations:n,isSubscriptionOperation:a})=>({client:o,forward:i})=>{var u=a||(e=>"subscription"===e.kind||!!n&&("query"===e.kind||"mutation"===e.kind));return n=>{var a=t.mergeMap((a=>{var{key:i}=a,u=t.filter((e=>"teardown"===e.kind&&e.key===i))(n);return t.takeUntil(u)((n=>{var a=e(r.makeFetchBody(n),n);return t.make((e=>{var t,i,u=!1;function c(t){e.next(i=i?r.mergeResultPatch(i,t):r.makeResult(n,t))}return Promise.resolve().then((()=>{u||(t=a.subscribe({next:c,error(t){Array.isArray(t)?c({errors:t}):e.next(r.makeErrorResult(n,t)),e.complete()},complete(){u||(u=!0,"subscription"===n.kind&&o.reexecuteOperation(s("teardown",n,n.context)),i&&i.hasNext&&c({hasNext:!1}),e.complete())}}))})),()=>{u=!0,t&&t.unsubscribe()}}))})(a))}))(t.filter((e=>"teardown"!==e.kind&&u(e)))(n)),c=i(t.filter((e=>"teardown"===e.kind||!u(e)))(n));return t.merge([a,c])}};
Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@0no-co/graphql.web"),r=require("./urql-core-chunk.min.js"),t=require("wonka"),n=(e,r)=>{if(Array.isArray(e))for(var t of e)n(t,r);else if("object"==typeof e&&null!==e)for(var o in e)"__typename"===o&&"string"==typeof e[o]?r.add(e[o]):n(e[o],r);return r},o=r=>{if("definitions"in r){var t=[];for(var n of r.definitions){var a=o(n);t.push(a)}return{...r,definitions:t}}if("directives"in r&&r.directives&&r.directives.length){var i=[],s={};for(var u of r.directives){var c=u.name.value;"_"!==c[0]?i.push(u):c=c.slice(1),s[c]=u}r={...r,directives:i,_directives:s}}if("selectionSet"in r){var l=[],d=r.kind===e.Kind.OPERATION_DEFINITION;if(r.selectionSet){for(var p of r.selectionSet.selections||[]){d=d||p.kind===e.Kind.FIELD&&"__typename"===p.name.value&&!p.alias;var k=o(p);l.push(k)}return d||l.push({kind:e.Kind.FIELD,name:{kind:e.Kind.NAME,value:"__typename"},_generated:!0}),{...r,selectionSet:{...r.selectionSet,selections:l}}}}return r},a=new Map,i=e=>{var t=r.keyDocument(e),n=a.get(t.__key);return n||(a.set(t.__key,n=o(t)),Object.defineProperty(n,"__key",{value:t.__key,enumerable:!1})),n};function s(e,r,t){return{...r,kind:e,context:r.context?{...r.context,...t}:t||r.context}}var u=()=>{},c=({kind:e})=>"mutation"!==e&&"query"!==e,l=e=>{var r=i(e.query);if(r!==e.query){var t=s(e.kind,e);return t.query=r,t}return e},d=(e,r)=>e.reexecuteOperation(s(r.kind,r,{requestPolicy:"network-only"})),p=new Set,k=e=>({client:r,forward:n})=>e.reduceRight(((e,n)=>n({client:r,forward:r=>t.share(e(t.share(r))),dispatchDebug(e){}})),n),f=({onOperation:e,onResult:r,onError:n})=>({forward:o})=>a=>t.mergeMap((e=>{n&&e.error&&n(e.error,e.operation);var o=r&&r(e)||e;return"then"in o?t.fromPromise(o):t.fromValue(o)}))(o(t.mergeMap((r=>{var n=e&&e(r)||r;return"then"in n?t.fromPromise(n):t.fromValue(n)}))(a))),y=({})=>e=>t.filter((e=>!1))(e),h=function e(n){var o=0,a=new Map,i=new Map,c=new Set,l=[],d={url:n.url,fetchSubscriptions:n.fetchSubscriptions,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod,requestPolicy:n.requestPolicy||"cache-first"},p=t.makeSubject();function f(e){"mutation"!==e.kind&&"teardown"!==e.kind&&c.has(e.key)||("teardown"===e.kind?c.delete(e.key):"mutation"!==e.kind&&c.add(e.key),p.next(e))}var h=!1;function m(e){if(e&&f(e),!h){for(h=!0;h&&(e=l.shift());)f(e);h=!1}}var v=e=>{var r=t.takeUntil(t.filter((r=>"teardown"===r.kind&&r.key===e.key))(p.source))(t.filter((r=>r.operation.kind===e.kind&&r.operation.key===e.key&&(!r.operation.context._instance||r.operation.context._instance===e.context._instance)))(q));return r="query"!==e.kind?t.takeWhile((e=>!!e.hasNext),!0)(r):t.switchMap((r=>{var n=t.fromValue(r);return r.stale||r.hasNext?n:t.merge([n,t.map((()=>(r.stale=!0,r)))(t.take(1)(t.filter((r=>r.key===e.key))(p.source)))])}))(r),r="mutation"!==e.kind?t.onEnd((()=>{c.delete(e.key),a.delete(e.key),i.delete(e.key),h=!1;for(var r=l.length-1;r>=0;r--)l[r].key===e.key&&l.splice(r,1);f(s("teardown",e,e.context))}))(t.onPush((r=>{if(r.stale)if(r.hasNext){for(var t of l)if(t.key===r.operation.key){c.delete(t.key);break}}else c.delete(e.key);else r.hasNext||c.delete(e.key);a.set(e.key,r)}))(r)):t.onStart((()=>{f(e)}))(r),t.share(r)},x=this instanceof e?this:Object.create(e.prototype),g=Object.assign(x,{suspense:!!n.suspense,operations$:p.source,reexecuteOperation(e){if("teardown"===e.kind)m(e);else if("mutation"===e.kind)l.push(e),Promise.resolve().then(m);else if(i.has(e.key)){for(var r=!1,t=0;t<l.length;t++)l[t].key===e.key&&(l[t]=e,r=!0);r||c.has(e.key)&&"network-only"!==e.context.requestPolicy?(c.delete(e.key),Promise.resolve().then(m)):(l.push(e),Promise.resolve().then(m))}},createRequestOperation:(e,r,t)=>(t||(t={}),s(e,r,{_instance:"mutation"===e?o=o+1|0:void 0,...d,...t,requestPolicy:t.requestPolicy||d.requestPolicy,suspense:t.suspense||!1!==t.suspense&&g.suspense})),executeRequestOperation:e=>{return r="mutation"===e.kind?v(e):t.lazy((()=>{var r=i.get(e.key);r||i.set(e.key,r=v(e)),r=t.onStart((()=>{m(e)}))(r);var n=a.get(e.key);return"query"===e.kind&&n&&(n.stale||n.hasNext)?t.switchMap(t.fromValue)(t.merge([r,t.filter((r=>r===a.get(e.key)))(t.fromValue(n))])):r})),(n=e=>r(e)).toPromise=()=>t.toPromise(t.take(1)(t.filter((e=>!e.stale&&!e.hasNext))(n))),n.then=(e,r)=>n.toPromise().then(e,r),n.subscribe=e=>t.subscribe(e)(n),n;var r,n},executeQuery(e,r){var t=g.createRequestOperation("query",e,r);return g.executeRequestOperation(t)},executeSubscription(e,r){var t=g.createRequestOperation("subscription",e,r);return g.executeRequestOperation(t)},executeMutation(e,r){var t=g.createRequestOperation("mutation",e,r);return g.executeRequestOperation(t)},readQuery(e,r,n){var o=null;return t.subscribe((e=>{o=e}))(g.query(e,r,n)).unsubscribe(),o},query:(e,t,n)=>g.executeQuery(r.createRequest(e,t),n),subscription:(e,t,n)=>g.executeSubscription(r.createRequest(e,t),n),mutation:(e,t,n)=>g.executeMutation(r.createRequest(e,t),n)}),w=u,b=k(n.exchanges),q=t.share(b({client:g,dispatchDebug:w,forward:y({dispatchDebug:w})})(p.source));return t.publish(q),g},m=h;exports.CombinedError=r.CombinedError,exports.createRequest=r.createRequest,exports.makeErrorResult=r.makeErrorResult,exports.makeResult=r.makeResult,exports.mergeResultPatch=r.mergeResultPatch,exports.stringifyDocument=r.stringifyDocument,exports.stringifyVariables=r.stringifyVariables,exports.Client=h,exports.cacheExchange=({forward:e,client:o})=>{var a=new Map,i=new Map,s=e=>"query"===e.kind&&"network-only"!==e.context.requestPolicy&&("cache-only"===e.context.requestPolicy||a.has(e.key));return u=>{var p=t.map((e=>{var t=a.get(e.key)||r.makeResult(e,{data:null});return t={...t,operation:e},"cache-and-network"===e.context.requestPolicy&&(t.stale=!0,d(o,e)),t}))(t.filter((e=>!c(e)&&s(e)))(u)),k=t.tap((e=>{var{operation:r}=e;if(r){var t=r.context.additionalTypenames||[];if("subscription"!==e.operation.kind&&(t=(e=>[...n(e,new Set)])(e.data).concat(t)),"mutation"===e.operation.kind||"subscription"===e.operation.kind){for(var s=new Set,u=0;u<t.length;u++){var c=t[u],l=i.get(c);for(var p of(l||i.set(c,l=new Set),l.values()))s.add(p);l.clear()}for(var k of s.values())a.has(k)&&(r=a.get(k).operation,a.delete(k),d(o,r))}else if("query"===r.kind&&e.data){a.set(r.key,e);for(var f=0;f<t.length;f++){var y=t[f],h=i.get(y);h||i.set(y,h=new Set),h.add(r.key)}}}}))(e(t.filter((e=>"query"!==e.kind||"cache-only"!==e.context.requestPolicy))(t.map((e=>e))(t.merge([t.map(l)(t.filter((e=>!c(e)&&!s(e)))(u)),t.filter((e=>c(e)))(u)])))));return t.merge([p,k])}},exports.composeExchanges=k,exports.createClient=m,exports.debugExchange=({forward:e})=>r=>e(r),exports.errorExchange=f,exports.fetchExchange=({forward:e})=>n=>{var o=t.mergeMap((e=>{var o=r.makeFetchBody(e),a=r.makeFetchURL(e,o),i=r.makeFetchOptions(e,o);return t.takeUntil(t.filter((r=>"teardown"===r.kind&&r.key===e.key))(n))(r.makeFetchSource(e,a,i))}))(t.filter((e=>"teardown"!==e.kind&&("subscription"!==e.kind||!!e.context.fetchSubscriptions)))(n)),a=e(t.filter((e=>"teardown"===e.kind||"subscription"===e.kind&&!e.context.fetchSubscriptions))(n));return t.merge([o,a])},exports.formatDocument=i,exports.gql=function(t){for(var n=new Map,o=[],a=[],i=Array.isArray(t)?t[0]:t||"",s=1;s<arguments.length;s++){var u=arguments[s];u&&u.definitions?a.push(u):i+=u,i+=arguments[0][s]}for(var c of(a.unshift(r.keyDocument(i)),a))for(var l of c.definitions)if(l.kind===e.Kind.FRAGMENT_DEFINITION){var d=l.name.value,p=r.stringifyDocument(l);n.has(d)||(n.set(d,p),o.push(l))}else o.push(l);return r.keyDocument({kind:e.Kind.DOCUMENT,definitions:o})},exports.makeOperation=s,exports.mapExchange=f,exports.ssrExchange=(e={})=>{var n=!!e.staleWhileRevalidate,o=!!e.includeExtensions,a={},i=[],s=e=>{i.push(e.operation.key),1===i.length&&Promise.resolve().then((()=>{for(var e;e=i.shift();)a[e]=null}))},u=({client:i,forward:u})=>c=>{var k=e&&"boolean"==typeof e.isClient?!!e.isClient:!i.suspense,f=u(t.map(l)(t.filter((e=>"teardown"===e.kind||!a[e.key]||!!a[e.key].hasNext||"network-only"===e.context.requestPolicy))(c))),y=t.map((e=>{var t=((e,t,n)=>({operation:e,data:t.data?JSON.parse(t.data):void 0,extensions:n&&t.extensions?JSON.parse(t.extensions):void 0,error:t.error?new r.CombinedError({networkError:t.error.networkError?new Error(t.error.networkError):void 0,graphQLErrors:t.error.graphQLErrors}):void 0,stale:!1,hasNext:!!t.hasNext}))(e,a[e.key],o);return n&&!p.has(e.key)&&(t.stale=!0,p.add(e.key),d(i,e)),{...t,operation:e}}))(t.filter((e=>"teardown"!==e.kind&&!!a[e.key]&&"network-only"!==e.context.requestPolicy))(c));return k?y=t.tap(s)(y):f=t.tap((e=>{var{operation:r}=e;if("mutation"!==r.kind){var t=((e,r)=>{var t={data:JSON.stringify(e.data),hasNext:e.hasNext};return void 0!==e.data&&(t.data=JSON.stringify(e.data)),r&&void 0!==e.extensions&&(t.extensions=JSON.stringify(e.extensions)),e.error&&(t.error={graphQLErrors:e.error.graphQLErrors.map((e=>e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message))},e.error.networkError&&(t.error.networkError=""+e.error.networkError)),t})(e,o);a[r.key]=t}}))(f),t.merge([f,y])};return u.restoreData=e=>{for(var r in e)null!==a[r]&&(a[r]=e[r])},u.extractData=()=>{var e={};for(var r in a)null!=a[r]&&(e[r]=a[r]);return e},e&&e.initialState&&u.restoreData(e.initialState),u},exports.subscriptionExchange=({forwardSubscription:e,enableAllOperations:n,isSubscriptionOperation:o})=>({client:a,forward:i})=>{var u=o||(e=>"subscription"===e.kind||!!n&&("query"===e.kind||"mutation"===e.kind));return n=>{var o=t.mergeMap((o=>{var{key:i}=o,u=t.filter((e=>"teardown"===e.kind&&e.key===i))(n);return t.takeUntil(u)((n=>{var o=e(r.makeFetchBody(n),n);return t.make((e=>{var t,i,u=!1;function c(t){e.next(i=i?r.mergeResultPatch(i,t):r.makeResult(n,t))}return Promise.resolve().then((()=>{u||(t=o.subscribe({next:c,error(t){Array.isArray(t)?c({errors:t}):e.next(r.makeErrorResult(n,t)),e.complete()},complete(){u||(u=!0,"subscription"===n.kind&&a.reexecuteOperation(s("teardown",n,n.context)),i&&i.hasNext&&c({hasNext:!1}),e.complete())}}))})),()=>{u=!0,t&&t.unsubscribe()}}))})(o))}))(t.filter((e=>"teardown"!==e.kind&&u(e)))(n)),c=i(t.filter((e=>"teardown"===e.kind||!u(e)))(n));return t.merge([o,c])}};
//# sourceMappingURL=urql-core.min.js.map
{
"name": "@urql/core",
"version": "5.0.1",
"version": "5.0.2-canary-0f3c5c01",
"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