Nested keys required?
See original GitHub issueHello, with React query i naturally have this scenario:
-list of customers by account filtered by order by
how i map this to cache keys is:
`function customersByAccountId(accountId: number) { return [“customerListByAccountId”, accountId]; }
function customersByAccountIdFiltered(accountId: number, queryFilter: QueryFilter) { return […customersByAccountId(accountId), “list”, { queryFilter }]; }`
This way, when i edit an attribute for a customer, i can: update the in memory query for customersByAccountIdFiltered (which will change the attribute on the current screen, without reload)
and invalidate customersByAccountId (with refetchActive: false,) which will invalidate all other cached filtered entries.
How do i map this with query-key-factory?
Issue Analytics
- State:
- Created a year ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Python | Add keys to nested dictionary
This method is used in cases where more than one keys need to be added to the nested dictionaries. The update function accepts...
Read more >javascript - nested key property requirements in React
Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array...
Read more >TypeScript Utility: keyof nested object
In this blog post, we will learn how to build a TypeScript util type, that exposes all the key paths of an object,...
Read more >Python - Accessing Nested Dictionary Keys - YouTube
Working with .json data is a very common task, no matter if you're coming from the data science or the web development world....
Read more >Python Nested Dictionary (With Examples)
We can shrink or grow nested dictionary as need. Like Dictionary, it also has key and value. Dictionary are accessed using key.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
np,
here is another example: I have a list of accounts and each account has customers i want to do different lists per customers, as they are calling different endpoints. I could put everything as in a filter for this simple example but i may not want to.
API:
The first gives the list of all customers non invited ordered by desc. The second gives the list of all customers non invited ordered by asc.
This would naturally map as:
["customers",1,"invited", {sort:"desc"}]
And:["customers",1,"non_invited", {sort:"asc"}]
With
1
, the accountIdNow say i’m adding a customer to the first cache. I would
setQuery
on["customers",1,"invited", {sort:"desc"}]
and add a user “John” I now need to invalidate the followingqueryClient.invalidateQueries(["customers",1], { refetchActive: false });
This way:Is there a way to map this?
Something like this would not give me what i want to accomplish:
As there would be no way to invalidate
queryClient.invalidateQueries(["customers",1], { refetchActive: false });
@kimbuba just letting you know, v1.0 has been released with support for nested keys: https://github.com/lukemorales/query-key-factory/releases/tag/v1.0.0