EntityQuery, query by referenced entity value, I am getting an empty array when I query by the value of a referenced field. 

I have the following:

$result = \Drupal::entityQuery('node')
  -&gt;condition('type', 'custom')
  -&gt;condition('status', 1)
  -&gt;condition('field_category.entity:taxonomy_term.name', 'somevalue', '=')
  // -&gt;condition('field_category.%delta', 'somevalue');
  -&gt;execute();


Using -&gt;condition('field_category.%delta', 'somevalue'); returns way too many results (nids) than expected.

using -&gt;condition('field_category.entity:taxonomy_term', 'somevalue', '='): returns an empty array.

Am I using an incorrect syntax to query by a related field?
As mentioned here it seems like you only need .entity like this:

-&gt;condition('field_category.entity.name', 'somevalue', '=');