Skip to content
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: OpenAPI generator for frontend #2715

Closed
Tracked by #2595
Tymek opened this issue Dec 20, 2022 · 4 comments
Closed
Tracked by #2595

feat: OpenAPI generator for frontend #2715

Tymek opened this issue Dec 20, 2022 · 4 comments
Labels

Comments

@Tymek
Copy link
Member

Tymek commented Dec 20, 2022

Inconsistencies that we get by writing API integration by hand:

  • A lot of duplicated code
  • We had bugs where for example HTTP method didn't match
  • It's not clear how to handle errors
  • Cache invalidation on different levels of abstraction

Things to take into consideration

  • Possible errors in parsing data are a big concern
    • If generated code is trying to be smart and parse JSON and Date, this can cause serious bugs.
  • To test: Can we generate types out of OpenAPI anyOf & oneOf?
  • We would like to avoid lock-in with the library that we end up using.
    • We need to be able to compose functionality on top of it, for example with custom fetcher.
    • Something like "middleware" is the pattern we are looking for. Example use is conditionally fetching from an endpoint.
  • Right now to generate types we need to run Enterprise to get OpenAPI, and we generate frontend
    • It's hard to synchronize changes
    • We can crate a separate package for entire schema

Possible solutions

Dependencies that we can use (click to expand)
This was referenced Dec 20, 2022
@simenandre
Copy link
Contributor

Why not try GraphQL?

@Tymek
Copy link
Member Author

Tymek commented Dec 30, 2022

Because it's a huge rewrite with no clear benefits, if it's done for both frontend and backend, or a level of not useful wrapper if we use it only on frontend. You're welcome to state your arguments and/or provide a POC.

@simenandre
Copy link
Contributor

In my personal experience I find that OpenAPI doesn't have that great tools for generating clients, and I think this mainly comes down to people misunderstanding the OpenAPI specification (or not caring enough, maybe).

AFAIK, GraphQL has better tooling at this point, not to mention better documentation. Another option might be to look at tRPC? The benefits for both options are end-to-end type-safe APIs.

I appreciate that it's a large rewrite to change the transport layer, and it might not be worth it for what this issue wants to achieve. However, there are clear benefits with GraphQL, might not make sense right now.

I'll leave you with that 👍 Let me know I can help!

Tymek added a commit that referenced this issue Jan 5, 2023
@ivarconr ivarconr changed the title OpenAPI generator for frontend feat: OpenAPI generator for frontend Jan 19, 2023
@stale
Copy link

stale bot commented Feb 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 18, 2023
@stale stale bot closed this as completed Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

2 participants