benawad / fullstack-graphql-airbnb-clone

A Fullstack GraphQL Airbnb Clone with React and React Native
MIT License
1.68k stars 445 forks source link

How many dataloaders do we need ? #27

Open gotexis opened 5 years ago

gotexis commented 5 years ago

Hey, do you create 1 loader for each type of entity and that's enough? no need for separate loaders for subqueries? So if you query

{Article (where: {id: 1})
    {
        Comments  { id }  
    }
}

, if you have a CommentLoader that will load as only 2 SQL calls?

Or do we need a CommentByArticleLoader to only be used with this query?

benawad commented 5 years ago

You'll sometimes need to create separate loaders for subqueries

in this case I would do CommentByArticleLoader