Entity query on custom entity is not checking access rights I have a custom entity called project_member. Not all user have access to this entity. But when I query this entity with entityQuery as follows
\Drupal::entityQuery('project_member')-&gt;execute()
all the entities are returning. It is not checking the access rights. I am missing anything. I tried to implement hook_project_member_access() to restrict the access still entityQuery is not checking those access results.
You will need to implement hook_query_ENTITY_TYPE_access_alter  ( hook_query_project_member_access_alter) to apply the custom query access check.
For example https://api.drupal.org/api/drupal/core%21modules%21node%21node.module/function/node_query_node_access_alter/8.9.x
You might need to $query-&gt;addTag(‘project_member_access’) but from memory that tag may now be added automatically by the entity query handler.