Skip to content

Entity reference revisions data producer returns null on empty #1151

@askibinski

Description

@askibinski

The entity_reference_revisions data producer currently returns null if no entites are referenced.

   * @return \GraphQL\Deferred|null
   *   A promise that will return entities or NULL if there aren't any.

My schema currently looks something like this:

type Page implements NodeInterface {
  id: Int!
  title: String!
  content: [ParagraphInterface]
}

Of course, frontend could also handle null but shouldn't we return an empty array here?

if (empty($entities)) {
  $type = $this->entityTypeManager->getDefinition($type);
  /** @var \Drupal\Core\Entity\EntityTypeInterface $type */
  $tags = $type->getListCacheTags();
  $context->addCacheTags($tags);
  return NULL;
}

edit: I realize the schema actually dictates this and we could always create own data producers, just wondering what about sensible defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions