correct way to call query inside a function - TanStack