public static function convert($value, TypeInterface $type): ?ValueNodeInterface
    {
        if ($type instanceof NonNullType) {
            $node = self::convert($value, $type->getOfType());

            return null !== $node && $node->getKind() === NodeKindEnum::NULL ? null : $node;
        }

        if (null === $value) {
            return new NullValueNode(null);
        }

        // Convert PHP array to GraphQL list. If the GraphQLType is a list, but
        // the value is not an array, convert the value using the list's item type.
        if ($type instanceof ListType) {
            return self::convertListType($value, $type);
        }

        // Populate the fields of the input object by creating ASTs from each value
        // in the PHP object according to the fields in the input type.
        if ($type instanceof InputObjectType) {
            return self::convertInputObjectType($value, $type);
        }

        if ($type instanceof ScalarType || $type instanceof EnumType) {
            return self::convertScalarOrEnum($value, $type);
        }

        throw new ConversionException(\sprintf('Unknown type: %s.', (string)$type));
    }
public static function convert($value, TypeInterface $type): ?ValueNodeInterface
    {
        if ($type instanceof NonNullType) {
            $node = self::convert($value, $type->getOfType());

            return null !== $node && $node->getKind() === NodeKindEnum::NULL ? null : $node;
        }

        if (null === $value) {
            return new NullValueNode(null);
        }

        // Convert PHP array to GraphQL list. If the GraphQLType is a list, but
        // the value is not an array, convert the value using the list's item type.
        if ($type instanceof ListType) {
            return self::convertListType($value, $type);
        }

        // Populate the fields of the input object by creating ASTs from each value
        // in the PHP object according to the fields in the input type.
        if ($type instanceof InputObjectType) {
            return self::convertInputObjectType($value, $type);
        }

        if ($type instanceof ScalarType || $type instanceof EnumType) {
            return self::convertScalarOrEnum($value, $type);
        }

        throw new ConversionException(\sprintf('Unknown type: %s.', (string)$type));
    }
public static function convert ( $ value , TypeInterface $ type ) : ? ValueNodeInterface { if ( $ type instanceof NonNullType ) { $ node = self :: convert ( $ value , $ type -> getOfType ( ) ) ; return null !== $ node && $ node -> getKind ( ) === NodeKindEnum :: NULL ? null : $ node ; } if ( null === $ value ) { return new NullValueNode ( null ) ; } // Convert PHP array to GraphQL list. If the GraphQLType is a list, but // the value is not an array, convert the value using the list's item type. if ( $ type instanceof ListType ) { return self :: convertListType ( $ value , $ type ) ; } // Populate the fields of the input object by creating ASTs from each value // in the PHP object according to the fields in the input type. if ( $ type instanceof InputObjectType ) { return self :: convertInputObjectType ( $ value , $ type ) ; } if ( $ type instanceof ScalarType || $ type instanceof EnumType ) { return self :: convertScalarOrEnum ( $ value , $ type ) ; } throw new ConversionException ( \ sprintf ( 'Unknown type: %s.' , ( string ) $ type ) ) ; }
Produces a GraphQL Value AST given a PHP value.

A GraphQL type must be provided, which will be used to interpret different
PHP values.

| JSON Value    | GraphQL Value        |
| ------------- | -------------------- |
| Object        | Input Object         |
| Array         | List                 |
| Boolean       | Boolean              |
| String        | String / Enum Value  |
| Number        | Int / Float          |
| Mixed         | Enum Value           |
| null          | NullValue            |

@param mixed         $value
@param TypeInterface $type
@return ValueNodeInterface|null
@throws InvariantException
@throws SyntaxErrorException
@throws ConversionException
Produces a GraphQL Value AST given a PHP value .