graphql-resolve-batch
graphql-resolve-batch copied to clipboard
Example with a SQL query?
This looks to be the sort of solution we are looking for, but I'm struggling to think of how to make the resolver work while using a DB as the data source.
Your example walks the array 1 by 1 which would be like firing a query for each user which defeats the point of dataloader.
Best I can think is to chain UNION's together:
(SELECT * FROM child WHERE parent_id = 1 LIMIT 10) UNION ALL (SELECT * FROM child WHERE parent_id = 2 LIMIT 10)...
That's seems like minimal optimization (haven't tested so maybe even union'ing saving on multiple roundtrips is significant).
Any other approaches I'm missing? This feels like something you would commonly want to do -- limit child properties from returning infinite results, but I'm struggling to find a good implementation on it.