Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example with a SQL query? #10

Open
shoeman22 opened this issue Nov 1, 2018 · 0 comments
Open

Example with a SQL query? #10

shoeman22 opened this issue Nov 1, 2018 · 0 comments

Comments

@shoeman22
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant