overblog / GraphQLBundle

This bundle provides tools to build a complete GraphQL API server in your Symfony App.
MIT License
788 stars 222 forks source link

Default field value for Input Object #1171

Closed Vincz closed 7 months ago

Vincz commented 8 months ago
Q A
Bug report? yes
Version/Branch 1.1.0

The changes introduce in this PR https://github.com/overblog/GraphQLBundle/pull/1143, breaks the usage of default value in PHP for Input fields. @deeky666

#[GQL\Input]
class TestInput {
    #[GQL\Field(type: "String")]
    public string myField = "default_value"; // <-- This doesn't work anymore
}

Either the MetadataParser should check this when generating the type and add a defaultValue on the input field, or this field should be skip in the ArgumentsTransformer. Adding an FieldInput annotation/attribute should also be considered (as currently, the #GQL\Field does not allow a default value).