class SourceContext in GraphQL 8.4
Resolves by setting the value as context with the given name.
Hierarchy
- class \Drupal\graphql\GraphQL\Resolver\SourceContext implements ResolverInterface
Expanded class hierarchy of SourceContext
1 file declares its use of SourceContext
- ResolverBuilder.php in src/
GraphQL/ ResolverBuilder.php
File
- src/
GraphQL/ Resolver/ SourceContext.php, line 12
Namespace
Drupal\graphql\GraphQL\ResolverView source
class SourceContext implements ResolverInterface {
/**
* Name of the context.
*
* @var string
*/
protected $name;
/**
* Source resolver.
*
* @var mixed
*/
protected $source;
/**
* SourceContext constructor.
*
* @param string $name
* @param \Drupal\graphql\GraphQL\Resolver\ResolverInterface|null $source
*/
public function __construct($name, ResolverInterface $source = NULL) {
$this->name = $name;
$this->source = $source;
}
/**
* {@inheritdoc}
*/
public function resolve($value, $args, ResolveContext $context, ResolveInfo $info, FieldContext $field) {
$source = $this->source ?? new ParentValue();
$context = $source
->resolve($value, $args, $context, $info, $field);
$field
->setContextValue($this->name, $context);
return $context;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SourceContext:: |
protected | property | Name of the context. | |
SourceContext:: |
protected | property | Source resolver. | |
SourceContext:: |
public | function |
Resolve values for the fields. Overrides ResolverInterface:: |
|
SourceContext:: |
public | function | SourceContext constructor. |