You are here

public function SchemaPluginBase::getType in GraphQL 8.3

Retrieve the type instance for a given type name.

Parameters

string $name: The name of the type to retrieve the type instance for.

Return value

\GraphQL\Type\Definition\Type The type instance corresponding to the given type name.

Overrides SchemaBuilderInterface::getType

3 calls to SchemaPluginBase::getType()
SchemaPluginBase::getSchema in src/Plugin/GraphQL/Schemas/SchemaPluginBase.php
Retrieves the schema.
SchemaPluginBase::getTypes in src/Plugin/GraphQL/Schemas/SchemaPluginBase.php
Retrieves all type instances from the schema.
SchemaPluginBase::processType in src/Plugin/GraphQL/Schemas/SchemaPluginBase.php
Processes a optimized type definition structure.

File

src/Plugin/GraphQL/Schemas/SchemaPluginBase.php, line 408

Class

SchemaPluginBase

Namespace

Drupal\graphql\Plugin\GraphQL\Schemas

Code

public function getType($name) {
  $types = $this->pluginDefinition['type_map'];
  $references = $this->pluginDefinition['type_reference_map'];
  if (isset($types[$name])) {
    return $this
      ->buildType($this->pluginDefinition['type_map'][$name]);
  }
  do {
    if (isset($references[$name])) {
      return $this
        ->buildType($types[$references[$name]]);
    }
  } while (($pos = strpos($name, ':')) !== FALSE && ($name = substr($name, 0, $pos)));
  throw new \LogicException(sprintf('Missing type %s.', $name));
}