drupal-graphql / drupal-graphql/graphql
How to expose reverse entity references?
- Dominant language
- PHP
- Stars
- 287
- Forks
- 198
- PR merge metrics
- No merged PRs in 30d
Description
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 doc](https://drupal-graphql.gitbook.io/graphql/v/8.x-4.x/queries/references#adding-resolvers):
```
$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?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.