orval
orval copied to clipboard
Allow `fetch`client's `data` to be set to success type only
Background
In #1885, we defined the type of response's data and status as a combination.
When used with the fetch client, this is a more accurate type definition.
However, when used as an HTTP client such as swr or react-query, it becomes a union type of 200 and 400, and the type cannot be specified. And in those libraries, it is common to use exceptions for cases other than 200 and refer to data only when it is 200.
For example, swr:
https://swr.vercel.app/docs/error-handling
Proposal
There are cases where you want to define only 200 data as before and make only the status a union type, so by making these options selectable, we would like to maintain the format before #1885.
Hi @AllieJonsson what do you think about this?
Seems very reasonable. Is there a need to have this as a setting? Im thinking maybe this should be the behavior when using fetch as httpClient, and keep the behavior introduced in #1885 when using fetch as client?
@AllieJonsson
Although swr and tanstack query are recommended, they are not mandatory. There may be cases where you want to use composite response types while using those libraries, so we want to maintain the option for users.
Hi, is there any movement on this or do you need someone to help contribute it?
Hi, @jeremy-marcus. There is nothing going on. We would be happy to accept your contribute!
I'm looking into this now :)