`withGraphFetched` doesn't result `runAfter` modification
KcZLog opened this issue · comments
KcZLog commented
Using withGraphFetch
with child modifier, which has runAfter
doesn't return modified child object from runAfter.
Using same modifier directly in child model works as expected.
Reproduce using reproduction-template.js:
await Person.query().insertGraph({
firstName: 'Jennifer',
lastName: 'Lawrence',
pets: [
{
name: 'Doggo',
species: 'dog',
},
],
});
const modifiers = {
onlyNames(builder) {
// return values only
builder.select('name').runAfter(
(pets) => pets.map((p) => p.name)
);
},
};
const jennifer = await Person.query()
.findOne({ firstName: 'Jennifer' })
.modifiers(modifiers)
.withGraphFetched('pets(onlyNames)');
const petNames = await Animal.query()
.modifiers(modifiers)
.modify('onlyNames');
const expectPets = ['Doggo'];
chai.expect(petNames).to.have.members(expectPets); // success
chai.expect(jennifer.pets).to.have.members(expectPets); // fails