@urql/exchange-persisted
Advanced tools
Comparing version 4.1.0 to 4.1.1-canary-d6e435c5
# @urql/exchange-persisted-fetch | ||
## 4.1.1-canary-d6e435c5 | ||
### Patch Changes | ||
- Warn about cached persisted-miss results in development, when a `persistedExchange()` sees a persisted-miss error for a result that's already seen a persisted-miss error (i.e. two misses). This shouldn't happen unless something is caching persisted errors and we should warn about this appropriately | ||
Submitted by [@kitten](https://github.com/kitten) (See [#3442](https://github.com/urql-graphql/urql/pull/3442)) | ||
## 4.1.0 | ||
@@ -4,0 +11,0 @@ |
@@ -122,2 +122,8 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
} else if (result.error && isPersistedMiss(result.error)) { | ||
if (result.operation.extensions.persistedQuery.miss) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
console.warn('persistedExchange()’s results include two misses for the same operation.\n' + 'This is not expected as it means a persisted error has been delivered for a non-persisted query!\n' + 'Another exchange with a cache may be delivering an outdated result. For example, a server-side ssrExchange() may be caching an errored result.\n' + 'Try moving the persistedExchange() in past these exchanges, for example in front of your fetchExchange.'); | ||
} | ||
return result; | ||
} | ||
// Update operation with unsupported attempt | ||
@@ -124,0 +130,0 @@ var _followupOperation = core.makeOperation(result.operation.kind, result.operation); |
@@ -1,2 +0,2 @@ | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("wonka"),t=require("@urql/core"),n="undefined"!=typeof window?window.crypto:"undefined"!=typeof self?self.crypto:null,i=async r=>{if(n&&n.subtle){var t=await n.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(r));return new Uint8Array(t).reduce(((e,r)=>e+r.toString(16).padStart(2,"0")),"")}return await(async()=>{if(!e)try{e=new Function("require",'return require("crypto")')(require)}catch(r){try{e=new Function('return import("crypto")')()}catch(e){}}return e})()?(await e).createHash("sha256").update(r).digest("hex"):""};exports.persistedExchange=e=>({forward:n})=>{e||(e={});var s=e.preferGetForPersistedQueries,o=!!e.enforcePersistedQueries,a=e.generateHash||i,u=!!e.enableForMutation,p=!0,d=e=>p&&!e.context.persistAttempt&&(u&&"mutation"===e.kind||"query"===e.kind);return e=>{var i=r.makeSubject(),u=r.filter((e=>!d(e)))(e),c=r.mergeMap((n=>{var i=(async e=>{var r=t.makeOperation(e.kind,e,{...e.context,persistAttempt:!0}),n=await a(t.stringifyDocument(e.query),e.query);return n&&(r.extensions={...r.extensions,persistedQuery:{version:1,sha256Hash:n}},"query"===r.kind&&s&&(r.context.preferGetMethod=s)),r})(n);return r.takeUntil(r.filter((e=>"teardown"===e.kind&&e.key===n.key))(e))(r.fromPromise(i))}))(r.filter(d)(e));return r.filter((e=>!!e))(r.map((e=>{if(!o&&e.operation.extensions&&e.operation.extensions.persistedQuery){if(e.error&&e.error.graphQLErrors.some((e=>"PersistedQueryNotSupported"===e.message))){p=!1;var r=t.makeOperation(e.operation.kind,e.operation);return r.extensions&&delete r.extensions.persistedQuery,i.next(r),null}if(e.error&&e.error.graphQLErrors.some((e=>"PersistedQueryNotFound"===e.message))){var n=t.makeOperation(e.operation.kind,e.operation);return n.extensions={...n.extensions,persistedQuery:{...(n.extensions||{}).persistedQuery,miss:!0}},i.next(n),null}}return e}))(n(r.merge([c,u,i.source]))))}}; | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("wonka"),t=require("@urql/core"),n="undefined"!=typeof window?window.crypto:"undefined"!=typeof self?self.crypto:null,i=async r=>{if(n&&n.subtle){var t=await n.subtle.digest({name:"SHA-256"},(new TextEncoder).encode(r));return new Uint8Array(t).reduce(((e,r)=>e+r.toString(16).padStart(2,"0")),"")}return await(async()=>{if(!e)try{e=new Function("require",'return require("crypto")')(require)}catch(r){try{e=new Function('return import("crypto")')()}catch(e){}}return e})()?(await e).createHash("sha256").update(r).digest("hex"):""};exports.persistedExchange=e=>({forward:n})=>{e||(e={});var s=e.preferGetForPersistedQueries,o=!!e.enforcePersistedQueries,a=e.generateHash||i,u=!!e.enableForMutation,p=!0,d=e=>p&&!e.context.persistAttempt&&(u&&"mutation"===e.kind||"query"===e.kind);return e=>{var i=r.makeSubject(),u=r.filter((e=>!d(e)))(e),y=r.mergeMap((n=>{var i=(async e=>{var r=t.makeOperation(e.kind,e,{...e.context,persistAttempt:!0}),n=await a(t.stringifyDocument(e.query),e.query);return n&&(r.extensions={...r.extensions,persistedQuery:{version:1,sha256Hash:n}},"query"===r.kind&&s&&(r.context.preferGetMethod=s)),r})(n);return r.takeUntil(r.filter((e=>"teardown"===e.kind&&e.key===n.key))(e))(r.fromPromise(i))}))(r.filter(d)(e));return r.filter((e=>!!e))(r.map((e=>{if(!o&&e.operation.extensions&&e.operation.extensions.persistedQuery){if(e.error&&e.error.graphQLErrors.some((e=>"PersistedQueryNotSupported"===e.message))){p=!1;var r=t.makeOperation(e.operation.kind,e.operation);return r.extensions&&delete r.extensions.persistedQuery,i.next(r),null}if(e.error&&e.error.graphQLErrors.some((e=>"PersistedQueryNotFound"===e.message))){if(e.operation.extensions.persistedQuery.miss)return e;var n=t.makeOperation(e.operation.kind,e.operation);return n.extensions={...n.extensions,persistedQuery:{...(n.extensions||{}).persistedQuery,miss:!0}},i.next(n),null}}return e}))(n(r.merge([y,u,i.source]))))}}; | ||
//# sourceMappingURL=urql-exchange-persisted.min.js.map |
{ | ||
"name": "@urql/exchange-persisted", | ||
"version": "4.1.0", | ||
"version": "4.1.1-canary-d6e435c5", | ||
"description": "An exchange that allows for persisted queries support when fetching queries", | ||
@@ -41,3 +41,3 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@urql/core": ">=4.1.0", | ||
"@urql/core": ">=4.2.0", | ||
"wonka": "^6.3.2" | ||
@@ -47,3 +47,3 @@ }, | ||
"graphql": "^16.0.0", | ||
"@urql/core": "4.1.0" | ||
"@urql/core": "4.2.0" | ||
}, | ||
@@ -50,0 +50,0 @@ "publishConfig": { |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
95493
355
2
4
Updated@urql/core@>=4.2.0