title: Best way to handle one-to-many with type-graphql typeorm and dataloader
body: <p>I'm trying to figure out the best way to handle a one-to-many relationship using type-graphql and typeorm with a postgresql db (using apollo server with express). I have a user table which has a one-to-many relation with a courses table. The way I am currently handling this is to use the @RelationId field to create a column of userCourseIds and then using @FieldResolver with dataloader to batch fetch the courses that belong to that user(s). My issue is that with the @RelationId field, a separate query is made to get the relationids whether or not I actually query for userCourses. Is there a way to handle this where it won't make that extra query or is there a better way to go about handling one-to-many relationships?</p>
  <p>User side of relation:</p>
  <pre><code>@OneToMany(() =&gt; Course, (course) =&gt; course.creator, { cascade: true })
  userCourses: Course[];
  @RelationId((user: User) =&gt; user.userCourses)
  userCourseIds: string;
  </code></pre>
  <p>Course side of relation:</p>
  <pre><code>@Field()
  @Column()
  creatorId: string;
  
  @ManyToOne(() =&gt; User, (user) =&gt; user.userCourses)
  creator: User;
  </code></pre>
  <p>userCourses FieldResolver:</p>
  <pre><code>@FieldResolver(() =&gt; [Course], { nullable: true })
  async userCourses(@Root() user: User, @Ctx() { courseLoader }: MyContext) {
    const userCourses = await courseLoader.loadMany(user.userCourseIds);
    return userCourses;
  }
  </code></pre>