So practically both ways are same or different? In terms of good architecture what should be the preferred way and why?
usePreloadedQuery
sends the request while the component is rendering, and can suspend with a loading state if the component is ready before the query returns.
On the other hand useLazyLoadQuery
sends the request after the component has rendered.
Because API requests generally take longer than React renders, it is better to start fetching as early as possible. Using prefetching with React.Suspense
also improves user experience, because they won't see the component rendering nothing or an empty initial state before becoming populated with data.