You are here

protected function TypedDataTypeResolver::resolveFields in GraphQL 8.2

Same name and namespace in other branches
  1. 8 src/TypeResolver/TypedDataTypeResolver.php \Drupal\graphql\TypeResolver\TypedDataTypeResolver::resolveFields()

Helper function to resolve the list of available fields for a type.

Parameters

\Drupal\Core\TypedData\ComplexDataDefinitionInterface $type: The typed data type to resolve the field list for.

Return value

array The list of fields for the given type.

1 call to TypedDataTypeResolver::resolveFields()
TypedDataTypeResolver::resolveRecursiveComplex in src/TypeResolver/TypedDataTypeResolver.php
Resolves complex data definitions.
1 method overrides TypedDataTypeResolver::resolveFields()
ContentEntityTypeResolver::resolveFields in src/TypeResolver/ContentEntityTypeResolver.php
Helper function to resolve the list of available fields for a type.

File

src/TypeResolver/TypedDataTypeResolver.php, line 152

Class

TypedDataTypeResolver
Generically resolves the schema for typed data types.

Namespace

Drupal\graphql\TypeResolver

Code

protected function resolveFields(ComplexDataDefinitionInterface $type) {
  $propertyDefinitions = $type
    ->getPropertyDefinitions();
  $propertyKeys = array_keys($propertyDefinitions);
  $typeFields = array_map(function ($propertyKey) use ($propertyDefinitions) {
    $propertyDefinition = $propertyDefinitions[$propertyKey];
    $resolvedProperty = $this
      ->resolveFieldFromProperty($propertyKey, $propertyDefinition);
    return $resolvedProperty;
  }, $propertyKeys);
  return array_combine($propertyKeys, $typeFields);
}