DEV Community

Discussion on: Build API with GraphQL, Node.js, and Sequelize

Collapse
 
umakantv profile image
Umakant Vashishtha • Edited

Great Article!
I noticed that using post.getAuthor() and post.getComments() we tell graphql to query database for all the posts one by one.
And I know this is only a template, but one wouldn't want to have as many queries to their DB. So I used sequelize' include model operation and then simply just returned post.author and post.comments. Of course this also comes at a cost of joining tables but sql table joins are better than multiple DB calls. Hope this would help someone.
Also, I would create a PR if you want :)