protected static function getVariableValue(Schema $schema, VariableDefinition $definition, $input)
    {
        $type = TypeInfo::typeFromAST($schema, $definition->get('type'));
        if (!$type) {
            return NULL;
        }

        if (self::isValidValue($type, $input)) {
            if (!isset($input)) {
                $default = $definition->get('defaultValue');

                if ($default) {
                    return self::coerceValueAST($type, $default);
                }
            }

            return self::coerceValue($type, $input);
        }

        // @todo Fix exception message once printer is ported.
        throw new \Exception(sprintf('Variable $%s expected value of different type.', $definition->get('variable')->get('name')->get('value')));
    }