@urql/core
Advanced tools
Comparing version 5.0.5 to 5.0.6-canary-a620d153
@@ -16,5 +16,5 @@ var graphql_web = require('@0no-co/graphql.web'); | ||
var rehydrateGraphQlError = error => { | ||
if (error && error.message && (error.extensions || error.name === 'GraphQLError')) { | ||
if (error && typeof error.message === 'string' && (error.extensions || error.name === 'GraphQLError')) { | ||
return error; | ||
} else if (typeof error === 'object' && error.message) { | ||
} else if (typeof error === 'object' && typeof error.message === 'string') { | ||
return new graphql_web.GraphQLError(error.message, error.nodes, error.source, error.positions, error.path, error, error.extensions || {}); | ||
@@ -21,0 +21,0 @@ } else { |
@@ -1,2 +0,2 @@ | ||
var e=require("@0no-co/graphql.web"),r=require("wonka"),t=r=>r&&r.message&&(r.extensions||"GraphQLError"===r.name)?r:"object"==typeof r&&r.message?new e.GraphQLError(r.message,r.nodes,r.source,r.positions,r.path,r,r.extensions||{}):new e.GraphQLError(r);class a extends Error{constructor(e){var r=(e.graphQLErrors||[]).map(t),a=((e,r)=>{var t="";if(e)return`[Network] ${e.message}`;if(r)for(var a of r)t&&(t+="\n"),t+=`[GraphQL] ${a.message}`;return t})(e.networkError,r);super(a),this.name="CombinedError",this.message=a,this.graphQLErrors=r,this.networkError=e.networkError,this.response=e.response}toString(){return this.message}}var n=(e,r)=>{for(var t=0|(r||5381),a=0,n=0|e.length;a<n;a++)t=(t<<5)+t+e.charCodeAt(a);return t},o=new Set,s=new WeakMap,i=(e,r)=>{if(null===e||o.has(e))return"null";if("object"!=typeof e)return JSON.stringify(e)||"";if(e.toJSON)return i(e.toJSON(),r);if(Array.isArray(e)){var t="[";for(var a of e)t.length>1&&(t+=","),t+=i(a,r)||"null";return t+"]"}if(!r&&(l!==f&&e instanceof l||p!==f&&e instanceof p))return"null";var n=Object.keys(e).sort();if(!n.length&&e.constructor&&Object.getPrototypeOf(e).constructor!==Object.prototype.constructor){var c=s.get(e)||Math.random().toString(36).slice(2);return s.set(e,c),i({__key:c},r)}o.add(e);var d="{";for(var u of n){var y=i(e[u],r);y&&(d.length>1&&(d+=","),d+=i(u,r)+":"+y)}return o.delete(e),d+"}"},c=(e,r,t)=>{if(null==t||"object"!=typeof t||t.toJSON||o.has(t));else if(Array.isArray(t))for(var a=0,n=t.length;a<n;a++)c(e,`${r}.${a}`,t[a]);else if(t instanceof l||t instanceof p)e.set(r,t);else for(var s of(o.add(t),Object.keys(t)))c(e,`${r}.${s}`,t[s])},d=(e,r)=>(o.clear(),i(e,r||!1));class f{}var l="undefined"!=typeof File?File:f,p="undefined"!=typeof Blob?Blob:f,u=/("{3}[\s\S]*"{3}|"(?:\\.|[^"])*")/g,y=/(?:#[^\n\r]+)?(?:[\r\n]+|$)/g,h=(e,r)=>r%2==0?e.replace(y,"\n"):e,v=e=>e.split(u).map(h).join("").trim(),x=new Map,m=new Map,g=r=>{var t;return"string"==typeof r?t=v(r):r.loc&&m.get(r.__key)===r?t=r.loc.source.body:(t=x.get(r)||v(e.print(r)),x.set(r,t)),"string"==typeof r||r.loc||(r.loc={start:0,end:t.length,source:{body:t,name:"gql",locationOffset:{line:1,column:1}}}),t},b=e=>{var r;if(e.documentId)r=n(e.documentId);else if(r=n(g(e)),e.definitions){var t=O(e);t&&(r=n(`\n# ${t}`,r))}return r},w=r=>{var t,a;return"string"==typeof r?(t=b(r),a=m.get(t)||e.parse(r,{noLocation:!0})):(t=r.__key||b(r),a=m.get(t)||r),a.loc||g(a),a.__key=t,m.set(t,a),a},O=r=>{for(var t of r.definitions)if(t.kind===e.Kind.OPERATION_DEFINITION)return t.name?t.name.value:void 0},k=(e,r,t)=>{if(!("data"in r||"errors"in r&&Array.isArray(r.errors)))throw new Error("No Content");var n="subscription"===e.kind;return{operation:e,data:r.data,error:Array.isArray(r.errors)?new a({graphQLErrors:r.errors,response:t}):void 0,extensions:r.extensions?{...r.extensions}:void 0,hasNext:null==r.hasNext?n:r.hasNext,stale:!1}},N=(e,r)=>{if("object"==typeof e&&null!=e&&(!e.constructor||e.constructor===Object||Array.isArray(e))){for(var t of(e=Array.isArray(e)?[...e]:{...e},Object.keys(r)))e[t]=N(e[t],r[t]);return e}return r},E=(e,r,t,n)=>{var o=e.error?e.error.graphQLErrors:[],s=!!e.extensions||!!(r.payload||r).extensions,i={...e.extensions,...(r.payload||r).extensions},c=r.incremental;"path"in r&&(c=[r]);var d={data:e.data};if(c){var f=function(e){Array.isArray(e.errors)&&o.push(...e.errors),e.extensions&&(Object.assign(i,e.extensions),s=!0);var r="data",t=d,a=[];if(e.path)a=e.path;else if(n){var c=n.find((r=>r.id===e.id));a=e.subPath?[...c.path,...e.subPath]:c.path}for(var f=0,l=a.length;f<l;r=a[f++])t=t[r]=Array.isArray(t[r])?[...t[r]]:{...t[r]};if(e.items)for(var p=+r>=0?r:0,u=0,y=e.items.length;u<y;u++)t[p+u]=N(t[p+u],e.items[u]);else void 0!==e.data&&(t[r]=N(t[r],e.data))};for(var l of c)f(l)}else d.data=(r.payload||r).data||e.data,o=r.errors||r.payload&&r.payload.errors||o;return{operation:e.operation,data:d.data,error:o.length?new a({graphQLErrors:o,response:t}):void 0,extensions:s?i:void 0,hasNext:null!=r.hasNext?r.hasNext:e.hasNext,stale:!1}},A=(e,r,t)=>({operation:e,data:void 0,error:new a({networkError:r,response:t}),extensions:void 0,hasNext:!1,stale:!1}),j="undefined"!=typeof TextDecoder?new TextDecoder:null,q=/boundary="?([^=";]+)"?/i,S=/data: ?([^\n]+)/,I=e=>"Buffer"===e.constructor.name?e.toString():j.decode(e);async function*L(e){if(e.body[Symbol.asyncIterator])for await(var r of e.body)yield I(r);else{var t,a=e.body.getReader();try{for(;!(t=await a.read()).done;)yield I(t.value)}finally{a.cancel()}}}async function*T(e,r){var t,a="";for await(var n of e)for(a+=n;(t=a.indexOf(r))>-1;)yield a.slice(0,t),a=a.slice(t+r.length)}exports.CombinedError=a,exports.createRequest=(e,r,t)=>{var a=r||{},o=w(e),s=d(a,!0),i=o.__key;return"{}"!==s&&(i=n(s,i)),{key:i,query:o,variables:a,extensions:t}},exports.getOperationType=r=>{for(var t of r.definitions)if(t.kind===e.Kind.OPERATION_DEFINITION)return t.operation},exports.keyDocument=w,exports.makeErrorResult=A,exports.makeFetchBody=function(e){var r={query:void 0,documentId:void 0,operationName:O(e.query),variables:e.variables||void 0,extensions:e.extensions};return!("documentId"in e.query)||!e.query.documentId||e.query.definitions&&e.query.definitions.length?e.extensions&&e.extensions.persistedQuery&&!e.extensions.persistedQuery.miss||(r.query=g(e.query)):r.documentId=e.query.documentId,r},exports.makeFetchOptions=(e,r)=>{var t={accept:"subscription"===e.kind?"text/event-stream, multipart/mixed":"application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed"},a=("function"==typeof e.context.fetchOptions?e.context.fetchOptions():e.context.fetchOptions)||{};if(a.headers)if((e=>"has"in e&&!Object.keys(e).length)(a.headers))a.headers.forEach(((e,r)=>{t[r]=e}));else if(Array.isArray(a.headers))a.headers.forEach(((e,r)=>{Array.isArray(e)?t[e[0]]=t[e[0]]?`${t[e[0]]},${e[1]}`:e[1]:t[r]=e}));else for(var n in a.headers)t[n.toLowerCase()]=a.headers[n];var s=((e,r)=>{var t,a;if(r&&("query"!==e.kind||!e.context.preferGetMethod)){var n=d(r),s=(t=r.variables,a=new Map,l===f&&p===f||(o.clear(),c(a,"variables",t)),a);if(s.size){var i=new FormData;i.append("operations",n),i.append("map",d({...[...s.keys()].map((e=>[e]))}));var u=0;for(var y of s.values())i.append(""+u++,y);return i}return n}})(e,r);return"string"!=typeof s||t["content-type"]||(t["content-type"]="application/json"),{...a,method:s?"POST":"GET",body:s,headers:t}},exports.makeFetchSource=function(e,t,a){var n;return"undefined"!=typeof AbortController&&(a.signal=(n=new AbortController).signal),r.onEnd((()=>{n&&n.abort()}))(r.filter((e=>!!e))(r.fromAsyncIterable(async function*(e,r,t){var a,n=!0,o=null;try{yield await Promise.resolve();var s,i,c=(a=await(e.context.fetch||fetch)(r,t)).headers.get("Content-Type")||"";for await(var d of(s=/multipart\/mixed/i.test(c)?async function*(e,r){var t,a=e.match(q),n="--"+(a?a[1]:"-"),o=!0;for await(var s of T(L(r),"\r\n"+n)){if(o){o=!1;var i=s.indexOf(n);if(!(i>-1))continue;s=s.slice(i+n.length)}try{yield t=JSON.parse(s.slice(s.indexOf("\r\n\r\n")+4))}catch(e){if(!t)throw e}if(t&&!1===t.hasNext)break}t&&!1!==t.hasNext&&(yield{hasNext:!1})}(c,a):/text\/event-stream/i.test(c)?async function*(e){var r;for await(var t of T(L(e),"\n\n")){var a=t.match(S);if(a){var n=a[1];try{yield r=JSON.parse(n)}catch(e){if(!r)throw e}if(r&&!1===r.hasNext)break}}r&&!1!==r.hasNext&&(yield{hasNext:!1})}(a):/text\//i.test(c)?async function*(e){var r=await e.text();try{var t=JSON.parse(r);yield t}catch(e){throw new Error(r)}}(a):async function*(e){yield JSON.parse(await e.text())}(a),s))d.pending&&!o?i=d.pending:d.pending&&(i=[...i,...d.pending]),o=o?E(o,d,a,i):k(e,d,a),n=!1,yield o,n=!0;o||(yield o=k(e,{},a))}catch(r){if(!n)throw r;yield A(e,a&&(a.status<200||a.status>=300)&&a.statusText?new Error(a.statusText):r,a)}}(e,t,a))))},exports.makeFetchURL=(e,r)=>{var t="query"===e.kind&&e.context.preferGetMethod;if(!t||!r)return e.context.url;var a,n,o=(n=(a=e.context.url).indexOf("?"))>-1?[a.slice(0,n),new URLSearchParams(a.slice(n+1))]:[a,new URLSearchParams];for(var s in r){var i=r[s];i&&o[1].set(s,"object"==typeof i?d(i):i)}var c=o.join("?");return c.length>2047&&"force"!==t?(e.context.preferGetMethod=!1,e.context.url):c},exports.makeResult=k,exports.mergeResultPatch=E,exports.stringifyDocument=g,exports.stringifyVariables=d; | ||
var e=require("@0no-co/graphql.web"),r=require("wonka"),t=r=>r&&"string"==typeof r.message&&(r.extensions||"GraphQLError"===r.name)?r:"object"==typeof r&&"string"==typeof r.message?new e.GraphQLError(r.message,r.nodes,r.source,r.positions,r.path,r,r.extensions||{}):new e.GraphQLError(r);class a extends Error{constructor(e){var r=(e.graphQLErrors||[]).map(t),a=((e,r)=>{var t="";if(e)return`[Network] ${e.message}`;if(r)for(var a of r)t&&(t+="\n"),t+=`[GraphQL] ${a.message}`;return t})(e.networkError,r);super(a),this.name="CombinedError",this.message=a,this.graphQLErrors=r,this.networkError=e.networkError,this.response=e.response}toString(){return this.message}}var n=(e,r)=>{for(var t=0|(r||5381),a=0,n=0|e.length;a<n;a++)t=(t<<5)+t+e.charCodeAt(a);return t},o=new Set,s=new WeakMap,i=(e,r)=>{if(null===e||o.has(e))return"null";if("object"!=typeof e)return JSON.stringify(e)||"";if(e.toJSON)return i(e.toJSON(),r);if(Array.isArray(e)){var t="[";for(var a of e)t.length>1&&(t+=","),t+=i(a,r)||"null";return t+"]"}if(!r&&(l!==f&&e instanceof l||p!==f&&e instanceof p))return"null";var n=Object.keys(e).sort();if(!n.length&&e.constructor&&Object.getPrototypeOf(e).constructor!==Object.prototype.constructor){var c=s.get(e)||Math.random().toString(36).slice(2);return s.set(e,c),i({__key:c},r)}o.add(e);var d="{";for(var u of n){var y=i(e[u],r);y&&(d.length>1&&(d+=","),d+=i(u,r)+":"+y)}return o.delete(e),d+"}"},c=(e,r,t)=>{if(null==t||"object"!=typeof t||t.toJSON||o.has(t));else if(Array.isArray(t))for(var a=0,n=t.length;a<n;a++)c(e,`${r}.${a}`,t[a]);else if(t instanceof l||t instanceof p)e.set(r,t);else for(var s of(o.add(t),Object.keys(t)))c(e,`${r}.${s}`,t[s])},d=(e,r)=>(o.clear(),i(e,r||!1));class f{}var l="undefined"!=typeof File?File:f,p="undefined"!=typeof Blob?Blob:f,u=/("{3}[\s\S]*"{3}|"(?:\\.|[^"])*")/g,y=/(?:#[^\n\r]+)?(?:[\r\n]+|$)/g,h=(e,r)=>r%2==0?e.replace(y,"\n"):e,v=e=>e.split(u).map(h).join("").trim(),x=new Map,m=new Map,g=r=>{var t;return"string"==typeof r?t=v(r):r.loc&&m.get(r.__key)===r?t=r.loc.source.body:(t=x.get(r)||v(e.print(r)),x.set(r,t)),"string"==typeof r||r.loc||(r.loc={start:0,end:t.length,source:{body:t,name:"gql",locationOffset:{line:1,column:1}}}),t},b=e=>{var r;if(e.documentId)r=n(e.documentId);else if(r=n(g(e)),e.definitions){var t=O(e);t&&(r=n(`\n# ${t}`,r))}return r},w=r=>{var t,a;return"string"==typeof r?(t=b(r),a=m.get(t)||e.parse(r,{noLocation:!0})):(t=r.__key||b(r),a=m.get(t)||r),a.loc||g(a),a.__key=t,m.set(t,a),a},O=r=>{for(var t of r.definitions)if(t.kind===e.Kind.OPERATION_DEFINITION)return t.name?t.name.value:void 0},k=(e,r,t)=>{if(!("data"in r||"errors"in r&&Array.isArray(r.errors)))throw new Error("No Content");var n="subscription"===e.kind;return{operation:e,data:r.data,error:Array.isArray(r.errors)?new a({graphQLErrors:r.errors,response:t}):void 0,extensions:r.extensions?{...r.extensions}:void 0,hasNext:null==r.hasNext?n:r.hasNext,stale:!1}},N=(e,r)=>{if("object"==typeof e&&null!=e&&(!e.constructor||e.constructor===Object||Array.isArray(e))){for(var t of(e=Array.isArray(e)?[...e]:{...e},Object.keys(r)))e[t]=N(e[t],r[t]);return e}return r},E=(e,r,t,n)=>{var o=e.error?e.error.graphQLErrors:[],s=!!e.extensions||!!(r.payload||r).extensions,i={...e.extensions,...(r.payload||r).extensions},c=r.incremental;"path"in r&&(c=[r]);var d={data:e.data};if(c){var f=function(e){Array.isArray(e.errors)&&o.push(...e.errors),e.extensions&&(Object.assign(i,e.extensions),s=!0);var r="data",t=d,a=[];if(e.path)a=e.path;else if(n){var c=n.find((r=>r.id===e.id));a=e.subPath?[...c.path,...e.subPath]:c.path}for(var f=0,l=a.length;f<l;r=a[f++])t=t[r]=Array.isArray(t[r])?[...t[r]]:{...t[r]};if(e.items)for(var p=+r>=0?r:0,u=0,y=e.items.length;u<y;u++)t[p+u]=N(t[p+u],e.items[u]);else void 0!==e.data&&(t[r]=N(t[r],e.data))};for(var l of c)f(l)}else d.data=(r.payload||r).data||e.data,o=r.errors||r.payload&&r.payload.errors||o;return{operation:e.operation,data:d.data,error:o.length?new a({graphQLErrors:o,response:t}):void 0,extensions:s?i:void 0,hasNext:null!=r.hasNext?r.hasNext:e.hasNext,stale:!1}},A=(e,r,t)=>({operation:e,data:void 0,error:new a({networkError:r,response:t}),extensions:void 0,hasNext:!1,stale:!1}),j="undefined"!=typeof TextDecoder?new TextDecoder:null,q=/boundary="?([^=";]+)"?/i,S=/data: ?([^\n]+)/,I=e=>"Buffer"===e.constructor.name?e.toString():j.decode(e);async function*L(e){if(e.body[Symbol.asyncIterator])for await(var r of e.body)yield I(r);else{var t,a=e.body.getReader();try{for(;!(t=await a.read()).done;)yield I(t.value)}finally{a.cancel()}}}async function*T(e,r){var t,a="";for await(var n of e)for(a+=n;(t=a.indexOf(r))>-1;)yield a.slice(0,t),a=a.slice(t+r.length)}exports.CombinedError=a,exports.createRequest=(e,r,t)=>{var a=r||{},o=w(e),s=d(a,!0),i=o.__key;return"{}"!==s&&(i=n(s,i)),{key:i,query:o,variables:a,extensions:t}},exports.getOperationType=r=>{for(var t of r.definitions)if(t.kind===e.Kind.OPERATION_DEFINITION)return t.operation},exports.keyDocument=w,exports.makeErrorResult=A,exports.makeFetchBody=function(e){var r={query:void 0,documentId:void 0,operationName:O(e.query),variables:e.variables||void 0,extensions:e.extensions};return!("documentId"in e.query)||!e.query.documentId||e.query.definitions&&e.query.definitions.length?e.extensions&&e.extensions.persistedQuery&&!e.extensions.persistedQuery.miss||(r.query=g(e.query)):r.documentId=e.query.documentId,r},exports.makeFetchOptions=(e,r)=>{var t={accept:"subscription"===e.kind?"text/event-stream, multipart/mixed":"application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed"},a=("function"==typeof e.context.fetchOptions?e.context.fetchOptions():e.context.fetchOptions)||{};if(a.headers)if((e=>"has"in e&&!Object.keys(e).length)(a.headers))a.headers.forEach(((e,r)=>{t[r]=e}));else if(Array.isArray(a.headers))a.headers.forEach(((e,r)=>{Array.isArray(e)?t[e[0]]=t[e[0]]?`${t[e[0]]},${e[1]}`:e[1]:t[r]=e}));else for(var n in a.headers)t[n.toLowerCase()]=a.headers[n];var s=((e,r)=>{var t,a;if(r&&("query"!==e.kind||!e.context.preferGetMethod)){var n=d(r),s=(t=r.variables,a=new Map,l===f&&p===f||(o.clear(),c(a,"variables",t)),a);if(s.size){var i=new FormData;i.append("operations",n),i.append("map",d({...[...s.keys()].map((e=>[e]))}));var u=0;for(var y of s.values())i.append(""+u++,y);return i}return n}})(e,r);return"string"!=typeof s||t["content-type"]||(t["content-type"]="application/json"),{...a,method:s?"POST":"GET",body:s,headers:t}},exports.makeFetchSource=function(e,t,a){var n;return"undefined"!=typeof AbortController&&(a.signal=(n=new AbortController).signal),r.onEnd((()=>{n&&n.abort()}))(r.filter((e=>!!e))(r.fromAsyncIterable(async function*(e,r,t){var a,n=!0,o=null;try{yield await Promise.resolve();var s,i,c=(a=await(e.context.fetch||fetch)(r,t)).headers.get("Content-Type")||"";for await(var d of(s=/multipart\/mixed/i.test(c)?async function*(e,r){var t,a=e.match(q),n="--"+(a?a[1]:"-"),o=!0;for await(var s of T(L(r),"\r\n"+n)){if(o){o=!1;var i=s.indexOf(n);if(!(i>-1))continue;s=s.slice(i+n.length)}try{yield t=JSON.parse(s.slice(s.indexOf("\r\n\r\n")+4))}catch(e){if(!t)throw e}if(t&&!1===t.hasNext)break}t&&!1!==t.hasNext&&(yield{hasNext:!1})}(c,a):/text\/event-stream/i.test(c)?async function*(e){var r;for await(var t of T(L(e),"\n\n")){var a=t.match(S);if(a){var n=a[1];try{yield r=JSON.parse(n)}catch(e){if(!r)throw e}if(r&&!1===r.hasNext)break}}r&&!1!==r.hasNext&&(yield{hasNext:!1})}(a):/text\//i.test(c)?async function*(e){var r=await e.text();try{var t=JSON.parse(r);yield t}catch(e){throw new Error(r)}}(a):async function*(e){yield JSON.parse(await e.text())}(a),s))d.pending&&!o?i=d.pending:d.pending&&(i=[...i,...d.pending]),o=o?E(o,d,a,i):k(e,d,a),n=!1,yield o,n=!0;o||(yield o=k(e,{},a))}catch(r){if(!n)throw r;yield A(e,a&&(a.status<200||a.status>=300)&&a.statusText?new Error(a.statusText):r,a)}}(e,t,a))))},exports.makeFetchURL=(e,r)=>{var t="query"===e.kind&&e.context.preferGetMethod;if(!t||!r)return e.context.url;var a,n,o=(n=(a=e.context.url).indexOf("?"))>-1?[a.slice(0,n),new URLSearchParams(a.slice(n+1))]:[a,new URLSearchParams];for(var s in r){var i=r[s];i&&o[1].set(s,"object"==typeof i?d(i):i)}var c=o.join("?");return c.length>2047&&"force"!==t?(e.context.preferGetMethod=!1,e.context.url):c},exports.makeResult=k,exports.mergeResultPatch=E,exports.stringifyDocument=g,exports.stringifyVariables=d; | ||
//# sourceMappingURL=urql-core-chunk.min.js.map |
{ | ||
"name": "@urql/core", | ||
"version": "5.0.5", | ||
"version": "5.0.6-canary-a620d153", | ||
"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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
920942
5388
3