src/Executor/Values.php
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')));
    }
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')));
    }
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' ) ) ) ; }
Given a variable definition, and any value of input, return a value which
adheres to the variable definition, or throw an error.

@param Schema $schema
@param VariableDefinition $definition
@param $input

@return array|mixed|null|string

@throws \Exception
Given a variable definition and any value of input return a value which adheres to the variable definition or throw an error .