You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any good examples of https://formidable.com/open-source/urql/docs/api/request-policy-exchange/ ?
When I first saw it I thought that it will enable a very precise centralized approach to refreshing cached data.
Similar to, let stay, Graphcache cacheExchange config like { updates: {...} } where you can specify a strategy for each mutation/subscription.
Here I thought will be the same but for each root query, so if you can make it like.
requestPolicyExchange({
operations: {
Query: {
me: {
ttl: 60000,
shouldUpdate: () => {...} // If that is even needed TBH
}
}
}
})
So you can kinda make ttl per field on Query type and then add some callback shouldUpdate logic where you can override upgrade to cache-and-network but only for this specific field.
But it's definitely different :)
So, even tho it gives a bit more control, it feels like it's still not as granular as I would expect it to be as for different Query fields I may want to have different ttl.
So the only option is to keep ttl for other operations to be in local storage (for offlineCache case only tho) and set ttl to the shortest ttl you expect, and for other queries that you expect to be upgraded after few hours let say actually return false in shouldUpdate and ignore for those that you're fine with default ttl.
Dunno, hard to understand how this helps, so maybe I'm getting it wrong :) I guess sort of useEffect here and there that will flip cache-and-network after some time, may work better :D
And is it expected to work fine with offlineCache? Any tradeoffs or gotchas?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Any good examples of https://formidable.com/open-source/urql/docs/api/request-policy-exchange/ ?
When I first saw it I thought that it will enable a very precise centralized approach to refreshing cached data.
Similar to, let stay, Graphcache
cacheExchange
config like{ updates: {...} }
where you can specify a strategy for each mutation/subscription.Here I thought will be the same but for each root query, so if you can make it like.
So you can kinda make
ttl
per field on Query type and then add some callbackshouldUpdate
logic where you can override upgrade tocache-and-network
but only for this specific field.But it's definitely different :)
So, even tho it gives a bit more control, it feels like it's still not as granular as I would expect it to be as for different
Query
fields I may want to have differentttl
.So the only option is to keep
ttl
for other operations to be in local storage (for offlineCache case only tho) and setttl
to the shortestttl
you expect, and for other queries that you expect to be upgraded after few hours let say actually returnfalse
inshouldUpdate
and ignore for those that you're fine with defaultttl
.Dunno, hard to understand how this helps, so maybe I'm getting it wrong :) I guess sort of
useEffect
here and there that will flipcache-and-network
after some time, may work better :DAnd is it expected to work fine with
offlineCache
? Any tradeoffs or gotchas?Beta Was this translation helpful? Give feedback.
All reactions