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
263
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 4.3.0 to 5.0.0-canary-3692842e

24

dist/urql-core.d.ts

@@ -303,8 +303,2 @@ import { AnyVariables, TypedDocumentNode, DocumentNode, GraphQLError, Exchange, FetchBody, Operation, ExecutionResult, DefinitionNode, DocumentInput, RequestExtensions, GraphQLRequest, OperationResult, FormattedNode, OperationType, OperationContext, CombinedError } from './urql-core-chunk.js';

/** Default deduplication exchange.
* @deprecated
* This exchange's functionality is now built into the {@link Client}.
*/
declare const dedupExchange: Exchange;
/** Default GraphQL over HTTP fetch exchange.

@@ -473,18 +467,2 @@ *

/** Used to recursively mark `__typename` fields in data as non-enumerable.
*
* @deprecated Not recommended over modelling inputs manually (See #3299)
*
* @remarks
* This utility can be used to recursively copy GraphQl response data and hide
* all `__typename` fields present on it.
*
* Hint: It’s not recommended to do this, unless it's absolutely necessary as
* cloning and modifying all data of a response can be unnecessarily slow, when
* a manual and more specific copy/mask is more efficient.
*
* @see {@link ClientOptions.maskTypename} for a description of how the `Client` uses this utility.
*/
declare const maskTypename: (data: any, isRoot?: boolean) => any;
/** Creates a {@link Operation} from the given parameters.

@@ -582,2 +560,2 @@ *

export { AnyVariables, CombinedError, DocumentInput, Exchange, ExecutionResult, FormattedNode, GraphQLRequest, MapExchangeOpts, Operation, OperationContext, OperationResult, OperationType, RequestExtensions, SSRData, SSRExchange, SSRExchangeParams, SerializedResult, SubscriptionExchangeOpts, SubscriptionForwarder, SubscriptionOperation, TypedDocumentNode, cacheExchange, composeExchanges, createRequest, debugExchange, dedupExchange, mapExchange as errorExchange, fetchExchange, formatDocument, gql, makeErrorResult, makeOperation, makeResult, mapExchange, maskTypename, mergeResultPatch, ssrExchange, stringifyDocument, stringifyVariables, subscriptionExchange };
export { AnyVariables, CombinedError, DocumentInput, Exchange, ExecutionResult, FormattedNode, GraphQLRequest, MapExchangeOpts, Operation, OperationContext, OperationResult, OperationType, RequestExtensions, SSRData, SSRExchange, SSRExchangeParams, SerializedResult, SubscriptionExchangeOpts, SubscriptionForwarder, SubscriptionOperation, TypedDocumentNode, cacheExchange, composeExchanges, createRequest, debugExchange, mapExchange as errorExchange, fetchExchange, formatDocument, gql, makeErrorResult, makeOperation, makeResult, mapExchange, mergeResultPatch, ssrExchange, stringifyDocument, stringifyVariables, subscriptionExchange };

@@ -131,39 +131,2 @@ Object.defineProperty(exports, '__esModule', { value: true });

/** Used to recursively mark `__typename` fields in data as non-enumerable.
*
* @deprecated Not recommended over modelling inputs manually (See #3299)
*
* @remarks
* This utility can be used to recursively copy GraphQl response data and hide
* all `__typename` fields present on it.
*
* Hint: It’s not recommended to do this, unless it's absolutely necessary as
* cloning and modifying all data of a response can be unnecessarily slow, when
* a manual and more specific copy/mask is more efficient.
*
* @see {@link ClientOptions.maskTypename} for a description of how the `Client` uses this utility.
*/
var maskTypename = (data, isRoot) => {
if (!data || typeof data !== 'object') {
return data;
} else if (Array.isArray(data)) {
return data.map(d => maskTypename(d));
} else if (data && typeof data === 'object' && (isRoot || '__typename' in data)) {
var acc = {};
for (var key in data) {
if (key === '__typename') {
Object.defineProperty(acc, '__typename', {
enumerable: false,
value: data.__typename
});
} else {
acc[key] = maskTypename(data[key]);
}
}
return acc;
} else {
return data;
}
};
/** Patches a `toPromise` method onto the `Source` passed to it.

@@ -792,10 +755,2 @@ * @param source$ - the Wonka {@link Source} to patch.

/** Default deduplication exchange.
* @deprecated
* This exchange's functionality is now built into the {@link Client}.
*/
var dedupExchange = ({
forward
}) => ops$ => forward(ops$);
/* eslint-disable @typescript-eslint/no-use-before-define */

