You are here

protected function Server::getFieldResolver in GraphQL 8.4

Returns the default field resolver.

@todo Handle this through configuration on the server.

Fields that don't explicitly declare a field resolver will use this one as a fallback.

Parameters

\Drupal\graphql\GraphQL\ResolverRegistryInterface $registry: The resolver registry.

Return value

null|callable The default field resolver.

1 call to Server::getFieldResolver()
Server::configuration in src/Entity/Server.php

File

src/Entity/Server.php, line 323

Class

Server
The main GraphQL configuration and request entry point.

Namespace

Drupal\graphql\Entity

Code

protected function getFieldResolver(ResolverRegistryInterface $registry) {
  return function ($value, $args, ResolveContext $context, ResolveInfo $info) use ($registry) {
    $field = new FieldContext($context, $info);
    $result = $registry
      ->resolveField($value, $args, $context, $info, $field);
    return DeferredUtility::applyFinally($result, function ($result) use ($field, $context) {
      if ($result instanceof CacheableDependencyInterface) {
        $field
          ->addCacheableDependency($result);
      }
      $context
        ->addCacheableDependency($field);
    });
  };
}