protected function Context::resolveValues in GraphQL 8.3
Retrieve the list of field values.
Always returns a list of field values. Even for single value fields. Single/multi field handling is responsibility of the base class.
Parameters
mixed $value: The current object value.
array $args: Field arguments.
$context: The resolve context.
\GraphQL\Type\Definition\ResolveInfo $info: The resolve info object.
Return value
\Generator The value generator.
Overrides FieldPluginBase::resolveValues
File
- modules/
graphql_core/ src/ Plugin/ GraphQL/ Fields/ Context/ Context.php, line 82
Class
- Context
- Request arbitrary drupal context objects with GraphQL.
Namespace
Drupal\graphql_core\Plugin\GraphQL\Fields\ContextCode
protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
if (!$value instanceof Url) {
$value = Url::fromRoute('<front>');
}
$resolve = $this->subRequestBuffer
->add($value, function () {
$id = $this
->getPluginDefinition()['context_id'];
$contexts = $this->contextRepository
->getRuntimeContexts([
$id,
]);
return isset($contexts[$id]) ? $contexts[$id]
->getContextValue() : NULL;
});
return function ($value, array $args, ResolveContext $context, ResolveInfo $info) use ($resolve) {
(yield $resolve());
};
}