Skip to content

skipFetched not working for nested relation #1757

@broom9

Description

@broom9

Hi there,

Thanks for the awesome library. We recently upgraded to v2.1.3 and start using the skipFetched option to replace patterns like if (!person.children) person.$fetchGraph('children'). It works great in most cases but I found an edge case not working.

For codes like below, assuming:

  • animal => person is a many-to-one relationship
  • person => country is many-to-one, too
const animal = await Animal.findById(1);

// This line will fetch as expected
await animal.$fetchGraph('owner');

// This line will throw an error like "unknown relation "country" in an eager expression"
await animal.$fetchGraph('owner.country', { skipFetched: true });

// If I change the line above to `await animal.$fetchGraph('owner.country');`, it works

Please confirm if this is an issue of skipFetched. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions