protected function TypedDataTypeResolver::resolveRecursiveComplex in GraphQL 8.2
Same name and namespace in other branches
- 8 src/TypeResolver/TypedDataTypeResolver.php \Drupal\graphql\TypeResolver\TypedDataTypeResolver::resolveRecursiveComplex()
Resolves complex data definitions.
Parameters
\Drupal\Core\TypedData\ComplexDataDefinitionInterface $type: The complext data definition to be resolved.
Return value
\Fubhy\GraphQL\Type\Definition\Types\ObjectType|null The object type or NULL if the type does not have any resolvable fields.
1 call to TypedDataTypeResolver::resolveRecursiveComplex()
- TypedDataTypeResolver::resolveRecursive in src/
TypeResolver/ TypedDataTypeResolver.php
File
- src/
TypeResolver/ TypedDataTypeResolver.php, line 112
Class
- TypedDataTypeResolver
- Generically resolves the schema for typed data types.
Namespace
Drupal\graphql\TypeResolverCode
protected function resolveRecursiveComplex(ComplexDataDefinitionInterface $type) {
if (($identifier = $this
->getTypeIdentifier($type)) && array_key_exists($identifier, $this->complexTypes)) {
return $this->complexTypes[$identifier];
}
// Resolve complex data definitions lazily due to recursive definitions.
return function () use ($type, $identifier) {
if (array_key_exists($identifier, $this->complexTypes)) {
return $this->complexTypes[$identifier];
}
$typeFields = $this
->resolveFields($type);
// Clean up the field names and remove any empty fields from the list.
$fieldNames = StringHelper::formatPropertyNameList(array_keys($typeFields));
$typeFields = array_filter(array_combine($fieldNames, $typeFields));
if (empty($typeFields)) {
return $this->complexTypes[$identifier] = new NullType();
}
$typeName = StringHelper::formatTypeName($identifier);
$typeDescription = $type
->getDescription();
$typeDescription = $typeDescription ? "{$type->getLabel()}: {$typeDescription}" : $type
->getLabel();
// Statically cache the resolved type based on its data type.
$this->complexTypes[$identifier] = new ObjectType($typeName, $typeFields, [], NULL, $typeDescription);
return $this->complexTypes[$identifier];
};
}