orval
orval copied to clipboard
feat: add new client `fetch`
Status
READY
Description
Fix #1387
I added a new fetchclient.
Becouse, since the fetch API is mature, it has the advantage of reducing the bundle size of the application compared to using Axios, and I feel that this is sufficient in some cases.
Furthermore, we think it can be used to select an HTTP client with tanstack query or swr, or when calling an API from a server-side framework.
In this PR, i implemented a client using the minimal fetch API. For example, customization by specifying mutator is not yet supported. However, I still think it is practical enough and would like to submmit it on first. I'll also submit a sample application in a subsequent PR.
Ref: https://developer.mozilla.org/en-US/docs/Web/API/fetch
Related PRs
none
Todos
- [x] Tests
- [x] Documentation
- [x] Changelog Entry (unreleased)
Steps to Test or Reproduce
I added a test case, so it should pass.
the params are passed to the body. Is it intended?
thanks. I'll check later 👍
Also code conflict might want to merge update.
@soartec-lab it's what I use in my project if you need https://gist.github.com/anymaniax/44c1331a5643081a82da070e45f405f0
@anymaniax wonderful. Thank you for sharing 🙌 I will use this as a reference when adding a custom instance in a future PR.
the params are passed to the body. Is it intended?
This is by design. Referring to this, I interpret that the request parameters are to be specified in the body.
https://developer.mozilla.org/en-US/docs/Web/API/fetch
@soartec-lab If you pass the query params into the body it wont be a query params anymore or I am missing something?
@anymaniax I see, the sample you shared with me adds query parameters to the URL. I will refer to it and consider it again.
Hi, @anymaniax
I took your advice into consideration and changed the URL used by fetch to be obtained from a get URL function. This function combines path parameters and query parameters. And they only use the request body for body parameters.
Cloud you review again ?
@anymaniax Thank you for the review. I have fixed all responses and commented.
I wanna add the fetch client incrementally and improve it little by little. First of all, I'm adding a minimal working package, so additional behaviors can be added in subsequent PRs. Detailed plans are also managed in this issue.
https://github.com/anymaniax/orval/issues/1387
@melloware
Even if i merge this, I don't wanna close #1387, so I deleted fix #1387 in description, is there any problem?
No problem! We can always reopen if it accidentally closes. I always prefer to have PR linked to ticket so we can reference later.
Thanks !