-
Notifications
You must be signed in to change notification settings - Fork 38
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: make Single Table Inheritance usable #371
Comments
Oh, I just read in typeorm docs it's an experimental feature yet. Maybe it's not as good idea as I thought. |
Hey, thanks for the code sample. Do you want to put it in as a PR in the examples folder? Then it’s not “officially supported” but folks have the pattern handy. |
Hey @diegonc . I'd still be interested in getting this represented in the examples folder if you're interested in adding it. |
Hi, where should I put it? Do I just pick the next number and create a new folder? |
Yeah, that works. I typically just copy the last folder, re-number the DB name, etc... and gut the model, service and resolver of what's not needed. |
Sorry I cannot seem to make it work like it did at that time. Even my original project looks broken now. I cannot make Person and Group implement Party at the graphql schema. Extending from Party doesn't add the implements clause and adding {api: {implements: Party}} to group or person gives an error (I suspect due to the circular dependencies):
|
Can you shoot me a link to your branch? |
This is what I have so far: https://github.com/diegonc/warthog/tree/t/single-table-inheritance |
Note to self to see diff: main...diegonc:t/single-table-inheritance |
TypeORM has a mode in which entities in a tree may share the same table as it's ancestor.
It goes something like in the following snippets:
Class party can already be implemented by just using the TableInheritance decorator from TypeORM along with Model from warthog.
Child classes however cannot be added as warthog's Model decorator uses Entity. So, I came up with a custom decorator sitting in my code tree which I called ChildModel and is shown below.
Maybe it's a good idea to add the decorator to warthog's source tree :-)
The text was updated successfully, but these errors were encountered: