-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Schema first approach with generated client #3484
Labels
enhancement
New feature or request
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original idea coming from this tweet: https://twitter.com/MikroOrm/status/1568534840370237441
Prerequisities
EntityRepositoryType
symbol)Or maybe we dong need to generate the repositories for the schema first approach? They are empty classes in the end, its only important if provided by user - we should have a way to set a custom repository without providing custom entity implementation/extension.
The generated client PoC
Last step would be that "generated client". I have this simple script I used for the PoC, it generates entities, repositories and a client file which initializes the ORM and exports a map of services:
This would work only when used with the generated entities, important bit here is finding a way how to make this work dynamically with user provided entitites (that would extend the generated ones).
We also need to think about non-ESM projects, without top level await support, and in general the top level await is not suited for switching configurations (dev/prod). A callback would be better here, we can detect the type of project and generate it based on that. A callback might be generally better, we need to think about how this would be actually used.
The important followup is finding a way to allow extension of the generated entities, probably via some ORM configuration, so the generator already knows the link, therefore knows what to discover. Same needs to work for repositories, but the generated ones don't bring any real benefit, so its enough to support user provided ones (might work out of box, user provided entity links user provided repository).
The text was updated successfully, but these errors were encountered: