-
-
Notifications
You must be signed in to change notification settings - Fork 31
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: add support for new version of @heyapi and use fetch client ins… #125
Conversation
@7nohe @seriouslag |
By the way, really great lib :D |
I also noticed that in the main branch the react example the UI doesn't update when you create a new pet, this address this issue as well |
might help address this as well: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the amazing work!
// This is an example of using a hook that has all parameters optional; | ||
// Here we do not have to pass in an object | ||
const { data: _ } = useDefaultServiceFindPets(); | ||
const { data: _ } = useFindPets(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping the use of tag names makes this a breaking change.
I must consider whether dropping the tag to generate the hook is helpful.
I see a benefit in having the tag help describe the hook, especially for large spec files.
I also see the beauty in not having the tag there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you referring the "defaultService"? because wasn't sure what to put there if there's no real concept of a service in the new client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was referring to defaultService. For large spec files it’s a nice to have buckets to put similar api calls. dogService, catService, etc. makes DX better as you can discover api calls related to what you are working with using intelliSense/autocomplete
How are the names of the hooks being generated now? I believe they are generated from the method names of the generated client code from @hey-api. Does @hey-api use operationId or is it generated from the displayName, or something else? How are duplicate names handled.
I can imagine 2 generated hooks having the same or similar name using the clients code now that tags are not used in the names.
That was my stream of consciousness. I haven’t dug into the code yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seriouslag it is using the operationId and AFAIK it should be unique in the spec no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe OperationId to be unique but not a required field in the OpenAPI spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I checked and it is either using the operationId, or build it using the URL, so we can definitely have a conflicts no?
examples/react-app/src/App.tsx
Outdated
@@ -42,8 +42,8 @@ function App() { | |||
<div className="App"> | |||
<h1>Pet List</h1> | |||
<ul> | |||
{Array.isArray(data) && | |||
data?.map((pet, index) => ( | |||
{Array.isArray(data?.data) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data?.data
is ugly right?
Why do we have another object with data inside of it?
This also introduces a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, was planning to dig into this and see what was changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seriouslag fixed. not sure how I like the solution but you can you see it in this commit:
a341432
@seriouslag |
}, | ||
}; | ||
|
||
export const processOutput = async ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work adding linting support.
I don't support putting linting and formatting in this PR.
@7nohe and I discussed dropping support in favor of letting users run the linters/formatters themselves.
If we were to keep the linters/formatters we should use this implementation to lint all the generated files instead of using the built-in implementation in @hey-api so that we don't have to worry if they break compatibility or change something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np, i'll remove
Let's talk about the big elephant in the PR. |
A breaking change is not no-go but this is a huge change as every single consumer has will have to change every hook. I feel we should not do that and offer a codemod or generate the old and new hooks and deprecate the old hooks. Or we could not break every hook and add back the service layer using the tag names. We could generate the services and this would be a non-breaking change. |
yes there are several ways to go around this, I was thinking we can discuss it in discord or something so we can align on a way to tackle this with a plan, I don't mind the extra work. Regardless, i'd much rather contribute to this great lib and not only using a fork, you guys did really nice work here and i'd really want to give back :D |
Thank you for all the work you have put into this! I have been away on vacation and will be for another week. Let’s touch base on discord when I get back. |
…tead of axios