narkoleptika / apollo-api-boilerplate Goto Github PK
View Code? Open in Web Editor NEWBoilerplate for an Apollo GraphQL API server with Sequelize and Express.
License: MIT License
Boilerplate for an Apollo GraphQL API server with Sequelize and Express.
License: MIT License
I'm trying to get a better understanding of using Dataloader, particularly with Sequelize relationships. Your boilerplate looks very close to solving the problem I'm having, but I'm not sure it is batching results as it should be. Perhaps it is my lack of understanding of how dataloader should work.
For example, given the following query:
{
getPosts {
title
content
comments {
content
}
}
}
I expect dataloader to batch the comments query with an IN statement so there is only one query for comments. What actually happens is the following:
Executing (default): SELECT `id`, `title`, `content`, `createdAt`, `updatedAt` FROM `posts` AS `post` ORDER BY `post`.`createdAt` DESC;
Executing (default): SELECT `id`, `content`, `createdAt`, `updatedAt`, `postId` FROM `comments` AS `comment` WHERE `comment`.`postId` = 1;
Executing (default): SELECT `id`, `content`, `createdAt`, `updatedAt`, `postId` FROM `comments` AS `comment` WHERE `comment`.`postId` = 2;
Executing (default): SELECT `id`, `content`, `createdAt`, `updatedAt`, `postId` FROM `comments` AS `comment` WHERE `comment`.`postId` = 3;
Executing (default): SELECT `id`, `content`, `createdAt`, `updatedAt`, `postId` FROM `comments` AS `comment` WHERE `comment`.`postId` = 4;
Executing (default): SELECT `id`, `content`, `createdAt`, `updatedAt`, `postId` FROM `comments` AS `comment` WHERE `comment`.`postId` = 5;
Executing (default): SELECT `id`, `content`, `createdAt`, `updatedAt`, `postId` FROM `comments` AS `comment` WHERE `comment`.`postId` = 6;
Executing (default): SELECT `id`, `content`, `createdAt`, `updatedAt`, `postId` FROM `comments` AS `comment` WHERE `comment`.`postId` = 7;
Executing (default): SELECT `id`, `content`, `createdAt`, `updatedAt`, `postId` FROM `comments` AS `comment` WHERE `comment`.`postId` = 8;
Executing (default): SELECT `id`, `content`, `createdAt`, `updatedAt`, `postId` FROM `comments` AS `comment` WHERE `comment`.`postId` = 9;
Executing (default): SELECT `id`, `content`, `createdAt`, `updatedAt`, `postId` FROM `comments` AS `comment` WHERE `comment`.`postId` = 10;
Shouldn't this be something like this?
WHERE comment
.postId
IN (1,2,3,4,5,6,7,8,9,10);
I though that was the whole point of batching with dataloader.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.