mickhansen/dataloader-sequelize

Support build

mschipperheyn opened this issue · 2 comments

I use dataloader for association loading. The cache part I built myself using redis. My problem is this. dataloader doesn't support build right now. IMHO it should.

resolver

	types: {
		Account: {
			roles: parent => {
				return parent.getRoles ? parent.getRoles() : parent.roles;
			},
		},

When I get a datastructure back from the cache I build it using

Account.fromCache = (data, opts) =>
    Account.build(data, {
        ...opts,
        isNewRecord: false,
    });

I pass the dataloader as part of the opts (but it doesn't work of course).

As a result, I get empty associations. Could this be considered to be included?

You'd have to use build so that it creates the associated instances internally, i.e. mimic how sequelize does it internally.

stale commented

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.