Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

withGraphFetched doesn't result runAfter modification #2647

Open
KcZLog opened this issue Apr 30, 2024 · 0 comments
Open

withGraphFetched doesn't result runAfter modification #2647

KcZLog opened this issue Apr 30, 2024 · 0 comments

Comments

@KcZLog
Copy link

KcZLog commented Apr 30, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant