Open isBatak opened 2 years ago
At the first, Thank you for sharing your thought! I think I have to explain why I decided to design like this. I tried to use many QueryClient methods for several purposes and Optimistic Update is one of them, but QueryClient does not infer the exact query result type. so I write a small function to use QueryClient's methods and get the exact query type. it was the first step of this!
BTW, I think your thought had pointed very importantly and I agree. I will research how can I improve this if I have some empty hours. Thank you and sorry for the late response!
Why can’t you just use this https://react-query.tanstack.com/guides/query-functions#using-a-query-object-instead-of-parameters?
I have a feeling that makeQueryHelper should not depend on queryClient. This will make streaming difficult, because now your component actually bundles the whole client instead of getting it through the context. Also, the whole thing with chaining feels dirty and impure. I don’t want to discourage you, I just want to share my thoughts :)
Example https://codesandbox.io/s/without-react-query-helper-ljibc?file=/pages/index.tsx