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 · 7 comments
Open

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

aliemir opened this issue Sep 29, 2024 Discussed in #6318 · 7 comments
Assignees
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

@BatuhanW
Copy link
Member

BatuhanW commented Oct 7, 2024

Hey @mr-loop-1 assigned issue to you.

@mr-loop-1
Copy link

@aliemir why do we need to do same for mutation keys that you mentioned in your fix.

@aliemir
Copy link
Member Author

aliemir commented Oct 10, 2024

Hey @mr-loop-1, I wanted to make sure we check for every usage of the keys in @refinedev/core and use combined meta if wrong version is used. As far as I remember, mutation keys doesn't have any meta so no change will be required in them. 😅 My mistake, sorry for the mislead 🙏

@mr-loop-1
Copy link

Do we need a separate mockdata file for multi-tenant testing similar to this
https://github.com/refinedev/refine/blob/master/packages/core/test/dataMocks.ts

@aliemir
Copy link
Member Author

aliemir commented Oct 14, 2024

Do we need a separate mockdata file for multi-tenant testing similar to this https://github.com/refinedev/refine/blob/master/packages/core/test/dataMocks.ts

@mr-loop-1 you can provide custom methods/mocks in the test case if they're going to be used in one place only 🤔

@mr-loop-1
Copy link

mr-loop-1 commented Oct 24, 2024

I worked on this extensively today. Isn't this test case related to same, I read in docs that param is both for route and query params.

it("should only pass meta from the hook parameter and query parameters to the dataProvider", async () => {

also, i may not be able to work on this for sometime hence unassigning

@mr-loop-1 mr-loop-1 removed their assignment Oct 24, 2024
@BatuhanW BatuhanW added this to the December '24 Release milestone Nov 20, 2024
@BatuhanW BatuhanW assigned BatuhanW and unassigned alicanerdurmaz Nov 20, 2024
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

4 participants