public function Condition::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/ Condition.php, line 38
Class
- Condition
- Conditional resolver.
Namespace
Drupal\graphql\GraphQL\ResolverCode
public function resolve($value, $args, ResolveContext $context, ResolveInfo $info, FieldContext $field) {
$branches = $this->branches;
while (list($condition, $resolver) = array_pad(array_shift($branches), 2, NULL)) {
if ($condition instanceof ResolverInterface) {
if (($condition = $condition
->resolve($value, $args, $context, $info, $field)) === NULL) {
// Bail out early if a resolver returns NULL.
continue;
}
}
if ($condition instanceof SyncPromise) {
return DeferredUtility::returnFinally($condition, function ($cond) use ($branches, $resolver, $value, $args, $context, $info, $field) {
array_unshift($branches, [
$cond,
$resolver,
]);
return (new Condition($branches))
->resolve($value, $args, $context, $info, $field);
});
}
if ((bool) $condition) {
/** @var \Drupal\graphql\GraphQL\Resolver\ResolverInterface|null $resolver */
return $resolver ? $resolver
->resolve($value, $args, $context, $info, $field) : $condition;
}
}
// Functional languages throw exceptions here. Should we just return NULL?
return NULL;
}