You are here

public function ResolverRegistry::resolveField in GraphQL 8.4

Resolve a field.

Parameters

mixed $value:

mixed $args:

\Drupal\graphql\GraphQL\Execution\ResolveContext $context:

\GraphQL\Type\Definition\ResolveInfo $info:

\Drupal\graphql\GraphQL\Execution\FieldContext $field:

Return value

callable|null

Overrides ResolverRegistryInterface::resolveField

File

src/GraphQL/ResolverRegistry.php, line 74

Class

ResolverRegistry
Contains all the mappings how to resolve a GraphQL request.

Namespace

Drupal\graphql\GraphQL

Code

public function resolveField($value, $args, ResolveContext $context, ResolveInfo $info, FieldContext $field) {

  // First, check if there is a resolver registered for this field.
  if ($resolver = $this
    ->getRuntimeFieldResolver($value, $args, $context, $info)) {
    if (!$resolver instanceof ResolverInterface) {
      throw new \LogicException(sprintf('Field resolver for field %s on type %s is not callable.', $info->fieldName, $info->parentType->name));
    }
    return $resolver
      ->resolve($value, $args, $context, $info, $field);
  }
  return call_user_func($this->defaultFieldResolver, $value, $args, $context, $info, $field);
}