Skip to content

Example with a SQL query? #10

@shoeman22

Description

@shoeman22

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions