Since Drupal 8 doesn't support bidirectional relationship, we need to query manually the reverse entity.
Let's say we have 2 entities with a many to many relationship:
We can add a field resolver to get all books from an author, like explained in the documentation:
$registry->addFieldResolver('Author', 'books', $builder->compose( $builder->produce('entity_reference') ->map('entity', $builder->fromParent()) ->map('field', $builder->fromValue('field_books')) ) );
But how can we get all authors from a book?