Documentation

Value
in package

Coerces a PHP value given a GraphQL Type.

Returns either a value which is valid for the provided type or a list of encountered coercion errors.

Table of Contents

coerceValue()  : mixed
Given a type and any value, return a runtime value coerced to match the type.
add()  : array<string|int, Error>
atPath()  : array<string|int, mixed|null>
coercionError()  : Error
ofErrors()  : mixed
ofValue()  : array<string|int, mixed|null>
printPath()  : string
Build a string describing the path into the value where the error was found

Methods

coerceValue()

Given a type and any value, return a runtime value coerced to match the type.

public static coerceValue(mixed $value, ScalarType|EnumType|InputObjectType|ListOfType|NonNull $type[, mixed $blameNode = null ][, array<string|int, mixed> $path = null ]) : mixed
Parameters
$value : mixed
$type : ScalarType|EnumType|InputObjectType|ListOfType|NonNull
$blameNode : mixed = null
$path : array<string|int, mixed> = null
Return values
mixed

add()

private static add(array<string|int, Error$errors, Error|array<string|int, Error$moreErrors) : array<string|int, Error>
Parameters
$errors : array<string|int, Error>
$moreErrors : Error|array<string|int, Error>
Return values
array<string|int, Error>

atPath()

private static atPath(mixed|null $prev, mixed|null $key) : array<string|int, mixed|null>
Parameters
$prev : mixed|null
$key : mixed|null
Return values
array<string|int, mixed|null>

coercionError()

private static coercionError(string $message, Node $blameNode[, array<string|int, mixed>|null $path = null ][, string $subMessage = null ][, Exception|Throwable|null $originalError = null ]) : Error
Parameters
$message : string
$blameNode : Node
$path : array<string|int, mixed>|null = null
$subMessage : string = null
$originalError : Exception|Throwable|null = null
Return values
Error

ofErrors()

private static ofErrors(mixed $errors) : mixed
Parameters
$errors : mixed
Return values
mixed

ofValue()

private static ofValue(mixed $value) : array<string|int, mixed|null>
Parameters
$value : mixed
Return values
array<string|int, mixed|null>

printPath()

Build a string describing the path into the value where the error was found

private static printPath([array<string|int, mixed>|null $path = null ]) : string
Parameters
$path : array<string|int, mixed>|null = null
Return values
string

Search results