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:

enter image description here

We can add a field resolver to get all books from an author, like explained in the documentation:

$registry->addFieldResolver('Author', 'books',
      ->map('entity', $builder->fromParent())
      ->map('field', $builder->fromValue('field_books'))

But how can we get all authors from a book?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.