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
More ways of structure keys #19
Comments
@TommySorensen thanks for the suggestion and for sharing more information about your use cases. |
@lukemorales Sounds great 👍 export const cmsQueries = createQueryKeys('cms', {
content: (locale: string, path: string) => ({ locale, path, url: '/some/url' }),
});
export const queries = mergeQueryKeys(cmsQueries);
export type Queries = inferQueryKeyStore<typeof queries>;
function getPage(context: QueryFunctionContext<Queries['cms']['content']>) {
const { signal, queryKey } = context;
const [, , { locale, path, url }] = queryKey;
const searchParams = new URLSearchParams();
searchParams.set('locale', locale);
searchParams.set('path', path);
return ky
.get(url, { signal })
.json<Page>();
} |
You should already be able to do that? Not sure you're suggesting some feature or just giving an example of an idea you're considering 😅, but I don't see why you wouldn't already be able to do |
I guess it's me trying to give more context to the talk 😀 |
@TommySorensen 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 |
@lukemorales Yeah thx 👍 I will test it out tomorrow in my project. |
It would be nice to have a third level in the factory. For example if you have 5 different api urls with 30 endpoints underneed and not only a single one
So i can have a query like
['cms', 'content', 'page', { locale, path }]
.Basically i would have multiple swagger interfaces like this one. So in this case i would like
['bff', 'basket', 'baskets', { basketReference }]
The text was updated successfully, but these errors were encountered: