Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

(request-policy) - Fix requestPolicyExchange usage with persisted caching (#1742)

* Ignore files generated by JetBrains IDEs like Intellij

* (request-policy) - Fix TTL being set on cache hits

Do not set the TTL unless cache outcome is "miss". If the first result
to come through the requestPolicyExchange was a cache-hit then the ttl was incorrectly
set initially based on this cache hit and no network request was made. This happens when using
persisted caching with the graphcache exchange since the very first result can be a cache hit.

https://github.com/FormidableLabs/urql/issues/1644

* Add changeset

authored by

Malcolm and committed by
GitHub
616ac76c b5c61666

+8 -5
+5
.changeset/sweet-beers-brush.md
··· 1 + --- 2 + '@urql/exchange-request-policy': patch 3 + --- 4 + 5 + Do not set the TTL unless cache outcome is "miss". Previously we set the TTL on cache "miss" if it was the first time an operation returned a result, now the TTL is only set on cache miss results. This allows the request policy exchange to work when using persisted caching.
+2 -1
.gitignore
··· 1 + /.idea 1 2 /.vscode 2 3 **/node_modules 3 4 *.log ··· 22 23 examples/*/android/ 23 24 examples/*/.watchmanconfig 24 25 examples/*/metro.config.js 25 - examples/*/babel.config.js 26 + examples/*/babel.config.js
+1 -4
exchanges/request-policy/src/requestPolicyExchange.ts
··· 45 45 46 46 const processIncomingResults = (result: OperationResult): void => { 47 47 const meta = result.operation.context.meta; 48 - const isMiss = 49 - !operations.has(result.operation.key) || 50 - !meta || 51 - meta.cacheOutcome === 'miss'; 48 + const isMiss = !meta || meta.cacheOutcome === 'miss'; 52 49 if (isMiss) { 53 50 operations.set(result.operation.key, new Date().getTime()); 54 51 }