You are here

public function ResolveContext::setContext in GraphQL 8.3

Sets a contextual value for the current field and its decendents.

Allows field resolvers to set contextual values which can be inherited by their descendents.

Parameters

string $name: The name of the context.

$value: The value of the context.

\GraphQL\Type\Definition\ResolveInfo $info: The resolve info object.

Return value

$this

File

src/GraphQL/Execution/ResolveContext.php, line 96

Class

ResolveContext

Namespace

Drupal\graphql\GraphQL\Execution

Code

public function setContext($name, $value, ResolveInfo $info) {
  $operation = isset($info->operation->name->value) ? $info->operation->name->value : $info->operation->operation;
  $key = implode('.', $info->path);
  $this->contexts[$operation][$key][$name] = $value;
  return $this;
}