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
Multi-tenant application where users can switch tenant context without navigating away (e.g., tenant switcher dropdown). We use queryKeyHashFn to transparently scope queries by user and tenant:
This works because setOptions recomputes the hash when not provided, but it relies on internal behavior (_defaulted causing early return in defaultQueryOptions).
Proposal
An official API to rescope active observers, e.g.:
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
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