You are here

class FieldItemTypeResolver in GraphQL 8.2

Same name and namespace in other branches
  1. 8 src/TypeResolver/FieldItemTypeResolver.php \Drupal\graphql\TypeResolver\FieldItemTypeResolver

Resolves the schema for field definitions.

Note: This resolver is only relevant for complex fields which can not be simplified via the content entity schema resolver.

Hierarchy

Expanded class hierarchy of FieldItemTypeResolver

1 string reference to 'FieldItemTypeResolver'
graphql.services.yml in ./graphql.services.yml
graphql.services.yml
1 service uses FieldItemTypeResolver
graphql.type_resolver.typed_data.field_item in ./graphql.services.yml
Drupal\graphql\TypeResolver\FieldItemTypeResolver

File

src/TypeResolver/FieldItemTypeResolver.php, line 18

Namespace

Drupal\graphql\TypeResolver
View source
class FieldItemTypeResolver extends TypedDataTypeResolver {

  /**
   * The typed data manager service.
   *
   * @var \Drupal\Core\TypedData\TypedDataManager
   */
  protected $typedDataManager;

  /**
   * The entity manager service.
   *
   * @var \Drupal\Core\Entity\EntityManagerInterface
   */
  protected $entityManager;

  /**
   * Constructs a FieldItemTypeResolver object.
   *
   * @param TypeResolverInterface $typeResolver
   *   The base type resolver service.
   * @param \Drupal\Core\Entity\EntityManagerInterface $entityManager
   *   The entity manager service.
   */
  public function __construct(TypeResolverInterface $typeResolver, EntityManagerInterface $entityManager) {
    parent::__construct($typeResolver);
    $this->entityManager = $entityManager;
  }

  /**
   * {@inheritdoc}
   */
  public function applies($type) {
    return $type instanceof FieldItemDataDefinition;
  }

  /**
   * {@inheritdoc}
   */
  protected function getTypeIdentifier(DataDefinitionInterface $type) {

    /** @var FieldItemDataDefinition $type */
    $fieldDefinition = $type
      ->getFieldDefinition();
    $fieldName = $fieldDefinition
      ->getName();
    $entityTypeId = $fieldDefinition
      ->getTargetEntityTypeId();

    // Create a more specifc data type identifier because the one returned via
    // typed data is too vague and does not contain information about the owning
    // entity type.
    return "field:item:{$entityTypeId}:{$fieldName}";
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FieldItemTypeResolver::$entityManager protected property The entity manager service.
FieldItemTypeResolver::$typedDataManager protected property The typed data manager service.
FieldItemTypeResolver::applies public function Overrides TypedDataTypeResolver::applies
FieldItemTypeResolver::getTypeIdentifier protected function Retrieves the unique type identifier for a specific data type. Overrides TypedDataTypeResolver::getTypeIdentifier
FieldItemTypeResolver::__construct public function Constructs a FieldItemTypeResolver object. Overrides TypedDataTypeResolver::__construct
TypedDataTypeResolver::$complexTypes protected property Static cache of resolved complex data types.
TypedDataTypeResolver::$primitiveMap protected property Maps data types to primitive types.
TypedDataTypeResolver::$typeResolver protected property The type resolver service.
TypedDataTypeResolver::getPrimitiveType protected function
TypedDataTypeResolver::getPropertyComplexValue public static function Property value resolver callback for complex properties
TypedDataTypeResolver::getPropertyListValue public static function Property value resolver callback for list properties.
TypedDataTypeResolver::getPropertyPrimitiveValue public static function Property value resolver callback for primitive properties.
TypedDataTypeResolver::getPropertyReferenceValue public static function Property value resolver callback for reference properties.
TypedDataTypeResolver::getPropertyResolverFunction protected function Helper function to find the proper resolver function for a given property.
TypedDataTypeResolver::resolveFieldFromProperty protected function Helper function to resolve a field definition from a typed data property. 1
TypedDataTypeResolver::resolveFields protected function Helper function to resolve the list of available fields for a type. 1
TypedDataTypeResolver::resolveRecursive public function Overrides TypeResolverInterface::resolveRecursive 1
TypedDataTypeResolver::resolveRecursiveComplex protected function Resolves complex data definitions.
TypedDataTypeResolver::resolveRecursiveList protected function Resolves list data definitions.
TypedDataTypeResolver::resolveRecursivePrimitive protected function Resolves primitive data definitions.
TypedDataTypeResolver::resolveRecursiveReference protected function Resolves data reference definitions.