Open
Description
Hi @capaj! Thanks for forking and extending this! I'm trying to implement GraphQL with TypeORM, so far so good, the GraphQL part is working pretty nicely, but I am not sure how I should pass the right request to Typeorm, expecially while loading relationships and relations of relations:
So I have the following Graph:
I have the following resolver:
#Schema
@SchemaRoot()
class Schema {
@Query({ type: Voorraad })
async inventory(artikelnummer: string, @Context { dbConn }: IContext): Promise<Voorraad> {
const result = await dbConn.manager
.getRepository(Voorraad)
.findOne({ where: { artikelnummer }, relations: ['onderdeelsoort'] })
return result
}
}
#Relation definition
@ManyToOne(() => Ondsoort, (ondsoort: Ondsoort) => ondsoort.voorraads, {
onDelete: 'RESTRICT',
onUpdate: 'RESTRICT',
})
@JoinColumn({ name: 'onderdeelsoort_id' })
@Field({ type: () => Ondsoort })
onderdeelsoort: Ondsoort | null
Now I manually have to provide the relation field here, but that is far from ideal.. Can the GrapHQL request be 'automatically converted' to a TypeORM request that automatically selects the right relations and relations of relations?