T
TanStack•13mo ago
fascinating-indigo

"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
fascinating-indigo
fascinating-indigoOP•13mo 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);
},
},
});
extended-salmon
extended-salmon•13mo ago
this doesn't work because queryKey needs to be an array
fascinating-indigo
fascinating-indigoOP•13mo 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
extended-salmon
extended-salmon•13mo ago
Maybe that package has a different api, idk
fascinating-indigo
fascinating-indigoOP•13mo 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?