Skip to content
Discussion options

You must be logged in to vote

Hey @bylly1 !

Two things jumped out at me. You're not using the queryOptions helper. Your factory returns a plain object. That works at runtime, but you lose onz of the reasons this pattern exists, the type-safe inference. The queryOptions() helper looks like an identity function (it just returns what you give it), but it gives TypeScript the ability to infer the return type of queryFn, catch typos on option names, and flow types correctly into queryClient.getQueryData, prefetchQuery, etc...

The spread order can also be a little risky for me. In your factory you have ...options, then queryKey, then queryFn. This is actually fine as written because queryKey and queryFn come after and will …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bylly1
Comment options

Answer selected by bylly1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants