Replies: 1 comment
-
|
I’m wondering - if the user switches tenant and this doesn’t re-render the active components, how are they getting new data? And if the I’m guessing the affected components do re-render because they are somehow subscribed to those The point I’m trying to get towards is that using a different hash wasn’t meant to let you bypass explicit dependencies (and making them implicit). We have the hashing API to allow users to store non-json-serializable things in the QueryKey, so that they can provide their own hashing. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Use Case
Multi-tenant application where users can switch tenant context without navigating away (e.g., tenant switcher dropdown). We use
queryKeyHashFnto transparently scope queries by user and tenant:This gives us context-agnostic query definitions that work across different tenants without explicitly adding tenant to every queryKey.
The Problem
When tenant changes mid-session, active observers still have their cached
queryHash. There's no official API to trigger hash recalculation.Current Workaround
We force recalculation by calling
setOptionswithoutqueryHashor_defaulted:This works because
setOptionsrecomputes the hash when not provided, but it relies on internal behavior (_defaultedcausing early return indefaultQueryOptions).Proposal
An official API to rescope active observers, e.g.:
Alternatives Considered
Question
Is there an official/recommended way to handle this? Or would a new API be considered for this use case?
Beta Was this translation helpful? Give feedback.
All reactions