You are here

public function ResolverHelperTrait::fromEntityReference in Thunder 6.2.x

Produces an entity_reference field.

Parameters

string $field: Name of the filed.

\Drupal\graphql\GraphQL\Resolver\ResolverInterface|null $entity: Entity to get the field property.

Return value

\Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerProxy The field data producer.

3 calls to ResolverHelperTrait::fromEntityReference()
ThunderMediaSchemaExtension::resolveFields in modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderMediaSchemaExtension.php
Add image media field resolvers.
ThunderPagesSchemaExtension::resolveFields in modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderPagesSchemaExtension.php
Add article field resolvers.
ThunderParagraphsSchemaExtension::resolveFields in modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderParagraphsSchemaExtension.php
Add paragraph field resolvers.

File

modules/thunder_gqls/src/Traits/ResolverHelperTrait.php, line 61

Class

ResolverHelperTrait
Helper functions for field resolvers.

Namespace

Drupal\thunder_gqls\Traits

Code

public function fromEntityReference(string $field, ResolverInterface $entity = NULL) {
  return $this->builder
    ->produce('entity_reference')
    ->map('field', $this->builder
    ->fromValue($field))
    ->map('entity', $entity ?: $this->builder
    ->fromParent());
}