You are here

public function Context::resolve in GraphQL 8.4

Resolve values for the fields.

Parameters

mixed $value:

mixed $args:

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

\GraphQL\Type\Definition\ResolveInfo $info:

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

Return value

mixed

Overrides ResolverInterface::resolve

File

src/GraphQL/Resolver/Context.php, line 43

Class

Context
Resolves a context value with default value support.

Namespace

Drupal\graphql\GraphQL\Resolver

Code

public function resolve($value, $args, ResolveContext $context, ResolveInfo $info, FieldContext $field) {
  $output = $field
    ->getContextValue($this->name);
  if (!isset($output) && !$field
    ->hasContextValue($this->name)) {
    $output = $this->default;
  }
  if ($output instanceof CacheableDependencyInterface) {
    $context
      ->addCacheableDependency($output);
  }
  return $output;
}