EntityQuery on nodes related by ERR and paragraphs I have content type Publication which relates to content type Project using paragraphs:

Publication [field_mention] -&gt; Mention (paragraphs) [field_project] -&gt; Project


Now I want to show all referenced Projects on Article templates. Views doesn't show all relations because of the complexity of this relationship. 

I try to do it using EntityQuery with the following code used in a Custom Block Module in the following way:

$nids = \Drupal::entityQuery('node')
    -&gt;condition('status', 1)
    -&gt;condition('type', 'publication')
    -&gt;condition('field_mention.entity.field_project.target_id', \Drupal::routeMatch()-&gt;getRawParameter('node'))
    -&gt;execute();


The result is empty (after a long loading so) and logs don't show any error.

Is field_mention.entity.field_project.target_id the right way to do it or do I miss something?
Newer versions of Drupal (tested with v8.6.2) can also resolve Paragraphs (Entity Reference Revisions) if you explicitly name the target entity type using dot notation:

$nids = \Drupal::entityQuery('node')
    -&gt;condition('status', 1)
    -&gt;condition('type', 'publication')
    -&gt;condition('field_mention.entity:paragraph.field_project.target_id', \Drupal::routeMatch()-&gt;getRawParameter('node'))
    -&gt;execute();


Note the .entity:paragraph. instead of .entity. in the referenced field condition