Description
Discussed in #6318
Originally posted by TomCaserta September 11, 2024
Essentially I'm reading over the multitenancy documentation https://refine.dev/docs/guides-concepts/multi-tenancy/ and I've implemented what it suggests:
- Route parameter called
:tenantId
- My data provider uses the
tenantId
found in the meta and sends it to my endpoints via a header
The issue seems to be when I replace the tenantId parameter in the URL it doesn't actually reload the data.
After looking at the examples it seems it uses the params and the tenant ID as a filter parameter in the multi tenancy strapi example.
This seems to be different to the suggested approach and of course works in that scenario as the param changing causes the query key to change as the filters are changing. As far as I can tell the meta (combinedMeta) is not taken into consideration in the useList
query key creation, is this intentional?:
https://github.com/refinedev/refine/blob/master/packages/core/src/hooks/data/useList.ts#L238
Is there any way to make this work using route parameters and without specifying a filter on every usage of a useList/useOne/useMany hook?
Proposed Fix
When generating query and mutation keys, combinedMeta
should be used instead of preferredMeta
. This case needs to be done for every data hook to be consistent. A related test case needs to be added.