public function DefaultValue::resolve in GraphQL 8.4
Same name in this branch
- 8.4 src/GraphQL/Resolver/DefaultValue.php \Drupal\graphql\GraphQL\Resolver\DefaultValue::resolve()
- 8.4 src/Plugin/GraphQL/DataProducer/EntityDefinition/Fields/DefaultValue.php \Drupal\graphql\Plugin\GraphQL\DataProducer\EntityDefinition\Fields\DefaultValue::resolve()
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/ DefaultValue.php, line 48
Class
- DefaultValue
- Default value resolver.
Namespace
Drupal\graphql\GraphQL\ResolverCode
public function resolve($value, $args, ResolveContext $context, ResolveInfo $info, FieldContext $field) {
$result = $this->value
->resolve($value, $args, $context, $info, $field);
if ($result === NULL) {
return $this->default
->resolve($value, $args, $context, $info, $field);
}
if ($result instanceof SyncPromise) {
return DeferredUtility::returnFinally($result, function ($current) use ($value, $args, $context, $info, $field) {
if ($current === NULL) {
return $this->default
->resolve($value, $args, $context, $info, $field);
}
return $current;
});
}
return $result;
}