@@ -1061,10 +1016,2 @@

wonka.filter(res => res.operation.kind === operation.kind && res.operation.key === operation.key && (!res.operation.context._instance || res.operation.context._instance === operation.context._instance))(results$));
// Mask typename properties if the option for it is turned on
if (opts.maskTypename) {
result$ = wonka.map(res => ({
...res,
data: maskTypename(res.data, true)
}))(result$);
}
if (operation.kind !== 'query') {

@@ -1253,3 +1200,2 @@ // Interrupt subscriptions and mutations when they have no more results

exports.debugExchange = debugExchange;
exports.dedupExchange = dedupExchange;
exports.errorExchange = mapExchange;

@@ -1261,5 +1207,4 @@ exports.fetchExchange = fetchExchange;

exports.mapExchange = mapExchange;
exports.maskTypename = maskTypename;
exports.ssrExchange = ssrExchange;
exports.subscriptionExchange = subscriptionExchange;
//# sourceMappingURL=urql-core.js.map

2

dist/urql-core.min.js

@@ -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 p=[],l=r.kind===e.Kind.OPERATION_DEFINITION;if(r.selectionSet){for(var d of r.selectionSet.selections||[]){l=l||d.kind===e.Kind.FIELD&&"__typename"===d.name.value&&!d.alias;var k=a(d);p.push(k)}return l||p.push({kind:e.Kind.FIELD,name:{kind:e.Kind.NAME,value:"__typename"},_generated:!0}),{...r,selectionSet:{...r.selectionSet,selections:p}}}}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},s=(e,r)=>{if(e&&"object"==typeof e){if(Array.isArray(e))return e.map((e=>s(e)));if(e&&"object"==typeof e&&(r||"__typename"in e)){var t={};for(var n in e)"__typename"===n?Object.defineProperty(t,"__typename",{enumerable:!1,value:e.__typename}):t[n]=s(e[n]);return t}return e}return e};function u(e,r,t){return{...r,kind:e,context:r.context?{...r.context,...t}:t||r.context}}var c=()=>{},p=({kind:e})=>"mutation"!==e&&"query"!==e,l=e=>{var r=i(e.query);if(r!==e.query){var t=u(e.kind,e);return t.query=r,t}return e},d=(e,r)=>e.reexecuteOperation(u(r.kind,r,{requestPolicy:"network-only"})),k=new Set,f=e=>({client:r,forward:n})=>e.reduceRight(((e,n)=>n({client:r,forward:r=>t.share(e(t.share(r))),dispatchDebug(e){}})),n),y=({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))),h=({})=>e=>t.filter((e=>!1))(e),m=function e(n){var a=0,o=new Map,i=new Map,p=new Set,l=[],d={url:n.url,fetchSubscriptions:n.fetchSubscriptions,fetchOptions:n.fetchOptions,fetch:n.fetch,preferGetMethod:n.preferGetMethod,requestPolicy:n.requestPolicy||"cache-first"},k=t.makeSubject();function y(e){"mutation"!==e.kind&&"teardown"!==e.kind&&p.has(e.key)||("teardown"===e.kind?p.delete(e.key):"mutation"!==e.kind&&p.add(e.key),k.next(e))}var m=!1;function v(e){if(e&&y(e),!m){for(m=!0;m&&(e=l.shift());)y(e);m=!1}}var x=e=>{var r=t.takeUntil(t.filter((r=>"teardown"===r.kind&&r.key===e.key))(k.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)))(E));return n.maskTypename&&(r=t.map((e=>({...e,data:s(e.data,!0)})))(r)),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))(k.source)))])}))(r),r="mutation"!==e.kind?t.onEnd((()=>{p.delete(e.key),o.delete(e.key),i.delete(e.key),m=!1;for(var r=l.length-1;r>=0;r--)l[r].key===e.key&&l.splice(r,1);y(u("teardown",e,e.context))}))(t.onPush((r=>{if(r.stale){for(var t of l)if(t.key===r.operation.key){p.delete(t.key);break}}else r.hasNext||p.delete(e.key);o.set(e.key,r)}))(r)):t.onStart((()=>{y(e)}))(r),t.share(r)},g=this instanceof e?this:Object.create(e.prototype),b=Object.assign(g,{suspense:!!n.suspense,operations$:k.source,reexecuteOperation(e){if("teardown"===e.kind)v(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||p.delete(e.key),l.push(e),Promise.resolve().then(v)}},createRequestOperation:(e,r,t)=>(t||(t={}),u(e,r,{_instance:"mutation"===e?a=a+1|0:void 0,...d,...t,requestPolicy:t.requestPolicy||d.requestPolicy,suspense:t.suspense||!1!==t.suspense&&b.suspense})),executeRequestOperation:e=>{return r="mutation"===e.kind?x(e):t.lazy((()=>{var r=i.get(e.key);r||i.set(e.key,r=x(e)),r=t.onStart((()=>{v(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=b.createRequestOperation("query",e,r);return b.executeRequestOperation(t)},executeSubscription(e,r){var t=b.createRequestOperation("subscription",e,r);return b.executeRequestOperation(t)},executeMutation(e,r){var t=b.createRequestOperation("mutation",e,r);return b.executeRequestOperation(t)},readQuery(e,r,n){var a=null;return t.subscribe((e=>{a=e}))(b.query(e,r,n)).unsubscribe(),a},query:(e,t,n)=>b.executeQuery(r.createRequest(e,t),n),subscription:(e,t,n)=>b.executeSubscription(r.createRequest(e,t),n),mutation:(e,t,n)=>b.executeMutation(r.createRequest(e,t),n)}),w=c,q=f(n.exchanges),E=t.share(q({client:b,dispatchDebug:w,forward:h({dispatchDebug:w})})(k.source));return t.publish(E),b},v=m;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=m,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 c=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=>!p(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],p=i.get(c);for(var l of(p||i.set(c,p=new Set),p.values()))s.add(l);p.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=>!p(e)&&!s(e)))(u)),t.filter((e=>p(e)))(u)])))));return t.merge([c,k])}},exports.composeExchanges=f,exports.createClient=v,exports.debugExchange=({forward:e})=>r=>e(r),exports.dedupExchange=({forward:e})=>r=>e(r),exports.errorExchange=y,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 p of c.definitions)if(p.kind===e.Kind.FRAGMENT_DEFINITION){var l=p.name.value,d=r.stringifyDocument(p);n.has(l)||(n.set(l,d),a.push(p))}else a.push(p);return r.keyDocument({kind:e.Kind.DOCUMENT,definitions:a})},exports.makeOperation=u,exports.mapExchange=y,exports.maskTypename=s,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 p=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&&!k.has(e.key)&&(t.stale=!0,k.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 p?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 s=a||(e=>"subscription"===e.kind||!!n&&("query"===e.kind||"mutation"===e.kind));return n=>{var a=t.mergeMap((a=>{var{key:i}=a,s=t.filter((e=>"teardown"===e.kind&&e.key===i))(n);return t.takeUntil(s)((n=>{var a=e(r.makeFetchBody(n),n);return t.make((e=>{var t,i,s=!1;function c(t){e.next(i=i?r.mergeResultPatch(i,t):r.makeResult(n,t))}return Promise.resolve().then((()=>{s||(t=a.subscribe({next:c,error(t){Array.isArray(t)?c({errors:t}):e.next(r.makeErrorResult(n,t)),e.complete()},complete(){s||(s=!0,"subscription"===n.kind&&o.reexecuteOperation(u("teardown",n,n.context)),i&&i.hasNext&&c({hasNext:!1}),e.complete())}}))})),()=>{s=!0,t&&t.unsubscribe()}}))})(a))}))(t.filter((e=>"teardown"!==e.kind&&s(e)))(n)),c=i(t.filter((e=>"teardown"===e.kind||!s(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 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])}};
//# sourceMappingURL=urql-core.min.js.map
{
"name": "@urql/core",
"version": "4.3.0",
"version": "5.0.0-canary-3692842e",
"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 too big to display

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