@urql/core
Advanced tools
Comparing version 2.3.2 to 2.3.3
# @urql/core | ||
## 2.3.3 | ||
### Patch Changes | ||
- Adding option to `ssrExchange` to include the `extensions` field of operation results in the cache, by [@dios-david](https://github.com/dios-david) (See [#1985](https://github.com/FormidableLabs/urql/pull/1985)) | ||
## 2.3.2 | ||
@@ -4,0 +10,0 @@ |
@@ -6,2 +6,3 @@ import { GraphQLError } from 'graphql'; | ||
data?: string | undefined; | ||
extensions?: string | undefined; | ||
error?: { | ||
@@ -19,2 +20,3 @@ graphQLErrors: Array<Partial<GraphQLError> | string>; | ||
staleWhileRevalidate?: boolean; | ||
includeExtensions?: boolean; | ||
} | ||
@@ -21,0 +23,0 @@ export interface SSRExchange extends Exchange { |
@@ -652,11 +652,12 @@ var e = require("graphql"); | ||
var n = !(!e || !e.staleWhileRevalidate); | ||
var o = {}; | ||
var i = []; | ||
var o = !(!e || !e.includeExtensions); | ||
var i = {}; | ||
var u = []; | ||
function invalidate(e) { | ||
i.push(e.operation.key); | ||
if (1 === i.length) { | ||
u.push(e.operation.key); | ||
if (1 === u.length) { | ||
Promise.resolve().then((function() { | ||
var e; | ||
while (e = i.shift()) { | ||
o[e] = null; | ||
while (e = u.shift()) { | ||
i[e] = null; | ||
} | ||
@@ -666,17 +667,17 @@ })); | ||
} | ||
var ssr = function(i) { | ||
var u = i.client; | ||
var c = i.forward; | ||
return function(i) { | ||
var s = e && "boolean" == typeof e.isClient ? !!e.isClient : !u.suspense; | ||
var p = r.share(i); | ||
var f = c(r.filter((function(e) { | ||
return !o[e.key] || !!o[e.key].hasNext; | ||
}))(p)); | ||
var l = r.map((function(e) { | ||
var r = function deserializeResult(e, r) { | ||
var ssr = function(u) { | ||
var c = u.client; | ||
var s = u.forward; | ||
return function(u) { | ||
var p = e && "boolean" == typeof e.isClient ? !!e.isClient : !c.suspense; | ||
var f = r.share(u); | ||
var l = s(r.filter((function(e) { | ||
return !i[e.key] || !!i[e.key].hasNext; | ||
}))(f)); | ||
var d = r.map((function(e) { | ||
var r = function deserializeResult(e, r, n) { | ||
return { | ||
operation: e, | ||
data: r.data ? JSON.parse(r.data) : void 0, | ||
extensions: void 0, | ||
extensions: n && r.extensions ? JSON.parse(r.extensions) : void 0, | ||
error: r.error ? new t.CombinedError({ | ||
@@ -688,30 +689,34 @@ networkError: r.error.networkError ? new Error(r.error.networkError) : void 0, | ||
}; | ||
}(e, o[e.key]); | ||
}(e, i[e.key], o); | ||
if (n && !a.has(e.key)) { | ||
r.stale = !0; | ||
a.add(e.key); | ||
reexecuteOperation(u, e); | ||
reexecuteOperation(c, e); | ||
} | ||
return r; | ||
}))(r.filter((function(e) { | ||
return !!o[e.key]; | ||
}))(p)); | ||
if (!s) { | ||
f = r.tap((function(e) { | ||
return !!i[e.key]; | ||
}))(f)); | ||
if (!p) { | ||
l = r.tap((function(e) { | ||
var t = e.operation; | ||
if ("mutation" !== t.kind) { | ||
var r = function serializeResult(e) { | ||
var t = e.hasNext; | ||
var r = e.data; | ||
var n = e.error; | ||
var a = {}; | ||
if (void 0 !== r) { | ||
a.data = JSON.stringify(r); | ||
var r = function serializeResult(e, t) { | ||
var r = e.hasNext; | ||
var n = e.data; | ||
var a = e.extensions; | ||
var o = e.error; | ||
var i = {}; | ||
if (void 0 !== n) { | ||
i.data = JSON.stringify(n); | ||
} | ||
if (t) { | ||
a.hasNext = !0; | ||
if (t && void 0 !== a) { | ||
i.extensions = JSON.stringify(a); | ||
} | ||
if (n) { | ||
a.error = { | ||
graphQLErrors: n.graphQLErrors.map((function(e) { | ||
if (r) { | ||
i.hasNext = !0; | ||
} | ||
if (o) { | ||
i.error = { | ||
graphQLErrors: o.graphQLErrors.map((function(e) { | ||
if (!e.path && !e.extensions) { | ||
@@ -727,15 +732,15 @@ return e.message; | ||
}; | ||
if (n.networkError) { | ||
a.error.networkError = "" + n.networkError; | ||
if (o.networkError) { | ||
i.error.networkError = "" + o.networkError; | ||
} | ||
} | ||
return a; | ||
}(e); | ||
o[t.key] = r; | ||
return i; | ||
}(e, o); | ||
i[t.key] = r; | ||
} | ||
}))(f); | ||
}))(l); | ||
} else { | ||
l = r.tap(invalidate)(l); | ||
d = r.tap(invalidate)(d); | ||
} | ||
return r.merge([ f, l ]); | ||
return r.merge([ l, d ]); | ||
}; | ||
@@ -745,4 +750,4 @@ }; | ||
for (var t in e) { | ||
if (null !== o[t]) { | ||
o[t] = e[t]; | ||
if (null !== i[t]) { | ||
i[t] = e[t]; | ||
} | ||
@@ -753,5 +758,5 @@ } | ||
var e = {}; | ||
for (var t in o) { | ||
if (null != o[t]) { | ||
e[t] = o[t]; | ||
for (var t in i) { | ||
if (null != i[t]) { | ||
e[t] = i[t]; | ||
} | ||
@@ -758,0 +763,0 @@ } |
@@ -1,2 +0,2 @@ | ||
var e=require("graphql"),t=require("./8ce379e1.min.js"),r=require("wonka");function n(e,t){if(Array.isArray(e))for(var r=0;r<e.length;r++)n(e[r],t);else if("object"==typeof e&&null!==e)for(var o in e)"__typename"===o&&"string"==typeof e[o]?t[e[o]]=0:n(e[o],t);return t}function o(e){return Object.keys(n(e,{}))}var i=function(r){if(r.selectionSet&&!r.selectionSet.selections.some((function(t){return t.kind===e.Kind.FIELD&&"__typename"===t.name.value&&!t.alias})))return t._extends({},r,{selectionSet:t._extends({},r.selectionSet,{selections:r.selectionSet.selections.concat([{kind:e.Kind.FIELD,name:{kind:e.Kind.NAME,value:"__typename"}}])})})},u=new Map;function a(r){var n=t.keyDocument(r),o=u.get(n.__key);return o||(o=e.visit(n,{Field:i,InlineFragment:i}),Object.defineProperty(o,"__key",{value:n.__key,enumerable:!1}),u.set(n.__key,o)),o}function c(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(c):n&&"object"==typeof n&&"__typename"in n?c(n):n,t}),{}):e}function s(e){return e.toPromise=function(){return r.toPromise(r.take(1)(r.filter((function(e){return!e.stale&&!e.hasNext}))(e)))},e}function f(e,t,r){return r||(r=t.context),{key:t.key,query:t.query,variables:t.variables,kind:e,context:r}}function p(e,r){return f(e.kind,e,t._extends({},e.context,{meta:t._extends({},e.context.meta,r)}))}function l(){}function d(r,n,o){for(var i=0;i<o.length;i++)if(o[i].kind===e.Kind.FRAGMENT_DEFINITION){var u=o[i].name.value,a=t.stringifyDocument(o[i]);r.has(u)||(r.set(u,a),n.push(o[i]))}else n.push(o[i])}function y(e){var t=e.kind;return"mutation"!==t&&"query"!==t}function k(e){var n=e.forward,i=e.client,u=new Map,c=Object.create(null);function s(e){var t=f(e.kind,e);return t.query=a(e.query),t}function l(e){var t=e.context.requestPolicy;return"query"===e.kind&&"network-only"!==t&&("cache-only"===t||u.has(e.key))}return function(e){var a=r.share(e),f=r.map((function(e){var r=u.get(e.key),n=t._extends({},r,{operation:p(e,{cacheOutcome:r?"hit":"miss"})});return"cache-and-network"===e.context.requestPolicy&&(n.stale=!0,h(i,e)),n}))(r.filter((function(e){return!y(e)&&l(e)}))(a)),d=r.tap((function(e){var t=e.operation;if(t){var r=o(e.data).concat(t.context.additionalTypenames||[]);if("mutation"===e.operation.kind){for(var n=new Set,a=0;a<r.length;a++){var s=r[a],f=c[s]||(c[s]=new Set);f.forEach((function(e){n.add(e)})),f.clear()}n.forEach((function(e){u.has(e)&&(t=u.get(e).operation,u.delete(e),h(i,t))}))}else if("query"===t.kind&&e.data){u.set(t.key,e);for(var p=0;p<r.length;p++){var l=r[p];(c[l]||(c[l]=new Set)).add(t.key)}}}}))(n(r.filter((function(e){return"query"!==e.kind||"cache-only"!==e.context.requestPolicy}))(r.map((function(e){return p(e,{cacheOutcome:"miss"})}))(r.merge([r.map(s)(r.filter((function(e){return!y(e)&&!l(e)}))(a)),r.filter((function(e){return y(e)}))(a)])))));return r.merge([f,d])}}function h(e,r){return e.reexecuteOperation(f(r.kind,r,t._extends({},r.context,{requestPolicy:"network-only"})))}var m=new Set;function x(e){var t=e.forward,n=new Set;function o(e){var t=e.key,r=e.kind;if("teardown"===r)return n.delete(t),!0;if("query"!==r&&"subscription"!==r)return!0;var o=n.has(t);return n.add(t),!o}function i(e){e.hasNext||n.delete(e.operation.key)}return function(e){var n=r.filter(o)(e);return r.tap(i)(t(n))}}function v(e){var n=e.forward;return function(e){var o=r.share(e),i=r.mergeMap((function(e){var n=e.key,i=r.filter((function(e){return"teardown"===e.kind&&e.key===n}))(o),u=t.makeFetchBody(e),a=t.makeFetchURL(e,u),c=t.makeFetchOptions(e,u);return r.onPush((function(e){}))(r.takeUntil(i)(t.makeFetchSource(e,a,c)))}))(r.filter((function(e){return"query"===e.kind||"mutation"===e.kind}))(o)),u=n(r.filter((function(e){return"query"!==e.kind&&"mutation"!==e.kind}))(o));return r.merge([i,u])}}function g(e){return function(e){return r.filter((function(){return!1}))(r.tap((function(e){}))(e))}}var b=g();function q(e){return function(t){var r=t.client;return e.reduceRight((function(e,t){return t({client:r,forward:e,dispatchDebug:function(e){}})}),t.forward)}}var w=[x,k,v],E=function e(n){var o=new Map,i=new Map,u=[],a=r.makeSubject(),p=a.source,d=a.next,y=!1;function k(e){for(y=!0,e&&d(e);e=u.shift();)d(e);y=!1}function h(e){var n=r.filter((function(t){return t.operation.kind===e.kind&&t.operation.key===e.key}))(E);return x.maskTypename&&(n=r.map((function(e){return t._extends({},e,{data:c(e.data)})}))(n)),"mutation"===e.kind?r.take(1)(r.onStart((function(){return k(e)}))(n)):r.share(r.onEnd((function(){o.delete(e.key),i.delete(e.key);for(var t=u.length-1;t>=0;t--)u[t].key===e.key&&u.splice(t,1);k(f("teardown",e,e.context))}))(r.onPush((function(t){o.set(e.key,t)}))(r.switchMap((function(n){return"query"!==e.kind||n.stale?r.fromValue(n):r.merge([r.fromValue(n),r.map((function(){return t._extends({},n,{stale:!0})}))(r.take(1)(r.filter((function(t){return"query"===t.kind&&t.key===e.key&&"cache-only"!==t.context.requestPolicy}))(p)))])}))(r.takeUntil(r.filter((function(t){return"teardown"===t.kind&&t.key===e.key}))(p))(n)))))}var m=this instanceof e?this:Object.create(e.prototype),x=t._extends(m,{url:n.url,fetchOptions:n.fetchOptions,fetch:n.fetch,suspense:!!n.suspense,requestPolicy:n.requestPolicy||"cache-first",preferGetMethod:!!n.preferGetMethod,maskTypename:!!n.maskTypename,operations$:p,reexecuteOperation:function(e){("mutation"===e.kind||i.has(e.key))&&(u.push(e),y||Promise.resolve().then(k))},createOperationContext:function(e){return e||(e={}),t._extends({},{url:x.url,fetchOptions:x.fetchOptions,fetch:x.fetch,preferGetMethod:x.preferGetMethod},e,{suspense:e.suspense||!1!==e.suspense&&x.suspense,requestPolicy:e.requestPolicy||x.requestPolicy})},createRequestOperation:function(e,r,n){return t.getOperationType(r.query),f(e,r,x.createOperationContext(n))},executeRequestOperation:function(e){return"mutation"===e.kind?h(e):r.make((function(n){var u=i.get(e.key);u||i.set(e.key,u=h(e));var a="cache-and-network"===e.context.requestPolicy||"network-only"===e.context.requestPolicy;return r.subscribe(n.next)(r.onEnd(n.complete)(r.onStart((function(){var r=o.get(e.key);if("subscription"===e.kind)return k(e);a&&k(e),null!=r&&r===o.get(e.key)?n.next(a?t._extends({},r,{stale:!0}):r):a||k(e)}))(u))).unsubscribe}))},executeQuery:function(e,t){var r=x.createRequestOperation("query",e,t);return x.executeRequestOperation(r)},executeSubscription:function(e,t){var r=x.createRequestOperation("subscription",e,t);return x.executeRequestOperation(r)},executeMutation:function(e,t){var r=x.createRequestOperation("mutation",e,t);return x.executeRequestOperation(r)},query:function(e,r,n){return n&&"boolean"==typeof n.suspense||(n=t._extends({},n,{suspense:!1})),s(x.executeQuery(t.createRequest(e,r),n))},readQuery:function(e,t,n){var o=null;return r.subscribe((function(e){o=e}))(x.query(e,t,n)).unsubscribe(),o},subscription:function(e,r,n){return x.executeSubscription(t.createRequest(e,r),n)},mutation:function(e,r,n){return s(x.executeMutation(t.createRequest(e,r),n))}}),v=l,b=q(void 0!==n.exchanges?n.exchanges:w),E=r.share(b({client:x,dispatchDebug:v,forward:g()})(p));return r.publish(E),x},O=E;exports.CombinedError=t.CombinedError,exports.createRequest=t.createRequest,exports.getOperationName=t.getOperationName,exports.makeErrorResult=t.makeErrorResult,exports.makeResult=t.makeResult,exports.mergeResultPatch=t.mergeResultPatch,exports.stringifyVariables=t.stringifyVariables,exports.Client=E,exports.cacheExchange=k,exports.composeExchanges=q,exports.createClient=O,exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=x,exports.defaultExchanges=w,exports.errorExchange=function(e){var t=e.onError;return function(e){var n=e.forward;return function(e){return r.tap((function(e){var r=e.error;r&&t(r,e.operation)}))(n(e))}}},exports.fallbackExchangeIO=b,exports.fetchExchange=v,exports.formatDocument=a,exports.gql=function(){for(var r=arguments,n=new Map,o=[],i=[],u=Array.isArray(arguments[0])?arguments[0][0]:arguments[0]||"",a=1;a<arguments.length;a++){var c=r[a];c&&c.definitions?i.push.apply(i,c.definitions):u+=c,u+=r[0][a]}return d(n,o,t.keyDocument(u).definitions),d(n,o,i),t.keyDocument({kind:e.Kind.DOCUMENT,definitions:o})},exports.makeOperation=f,exports.maskTypename=c,exports.ssrExchange=function(e){var n=!(!e||!e.staleWhileRevalidate),o={},i=[];function u(e){i.push(e.operation.key),1===i.length&&Promise.resolve().then((function(){for(var e;e=i.shift();)o[e]=null}))}var a=function(i){var a=i.client,c=i.forward;return function(i){var s=e&&"boolean"==typeof e.isClient?!!e.isClient:!a.suspense,f=r.share(i),p=c(r.filter((function(e){return!o[e.key]||!!o[e.key].hasNext}))(f)),l=r.map((function(e){var r=function(e,r){return{operation:e,data:r.data?JSON.parse(r.data):void 0,extensions:void 0,error:r.error?new t.CombinedError({networkError:r.error.networkError?new Error(r.error.networkError):void 0,graphQLErrors:r.error.graphQLErrors}):void 0,hasNext:r.hasNext}}(e,o[e.key]);return n&&!m.has(e.key)&&(r.stale=!0,m.add(e.key),h(a,e)),r}))(r.filter((function(e){return!!o[e.key]}))(f));return s?l=r.tap(u)(l):p=r.tap((function(e){var t=e.operation;if("mutation"!==t.kind){var r=function(e){var t=e.hasNext,r=e.data,n=e.error,o={};return void 0!==r&&(o.data=JSON.stringify(r)),t&&(o.hasNext=!0),n&&(o.error={graphQLErrors:n.graphQLErrors.map((function(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}))},n.networkError&&(o.error.networkError=""+n.networkError)),o}(e);o[t.key]=r}}))(p),r.merge([p,l])}};return a.restoreData=function(e){for(var t in e)null!==o[t]&&(o[t]=e[t])},a.extractData=function(){var e={};for(var t in o)null!=o[t]&&(e[t]=o[t]);return e},e&&e.initialState&&a.restoreData(e.initialState),a},exports.subscriptionExchange=function(n){var o=n.forwardSubscription,i=n.enableAllOperations;return function(n){var u=n.client,a=n.forward;function c(e){var t=e.kind;return"subscription"===t||!!i&&("query"===t||"mutation"===t)}return function(n){var i=r.share(n),s=r.mergeMap((function(n){var a=n.key,c=r.filter((function(e){return"teardown"===e.kind&&e.key===a}))(i);return r.takeUntil(c)(function(n){var i=o({key:n.key.toString(36),query:e.print(n.query),variables:n.variables,context:t._extends({},n.context)});return r.make((function(e){var r,o=e.next,a=e.complete,c=!1;return Promise.resolve().then((function(){c||(r=i.subscribe({next:function(e){return o(t.makeResult(n,e))},error:function(e){return o(t.makeErrorResult(n,e))},complete:function(){c||(c=!0,"subscription"===n.kind&&u.reexecuteOperation(f("teardown",n,n.context)),a())}}))})),function(){c=!0,r&&r.unsubscribe()}}))}(n))}))(r.filter(c)(i)),p=a(r.filter((function(e){return!c(e)}))(i));return r.merge([s,p])}}}; | ||
var e=require("graphql"),t=require("./8ce379e1.min.js"),n=require("wonka");function r(e,t){if(Array.isArray(e))for(var n=0;n<e.length;n++)r(e[n],t);else if("object"==typeof e&&null!==e)for(var o in e)"__typename"===o&&"string"==typeof e[o]?t[e[o]]=0:r(e[o],t);return t}function o(e){return Object.keys(r(e,{}))}var i=function(n){if(n.selectionSet&&!n.selectionSet.selections.some((function(t){return t.kind===e.Kind.FIELD&&"__typename"===t.name.value&&!t.alias})))return t._extends({},n,{selectionSet:t._extends({},n.selectionSet,{selections:n.selectionSet.selections.concat([{kind:e.Kind.FIELD,name:{kind:e.Kind.NAME,value:"__typename"}}])})})},u=new Map;function a(n){var r=t.keyDocument(n),o=u.get(r.__key);return o||(o=e.visit(r,{Field:i,InlineFragment:i}),Object.defineProperty(o,"__key",{value:r.__key,enumerable:!1}),u.set(r.__key,o)),o}function c(e){return e&&"object"==typeof e?Object.keys(e).reduce((function(t,n){var r=e[n];return"__typename"===n?Object.defineProperty(t,"__typename",{enumerable:!1,value:r}):t[n]=Array.isArray(r)?r.map(c):r&&"object"==typeof r&&"__typename"in r?c(r):r,t}),{}):e}function s(e){return e.toPromise=function(){return n.toPromise(n.take(1)(n.filter((function(e){return!e.stale&&!e.hasNext}))(e)))},e}function f(e,t,n){return n||(n=t.context),{key:t.key,query:t.query,variables:t.variables,kind:e,context:n}}function p(e,n){return f(e.kind,e,t._extends({},e.context,{meta:t._extends({},e.context.meta,n)}))}function l(){}function d(n,r,o){for(var i=0;i<o.length;i++)if(o[i].kind===e.Kind.FRAGMENT_DEFINITION){var u=o[i].name.value,a=t.stringifyDocument(o[i]);n.has(u)||(n.set(u,a),r.push(o[i]))}else r.push(o[i])}function y(e){var t=e.kind;return"mutation"!==t&&"query"!==t}function k(e){var r=e.forward,i=e.client,u=new Map,c=Object.create(null);function s(e){var t=f(e.kind,e);return t.query=a(e.query),t}function l(e){var t=e.context.requestPolicy;return"query"===e.kind&&"network-only"!==t&&("cache-only"===t||u.has(e.key))}return function(e){var a=n.share(e),f=n.map((function(e){var n=u.get(e.key),r=t._extends({},n,{operation:p(e,{cacheOutcome:n?"hit":"miss"})});return"cache-and-network"===e.context.requestPolicy&&(r.stale=!0,x(i,e)),r}))(n.filter((function(e){return!y(e)&&l(e)}))(a)),d=n.tap((function(e){var t=e.operation;if(t){var n=o(e.data).concat(t.context.additionalTypenames||[]);if("mutation"===e.operation.kind){for(var r=new Set,a=0;a<n.length;a++){var s=n[a],f=c[s]||(c[s]=new Set);f.forEach((function(e){r.add(e)})),f.clear()}r.forEach((function(e){u.has(e)&&(t=u.get(e).operation,u.delete(e),x(i,t))}))}else if("query"===t.kind&&e.data){u.set(t.key,e);for(var p=0;p<n.length;p++){var l=n[p];(c[l]||(c[l]=new Set)).add(t.key)}}}}))(r(n.filter((function(e){return"query"!==e.kind||"cache-only"!==e.context.requestPolicy}))(n.map((function(e){return p(e,{cacheOutcome:"miss"})}))(n.merge([n.map(s)(n.filter((function(e){return!y(e)&&!l(e)}))(a)),n.filter((function(e){return y(e)}))(a)])))));return n.merge([f,d])}}function x(e,n){return e.reexecuteOperation(f(n.kind,n,t._extends({},n.context,{requestPolicy:"network-only"})))}var h=new Set;function m(e){var t=e.forward,r=new Set;function o(e){var t=e.key,n=e.kind;if("teardown"===n)return r.delete(t),!0;if("query"!==n&&"subscription"!==n)return!0;var o=r.has(t);return r.add(t),!o}function i(e){e.hasNext||r.delete(e.operation.key)}return function(e){var r=n.filter(o)(e);return n.tap(i)(t(r))}}function v(e){var r=e.forward;return function(e){var o=n.share(e),i=n.mergeMap((function(e){var r=e.key,i=n.filter((function(e){return"teardown"===e.kind&&e.key===r}))(o),u=t.makeFetchBody(e),a=t.makeFetchURL(e,u),c=t.makeFetchOptions(e,u);return n.onPush((function(e){}))(n.takeUntil(i)(t.makeFetchSource(e,a,c)))}))(n.filter((function(e){return"query"===e.kind||"mutation"===e.kind}))(o)),u=r(n.filter((function(e){return"query"!==e.kind&&"mutation"!==e.kind}))(o));return n.merge([i,u])}}function g(e){return function(e){return n.filter((function(){return!1}))(n.tap((function(e){}))(e))}}var b=g();function q(e){return function(t){var n=t.client;return e.reduceRight((function(e,t){return t({client:n,forward:e,dispatchDebug:function(e){}})}),t.forward)}}var w=[m,k,v],E=function e(r){var o=new Map,i=new Map,u=[],a=n.makeSubject(),p=a.source,d=a.next,y=!1;function k(e){for(y=!0,e&&d(e);e=u.shift();)d(e);y=!1}function x(e){var r=n.filter((function(t){return t.operation.kind===e.kind&&t.operation.key===e.key}))(E);return m.maskTypename&&(r=n.map((function(e){return t._extends({},e,{data:c(e.data)})}))(r)),"mutation"===e.kind?n.take(1)(n.onStart((function(){return k(e)}))(r)):n.share(n.onEnd((function(){o.delete(e.key),i.delete(e.key);for(var t=u.length-1;t>=0;t--)u[t].key===e.key&&u.splice(t,1);k(f("teardown",e,e.context))}))(n.onPush((function(t){o.set(e.key,t)}))(n.switchMap((function(r){return"query"!==e.kind||r.stale?n.fromValue(r):n.merge([n.fromValue(r),n.map((function(){return t._extends({},r,{stale:!0})}))(n.take(1)(n.filter((function(t){return"query"===t.kind&&t.key===e.key&&"cache-only"!==t.context.requestPolicy}))(p)))])}))(n.takeUntil(n.filter((function(t){return"teardown"===t.kind&&t.key===e.key}))(p))(r)))))}var h=this instanceof e?this:Object.create(e.prototype),m=t._extends(h,{url:r.url,fetchOptions:r.fetchOptions,fetch:r.fetch,suspense:!!r.suspense,requestPolicy:r.requestPolicy||"cache-first",preferGetMethod:!!r.preferGetMethod,maskTypename:!!r.maskTypename,operations$:p,reexecuteOperation:function(e){("mutation"===e.kind||i.has(e.key))&&(u.push(e),y||Promise.resolve().then(k))},createOperationContext:function(e){return e||(e={}),t._extends({},{url:m.url,fetchOptions:m.fetchOptions,fetch:m.fetch,preferGetMethod:m.preferGetMethod},e,{suspense:e.suspense||!1!==e.suspense&&m.suspense,requestPolicy:e.requestPolicy||m.requestPolicy})},createRequestOperation:function(e,n,r){return t.getOperationType(n.query),f(e,n,m.createOperationContext(r))},executeRequestOperation:function(e){return"mutation"===e.kind?x(e):n.make((function(r){var u=i.get(e.key);u||i.set(e.key,u=x(e));var a="cache-and-network"===e.context.requestPolicy||"network-only"===e.context.requestPolicy;return n.subscribe(r.next)(n.onEnd(r.complete)(n.onStart((function(){var n=o.get(e.key);if("subscription"===e.kind)return k(e);a&&k(e),null!=n&&n===o.get(e.key)?r.next(a?t._extends({},n,{stale:!0}):n):a||k(e)}))(u))).unsubscribe}))},executeQuery:function(e,t){var n=m.createRequestOperation("query",e,t);return m.executeRequestOperation(n)},executeSubscription:function(e,t){var n=m.createRequestOperation("subscription",e,t);return m.executeRequestOperation(n)},executeMutation:function(e,t){var n=m.createRequestOperation("mutation",e,t);return m.executeRequestOperation(n)},query:function(e,n,r){return r&&"boolean"==typeof r.suspense||(r=t._extends({},r,{suspense:!1})),s(m.executeQuery(t.createRequest(e,n),r))},readQuery:function(e,t,r){var o=null;return n.subscribe((function(e){o=e}))(m.query(e,t,r)).unsubscribe(),o},subscription:function(e,n,r){return m.executeSubscription(t.createRequest(e,n),r)},mutation:function(e,n,r){return s(m.executeMutation(t.createRequest(e,n),r))}}),v=l,b=q(void 0!==r.exchanges?r.exchanges:w),E=n.share(b({client:m,dispatchDebug:v,forward:g()})(p));return n.publish(E),m},O=E;exports.CombinedError=t.CombinedError,exports.createRequest=t.createRequest,exports.getOperationName=t.getOperationName,exports.makeErrorResult=t.makeErrorResult,exports.makeResult=t.makeResult,exports.mergeResultPatch=t.mergeResultPatch,exports.stringifyVariables=t.stringifyVariables,exports.Client=E,exports.cacheExchange=k,exports.composeExchanges=q,exports.createClient=O,exports.debugExchange=function(e){var t=e.forward;return function(e){return t(e)}},exports.dedupExchange=m,exports.defaultExchanges=w,exports.errorExchange=function(e){var t=e.onError;return function(e){var r=e.forward;return function(e){return n.tap((function(e){var n=e.error;n&&t(n,e.operation)}))(r(e))}}},exports.fallbackExchangeIO=b,exports.fetchExchange=v,exports.formatDocument=a,exports.gql=function(){for(var n=arguments,r=new Map,o=[],i=[],u=Array.isArray(arguments[0])?arguments[0][0]:arguments[0]||"",a=1;a<arguments.length;a++){var c=n[a];c&&c.definitions?i.push.apply(i,c.definitions):u+=c,u+=n[0][a]}return d(r,o,t.keyDocument(u).definitions),d(r,o,i),t.keyDocument({kind:e.Kind.DOCUMENT,definitions:o})},exports.makeOperation=f,exports.maskTypename=c,exports.ssrExchange=function(e){var r=!(!e||!e.staleWhileRevalidate),o=!(!e||!e.includeExtensions),i={},u=[];function a(e){u.push(e.operation.key),1===u.length&&Promise.resolve().then((function(){for(var e;e=u.shift();)i[e]=null}))}var c=function(u){var c=u.client,s=u.forward;return function(u){var f=e&&"boolean"==typeof e.isClient?!!e.isClient:!c.suspense,p=n.share(u),l=s(n.filter((function(e){return!i[e.key]||!!i[e.key].hasNext}))(p)),d=n.map((function(e){var n=function(e,n,r){return{operation:e,data:n.data?JSON.parse(n.data):void 0,extensions:r&&n.extensions?JSON.parse(n.extensions):void 0,error:n.error?new t.CombinedError({networkError:n.error.networkError?new Error(n.error.networkError):void 0,graphQLErrors:n.error.graphQLErrors}):void 0,hasNext:n.hasNext}}(e,i[e.key],o);return r&&!h.has(e.key)&&(n.stale=!0,h.add(e.key),x(c,e)),n}))(n.filter((function(e){return!!i[e.key]}))(p));return f?d=n.tap(a)(d):l=n.tap((function(e){var t=e.operation;if("mutation"!==t.kind){var n=function(e,t){var n=e.hasNext,r=e.data,o=e.extensions,i=e.error,u={};return void 0!==r&&(u.data=JSON.stringify(r)),t&&void 0!==o&&(u.extensions=JSON.stringify(o)),n&&(u.hasNext=!0),i&&(u.error={graphQLErrors:i.graphQLErrors.map((function(e){return e.path||e.extensions?{message:e.message,path:e.path,extensions:e.extensions}:e.message}))},i.networkError&&(u.error.networkError=""+i.networkError)),u}(e,o);i[t.key]=n}}))(l),n.merge([l,d])}};return c.restoreData=function(e){for(var t in e)null!==i[t]&&(i[t]=e[t])},c.extractData=function(){var e={};for(var t in i)null!=i[t]&&(e[t]=i[t]);return e},e&&e.initialState&&c.restoreData(e.initialState),c},exports.subscriptionExchange=function(r){var o=r.forwardSubscription,i=r.enableAllOperations;return function(r){var u=r.client,a=r.forward;function c(e){var t=e.kind;return"subscription"===t||!!i&&("query"===t||"mutation"===t)}return function(r){var i=n.share(r),s=n.mergeMap((function(r){var a=r.key,c=n.filter((function(e){return"teardown"===e.kind&&e.key===a}))(i);return n.takeUntil(c)(function(r){var i=o({key:r.key.toString(36),query:e.print(r.query),variables:r.variables,context:t._extends({},r.context)});return n.make((function(e){var n,o=e.next,a=e.complete,c=!1;return Promise.resolve().then((function(){c||(n=i.subscribe({next:function(e){return o(t.makeResult(r,e))},error:function(e){return o(t.makeErrorResult(r,e))},complete:function(){c||(c=!0,"subscription"===r.kind&&u.reexecuteOperation(f("teardown",r,r.context)),a())}}))})),function(){c=!0,n&&n.unsubscribe()}}))}(r))}))(n.filter(c)(i)),p=a(n.filter((function(e){return!c(e)}))(i));return n.merge([s,p])}}}; | ||
//# sourceMappingURL=urql-core.min.js.map |
{ | ||
"name": "@urql/core", | ||
"version": "2.3.2", | ||
"version": "2.3.3", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
398771
2858