query-key-factory icon indicating copy to clipboard operation
query-key-factory copied to clipboard

support for nested keys?

Open Shajansheriff opened this issue 1 year ago • 2 comments

This is just to initiate a discussion around supporting nested keys. @lukemorales have you seen trpc router examples https://trpc.io/docs/v9/merging-routers? It would be great if we could think about how to support nested and merging keys. Most of the time, people like to organise in a central location.

`

Shajansheriff avatar Aug 30 '22 12:08 Shajansheriff

@Shajansheriff thanks for starting the discussion!

I think supporting nested keys is a natural evolution of the package, it will be a fun experiment with Typescript to make that happen.

I really liked the idea of merging the keys, and inspired by that I've got a similar API:

CleanShot 2022-08-30 at 19 27 45

It uses the default key a user provided to create the query scope to populate the fields on a single object. How does that sound to you?

lukemorales avatar Aug 30 '22 22:08 lukemorales

I feel like providing both APIs (creating smaller scopes and merging into a single one, and creating a single huge factory) will be useful for cases that depend on how people like to structure their code.

I'm thinking createQueryKeys + createMergedQueryKeysFactory (name TBD) will serve people that like smaller files and slices of objects that they can then merge into a big one, and the next step would be to create a createQueryKeysFactory that creates a single huge object

lukemorales avatar Aug 30 '22 22:08 lukemorales