Last active
April 5, 2023 21:11
-
-
Save srmagura/1d2ad4c6a57b2f7fc612e180bf725afd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OrgMembership.ts | |
@ManyToOne(() => User, { ref: true, onDelete: 'cascade' }) | |
user: Ref<User>; | |
// User.ts | |
@OneToMany(() => OrgMembership, 'user') // 'user' is actually type-safe. You can't just enter any string | |
orgMemberships = new Collection<OrgMembership>(this); | |
// Notice there is no @Field() on either end of the relationship. If you try | |
// this, the GraphQL response will contain an object with the correct ID, but no | |
// other fields. | |
// | |
// So we will use @ResolveField() to load related entities for GraphQL API | |
// calls. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment