EntityQuery does not return values I am trying to get some entities using the "entity.query" service.

What am I doing:

in my module (file "mymodule.module") I execute:

function mymodule_preprocess_page(&amp;$variables) {
  $query = \Drupal::entityQuery('node');
  $query-&gt;condition('type', 'article');
  $nids = $query-&gt;execute();
}


What I get:


when I browse a page under the name of an authorized user - the request returns the results

when I browse the site as a guest, the query does not return any results.




Why am I not getting any results when I browse the site as a guest? Any ideas?
Entity query respects access by default. Add the ->accessCheck(FALSE) method to prevent access checking. Be careful, removing access checks may expose restricted data. It may be better to configure view permissions or whatever access system you're using to allow anonymous users to access content instead of removing the check.