T
TanStack•16mo ago
fair-rose

"null" as queryKey

Hi all, We are using createQueryKeys(...) from the query-key-factory so I believe technically, having queryKey: null works. Is it still best practice to explicitly list a queryKey? What would be the argument to use something other than null if everything is being passed through the factory?
5 Replies
fair-rose
fair-roseOP•16mo ago
For example:
export const monitors = createQueryKeys('monitors', {
list: {
queryKey: null,
queryFn: ({ signal }) => {
return UptimeService().getMonitors(signal);
},
},
});
export const monitors = createQueryKeys('monitors', {
list: {
queryKey: null,
queryFn: ({ signal }) => {
return UptimeService().getMonitors(signal);
},
},
});
quickest-silver
quickest-silver•16mo ago
this doesn't work because queryKey needs to be an array
fair-rose
fair-roseOP•16mo ago
hi @TkDodo 🔮 , thank you for the response. That is what I thought, but the docs on: https://github.com/lukemorales/query-key-factory have this:
No description
quickest-silver
quickest-silver•16mo ago
Maybe that package has a different api, idk
fair-rose
fair-roseOP•16mo ago
Got it. I think I confused your reference to a query-key-factory with that specific library. Thank you for the clarification

Did you find this page helpful?