You are here

public function ResolveContext::setContextValue in GraphQL 8.4

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

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

Parameters

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

string $name: The name of the context.

mixed $value: The value of the context.

Return value

$this

File

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

Class

ResolveContext
Context that is provided during resolving the GraphQL tree.

Namespace

Drupal\graphql\GraphQL\Execution

Code

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