Eager Loading not working
Describe the bug
I am trying to use eager loading to cut down on duplicate queries and I have noticed that eager loading doesn't seem to be doing anything with this plugin.
For example, here is one of my lines:
{% set primaryNavigation = craft.navigation.nodes('primaryNavigation').level(1).with(['children.children']).all() %}
While everything is functional, I noticed there is no difference in the amount of queries whether the with function is there or not. Additionally, when die and dumping like this {% dd primaryNavigation[0].children %}, it displays that the type is of verbb\navigation\elements\db\NodeQuery#1. Should this not be an array?
Is anyone else currently having this issue?
Steps to reproduce
- Try and eager load child nodes.
- Notice it doesn't work.
Craft CMS version
4.3.7.1
Plugin version
2.0.16
Multi-site?
Yes
Additional context
No response
My workaround for the time being:
{% set primaryNavigation = craft.navigation.nodes('primaryNavigation').all() %}
{% for navItem in primaryNavigation|filter(x => x.level == 1) %}
{% set childrenNav = primaryNavigation|filter(x => x.level > 1 and x.parent.id == navItem.id) %}
{% endfor %}
And so on.
Having this issue as well. On a local dev site with only 3 nodes and one subnode:
Without eager loading (children called using .all()):

With eager loading as per docs:

Removing the Navigation query entirely, leaving everything else:

Interestingly enough, ripping everything out of the header file except for this one line:
{% set primaryNodes = craft.navigation.nodes('headerNavigation').level(1).with(['children']).all() %}
Still leaves us at 100ms:

That's odd.
@plumduffer updated my local to 4.3.8.2 and it seems to be fixed, likely related to https://github.com/craftcms/cms/issues/12648:

There have been some rough issues with eager loading in Craft itself, so be sure to get updated before proceeding further.
However, the lack of eager-loading nodes is a well-known issue. While the nodes themselves can be eager-loaded, the linked-to elements cannot and is at the moment a Craft limitation.