Only a basic, format-specific, coercion must be done here. Type
correctness or nullability shouldn't be validated here, they will be
validated later. The type information is provided only as a hint.
For example
GraphQL prohibits the coercion from a 't:Float'
to an 't:Int', but
JSON doesn't have integers, so whole
numbers should be coerced to 't:Int` when receiving variables as a
JSON object. The same holds for 't:Enum'. There are formats that
support enumerations,
JSON doesn't, so the type information
is given and
coerceVariableValue can check that an 't:Enum' is
expected and treat the given value appropriately. Even checking
whether this value is a proper member of the corresponding 't:Enum'
type isn't required here, since this can be checked independently.
Another example is an
ID.
GraphQL explicitly allows
to coerce integers and strings to
IDs, so if an
ID
is received as an integer, it can be left as is and will be coerced
later.
If a value cannot be coerced without losing information,
Nothing should be returned, the coercion will fail then and the
query won't be executed.