-
-
Notifications
You must be signed in to change notification settings - Fork 533
Integration with tanstack-query #1502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I’m against the core library throwing an error by default, because it’s this library’s design to match the fetch API. Most applications should gracefully handle error codes without a try/catch that introduces unnecessary boilerplate. Requiring an error is a design decision of Tanstack Query that goes against the design of the fetch API. That said, I’m not opposed to a wrapper designed for Tanstack, but maybe there would be other functionality in addition to just simply throwing? |
Update: with openapi-fetch adding middleware, there may be a more automatic way to achieve this: https://github.com/drwpow/openapi-typescript/pull/1521/files#diff-decdbf43769e15babbf0e979dcea2acadd305ca28f41e453db3329ad1f317b80R4 |
Hi @drwpow, I have a question about how this middleware works with type narrowing. I have added the middleware to my codebase like so:
and then used it like so:
The problem is the type the destructured
I get type safety on the However, I'd ideally like to not do this, React Query allows me to separate my concerns using the The only way I can think of solving this is wrapping
Note this doesn't work from a TS perspective. I appreciate I'm really trying to have my cake and eat it here |
Description
Using with react-query or vue-query (this library) you need manually return data or raise error:
Proposal
Make wrapper or another createClient, so it elegantly works with tanstack-query
Checklist
The text was updated successfully, but these errors were encountered: