novacloudcz / graphql-orm

Golang GraphQL API generator using gqlgen and gorm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Dataloader for one to many relation

abinash-mlbd opened this issue · comments

For one to one relation dataloader woking perfectly.
Is there any way to generate dataloader for one to many relation ?
It will be great if dataloader for one to many relation also generated.
An example of one to many relation dataloader
https://medium.com/@gajus/using-dataloader-to-batch-requests-c345f4b23433

Hello @abinash-mlbd , currently there are no plans to create dataloader for toMany relationships. Mainly because we didn't need it yet :-) . Anyway I agree that it would be nice feature, but little refactoring would be required (also notes for myself):

  1. updating fetch query to be able to fetch related IDs (currently we fetch objects in separate query)
  2. reusing entity dataloader and passing these IDs

The biggest "issue" right now is the first point, I'm not sure if it's possible to fetch IDs of related objects in single query using gorm...in plain MySQL I would use something like GROUP_CONCAT to fetch all ID's in single query.