Problem/Motivation
Thank you very much for this module! It's great that it allows you to retrieve all the reverse-references from a single point in an object graph. However, the real power would be if we could leverage this functionality as part of an Entity Query.
For example, to get all of the tag terms referenced by a specific news item (5):
$term_ids =
\Drupal::entityQuery('taxonomy_term')
->condition('vid', 'tags')
->condition('reverse_entity_reference.entity:node.type', 'news_item')
->condition('reverse_entity_reference.entity:node.nid', 5)
->accessCheck(FALSE)
->execute();
Right now, this type of query yields an error like this:
Error: Call to a member function getColumns() on bool in Drupal\Core\Entity\Query\Sql\Tables->addField() (line 253 of core/lib/Drupal/Core/Entity/Query/Sql/Tables.php).
Drupal\Core\Entity\Query\Sql\Tables->addField('reverse_entity_reference.entity:node.type', 'INNER', NULL) (Line: 52)
Drupal\Core\Entity\Query\Sql\Condition->compile(Object) (Line: 172)
Drupal\Core\Entity\Query\Sql\Query->compile() (Line: 80)
Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 37)
Even just trying to do a condition on 'reverse_entity_reference' yields:
\Drupal\Core\Entity\Query\QueryException: 'reverse_entity_reference' not found
Steps to reproduce
Noted under problem.
Comments
Comment #2
GeraldNDA commentedUh, the reason this isn't a thing right now is because this is a computed field. I think if you wanted to create a query for this, then you should write the respective query. I'll take a closer look to see if this is possible with a computed field, but more likely this is out of scope for this module.