PHP Class GraphQL\Utils\AST

Show file Open project: webonyx/graphql-php Class Usage Examples

Public Methods

Method Description
astFromValue ( $value, GraphQL\Type\Definition\InputType $type ) : ObjectValueNode | ListValueNode | BooleanValueNode | IntValueNode | FloatValueNode | EnumValueNode | StringValueNode | NullValueNode Produces a GraphQL Value AST given a PHP value.
valueFromAST ( $valueNode, GraphQL\Type\Definition\InputType $type, null $variables = null ) : array | null | stdClass Produces a PHP value given a GraphQL Value AST.

Private Methods

Method Description
isMissingVariable ( $valueNode, $variables ) : boolean Returns true if the provided valueNode is a variable which is not defined in the set of variables.

Method Details

astFromValue() static public method

Optionally, a GraphQL type may be provided, which will be used to disambiguate between value primitives. | PHP Value | GraphQL Value | | ------------- | -------------------- | | Object | Input Object | | Assoc Array | Input Object | | Array | List | | Boolean | Boolean | | String | String / Enum Value | | Int | Int | | Float | Int / Float | | Mixed | Enum Value | | null | NullValue |
static public astFromValue ( $value, GraphQL\Type\Definition\InputType $type ) : ObjectValueNode | ListValueNode | BooleanValueNode | IntValueNode | FloatValueNode | EnumValueNode | StringValueNode | NullValueNode
$value
$type GraphQL\Type\Definition\InputType
return GraphQL\Language\AST\ObjectValueNode | GraphQL\Language\AST\ListValueNode | GraphQL\Language\AST\BooleanValueNode | GraphQL\Language\AST\IntValueNode | GraphQL\Language\AST\FloatValueNode | GraphQL\Language\AST\EnumValueNode | GraphQL\Language\AST\StringValueNode | GraphQL\Language\AST\NullValueNode

valueFromAST() public static method

A GraphQL type must be provided, which will be used to interpret different GraphQL Value literals. Returns null when the value could not be validly coerced according to the provided type. | GraphQL Value | PHP Value | | -------------------- | ------------- | | Input Object | Assoc Array | | List | Array | | Boolean | Boolean | | String | String | | Int / Float | Int / Float | | Enum Value | Mixed | | Null Value | stdClass | instance of NullValue::getNullValue()
public static valueFromAST ( $valueNode, GraphQL\Type\Definition\InputType $type, null $variables = null ) : array | null | stdClass
$valueNode
$type GraphQL\Type\Definition\InputType
$variables null
return array | null | stdClass