Note: this is my first Drupal project as I am usually working with Laravel.
I have some entities my-nodes
that have a field EntityReferenceFieldItemList (a multi-select linking to other entities of another content type related-nodes
).
I want to query the my-nodes
entities together with the related entities in 1 query (in Laravel I would describe this as eager loading the relationship).
The my-nodes
entities all reference different related-nodes
entities and I need to access related-nodes
related values.
I'd like to optimize the amount of calls to the database to possibly only 1.
Method referencedEntities
does not look like what I need because it's lazy loading, not eager loading:
$node->get($field)->referencedEntities();
Any idea? Thanks in advance!