How to get nodes that do not belong to a particular user role I am getting custom entity nodes using entity queries like below:

  $query= $this-&gt;entity_query-&gt;get('order_entity')
      -&gt;condition('external_id', $data['external_id']);

  $order_nids2 = $query-&gt;execute();


I am trying to put a condition where I can get nodes which do not belong to a particular user role. How can achieve this?
Nodes are only associated with author's nids (not user roles)

Thus you should do a query first to get the userids that match your selected user roles.  Then use that array to filter out nodes with authors that belong to those user ids.