Closed Vincz closed 1 year ago
ping @mcg-web
@Vincz @mcg-web this breaks typed Properties where no default value is set. Just encountered this while upgrading to v1.0:
<?php
namespace App\Input;
use Overblog\GraphQLBundle\Annotation as GQL;
#[GQL\Input]
final class MyInput
{
#[GQL\Field]
public ?string $field;
}
Throws Error: Typed property App\\Input\\MyInput::$field must not be accessed before initialization
See also: https://3v4l.org/9KReD
When data for an input doesn't exist (ie. The property is not set in the data), use the default value of the input property or null if is doesn't have one.
When a input object is used in conjunction with the
ArgumentsTransformer
, if the data doesn't contain the property, use the default one from the input object instead of null.For example:
If the submitted
data
doesn't include thefield2
property, the input instance will be left untouched and$field2
will equalsdefault_me
instead ofnull
.