protected function doResolve(FieldInterface $field, AstFieldInterface $ast, $parentValue = null)
{
/** @var AstQuery|AstField $ast */
$arguments = $this->parseArgumentsValues($field, $ast);
$astFields = $ast instanceof AstQuery ? $ast->getFields() : [];
$resolveInfo = $this->createResolveInfo($field, $astFields);
$this->assertClientHasFieldAccess($resolveInfo);
if ($field instanceof Field) {
if ($resolveFunc = $field->getConfig()->getResolveFunction()) {
if ($this->isServiceReference($resolveFunc)) {
$service = substr($resolveFunc[0], 1);
$method = $resolveFunc[1];
if (!$this->executionContext->getContainer()->has($service)) {
throw new ResolveException(sprintf('Resolve service "%s" not found for field "%s"', $service, $field->getName()));
}
$serviceInstance = $this->executionContext->getContainer()->get($service);
if (!method_exists($serviceInstance, $method)) {
throw new ResolveException(sprintf('Resolve method "%s" not found in "%s" service for field "%s"', $method, $service, $field->getName()));
}
return $serviceInstance->{$method}($parentValue, $arguments, $resolveInfo);
}
return $resolveFunc($parentValue, $arguments, $resolveInfo);
} else {
return TypeService::getPropertyValue($parentValue, $field->getName());
}
} else {
//instance of AbstractContainerAwareField
if (in_array('Symfony\\Component\\DependencyInjection\\ContainerAwareInterface', class_implements($field))) {
/** @var $field ContainerAwareInterface */
$field->setContainer($this->executionContext->getContainer()->getSymfonyContainer());
}
return $field->resolve($parentValue, $arguments, $resolveInfo);
}
}