Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Queries are not responding to URL parameter changes #6377

Open
aliemir opened this issue Sep 29, 2024 Discussed in #6318 · 1 comment
Open

[BUG] Queries are not responding to URL parameter changes #6377

aliemir opened this issue Sep 29, 2024 Discussed in #6318 · 1 comment
Labels
bug Something isn't working

Comments

@aliemir
Copy link
Member

aliemir commented Sep 29, 2024

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:

  1. Route parameter called :tenantId
  2. 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.

@aliemir aliemir added the bug Something isn't working label Sep 29, 2024
@mr-loop-1
Copy link

Hi @aliemir I can work on this. Please assign me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants