-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Eager Loading not working #341
Comments
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:
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 craftcms/cms#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. |
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:
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 ofverbb\navigation\elements\db\NodeQuery#1
. Should this not be an array?Is anyone else currently having this issue?
Steps to reproduce
Craft CMS version
4.3.7.1
Plugin version
2.0.16
Multi-site?
Yes
Additional context
No response
The text was updated successfully, but these errors were encountered: