Include separated
mjamado opened this issue · 5 comments
I'm using dataloader-sequelize
by itself (i.e.: not with graphql-sequelize
).
In some conditions, I have some includes with the separate
flag set, and, apparently, dataloader-sequelize
doesn't know what to do when the data is already cached - it returns an array with a single empty object.
It only happens when it tries to get from the cache, not when it's a single query.
I arrived at the following fast fix, but I'm guessing this is highly naive, and probably this case should be handled differently:
function shimHasMany(target) {
// (...)
// replace this:
// if (options.include || options.transaction || activeClsTransaction()) {
// with this:
if (options.include || options.transaction || options.separate || activeClsTransaction()) {
return original.apply(this, arguments);
}
// (...)
Hey @mjamado, very happy to accept a PR with a fix and a test. Solution looks good to me.
This doesn't feel right - does that mean that separate
includes will never be cached and/or batched? I haven't explored how dataloader-sequelize
works exactly, and I'm probably asking something stupid, but is it supposed to work like this?
I'll make a test and a PR anyway in the next few days.
seperate
does it's own batching internally, as for caching, it might still work i'm not totally sure.
I suppose in general you don't want to use includes at all with dataloader-sequelize
.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.