private function getVariableReferenceArgumentValue(VariableReference $variableReference, AbstractType $argumentType, Request $request)
{
$variable = $variableReference->getVariable();
if ($argumentType->getKind() == TypeMap::KIND_LIST) {
if ($variable->getTypeName() != $argumentType->getNamedType()->getName() || !$variable->isArray()) {
throw new ResolveException(sprintf('Invalid variable "%s" type, allowed type is "%s"', $variable->getName(), $argumentType->getName()), $variable->getLocation());
}
} else {
if ($variable->getTypeName() != $argumentType->getName()) {
throw new ResolveException(sprintf('Invalid variable "%s" type, allowed type is "%s"', $variable->getName(), $argumentType->getName()), $variable->getLocation());
}
}
$requestValue = $request->getVariable($variable->getName());
if (!$request->hasVariable($variable->getName()) || null === $requestValue && $variable->isNullable()) {
throw new ResolveException(sprintf('Variable "%s" does not exist in request', $variable->getName()), $variable->getLocation());
}
return $requestValue;
}