-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
feat(query): generate query return type along with hooks #318
Conversation
Someone is attempting to deploy a commit to a Personal Account owned by @anymaniax on Vercel. @anymaniax first needs to authorize it. |
014a0fb
to
249d988
Compare
c618e48
to
2a8fdcf
Compare
Just to clear up my confusion can you post what it generates NOW and what your proposed patch will generate? Or is what you are saying you are generating these "additional" values? |
Sorry for the confusion, indeed this PR generates new types |
Hello @CPatchane, it's a good idea! There is no breaking change from what I see no? You just add new types? |
Indeed, this is only new types for the queries part only. Btw, I just pushed a new change to use |
I personally love this @CPatchane . Since its add new code its really just adding new features and flexibility for users without breaking backwards compatibility I am all for it! I just started using React Query and I can't believe I did not know about it before but its an absolutely amazing library and this Orval generator makes my life so much easier since I already have OpenAPI generated from my Spring Boot apps! |
It's only done for react-query here but we should do it for all the clients |
2b2de08
to
27aa103
Compare
@anymaniax Is it normal we don't generate hooks for |
Swr doesn't have mutations like react query |
@anymaniax Let me know, it should be good for the other clients :) (swr, angular and axios) |
8e208d8
to
4955201
Compare
c26b7e0
to
31928e6
Compare
bdeb404
to
7fb7d35
Compare
Use it to avoid a breaking change
7fb7d35
to
e9f073a
Compare
Really great job |
Status
READY
Description
When dealing with hooks generated using
react-query
, it's currently difficult to get the actual return types from the queries (not those from the schemas).In a case where we process the data from the API (changing the case for example) using a custom client, we can't directly rely on the schemas types that have been generated, we have to get the response type from the queries generated instead.
This PR exported those new types for each functions in order to use them in components that used data from those, looking like:
Note: We have to use
NonNullable
for some cases when the client can returnundefined
(201 requests) and avoid type with| undefined
. In that case, the final type will benever
.Wdyt?
I guess it could be considered as a breaking change, should we maybe put this behind a config property and make it optional?