graphql-resolve-batch icon indicating copy to clipboard operation
graphql-resolve-batch copied to clipboard

Example with a SQL query?

Open shoeman22 opened this issue 7 years ago • 0 comments

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.

shoeman22 avatar Nov 01 '18 20:11 shoeman22