overblog / GraphQLBundle

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

Add Attribute definition to EnumValue so it can be used as an attribute. #1111

Closed IzabelaTimofte closed 1 year ago

IzabelaTimofte commented 1 year ago
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Documented? no
Fixed tickets #1030
License MIT

Added Attribute definition on EnumValue

Vincz commented 1 year ago

Hi @IzabelaTimofte! Thank you for the PR. Did you checked https://github.com/overblog/GraphQLBundle/blob/master/docs/definitions/type-system/enum.md#working-with-native-php-81-enums

There is no attribute with EnumValue cause it was used only to attach description or deprecated reason to a value cause before PHP 8.1 and the attributes, the annotations library was not able to handle annotation on contants. That's why this EnumValue was used. Now with attributes, you can attach directly the #GQL\Description to the enum value as in the example here:

#[GQL\Enum]
enum Color 
{
    #[GQL\Description("The color red")]
    case RED;
    case GREEN;
    case BLUE;
}

So attribute is useless on EnumValue

IzabelaTimofte commented 1 year ago

Thank you Vincz,it works, I will close the pull request.