Closed
Description
Is your feature request related to a problem? Please describe.
I cannot use a hook outside a component. This is not ideal when I use react router loaders.
Describe the solution you'd like
// Current query definition
export const useContactDetailsServiceGetContactDetails = ({ client }, queryKey?, options?) =>
useQuery({
queryKey: Common.UseContactDetailsServiceGetContactDetailsKeyFn({ client }, queryKey),
queryFn: () => ContactDetailsService.getContactDetails({ client }), ...options
});
// New query definition Option
export const UseContactDetailsSimpleServiceGetContactDetails = async (queryClient, { client }, queryKey?, options?) =>
await queryClient.ensureQueryData({
queryKey: Common.UseContactDetailsServiceGetContactDetailsKeyFn({ client }, queryKey),
queryFn: () => ContactDetailsService.getContactDetails({ client }),
})
// This will allow me to do this
export const loader =
(queryClient) =>
async ({ params }) => {
return await UseContactDetailsSimpleServiceGetContactDetails(queryClient, { params.client })
}
Adding a cli option to generate one type of query or both can be added.
Describe alternatives you've considered
Manually creating the new query definition
Additional context
Add any other context or screenshots about the feature request here.