You are here

public function Description::resolve in GraphQL 8.4

Resolves the field description.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $entity_definition_field: The entity field definition.

Return value

string|null The description.

File

src/Plugin/GraphQL/DataProducer/EntityDefinition/Fields/Description.php, line 37

Class

Description
Retrieves the "description" from a given field definition.

Namespace

Drupal\graphql\Plugin\GraphQL\DataProducer\EntityDefinition\Fields

Code

public function resolve(FieldDefinitionInterface $entity_definition_field) : ?string {

  /** @var \Drupal\Component\Render\MarkupInterface|string|null $description */
  $description = $entity_definition_field
    ->getDescription();

  // Convert translation object to string.
  if ($description instanceof MarkupInterface) {
    return (string) $description;
  }
  return $description;
}