public function SchemaPluginBase::resolveType in GraphQL 8.3
Resolves a given value to a concrete type.
Parameters
string $name: The name of the interface or union type.
mixed $value: The value to resolve the concrete type for.
\Drupal\graphql\GraphQL\Execution\ResolveContext $context: The resolve context object.
\GraphQL\Type\Definition\ResolveInfo $info: The resolve info object.
Return value
\Drupal\graphql\Plugin\GraphQL\Types\TypePluginBase|null The object type that applies to the given value.
Overrides SchemaBuilderInterface::resolveType
File
- src/
Plugin/ GraphQL/ Schemas/ SchemaPluginBase.php, line 386
Class
Namespace
Drupal\graphql\Plugin\GraphQL\SchemasCode
public function resolveType($name, $value, ResolveContext $context, ResolveInfo $info) {
$association = $this->pluginDefinition['type_association_map'];
$types = $this->pluginDefinition['type_map'];
if (!isset($association[$name])) {
return NULL;
}
foreach ($association[$name] as $type) {
// TODO: Try to avoid loading the type for the check. Consider to make it static!
if (isset($types[$type]) && ($instance = $this
->buildType($types[$type]))) {
if ($instance
->isTypeOf($value, $context, $info)) {
return $instance;
}
}
}
return NULL;
}