GraphQLBundle icon indicating copy to clipboard operation
GraphQLBundle copied to clipboard

Arbitrary default value for a field of enum type

Open lekseven opened this issue 2 years ago • 0 comments

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Version/Branch 0.13

Hey.

I noticed that it is possible to assign an arbitrary default value for a field of a enum type (out of enum value set), and this value successfuly passes to the resolver without any warning or error. Is this okay?

CustomerFilter:
    type: input-object
    config:
        fields:
            searchType:
                type: SearchType
                defaultValue: customer1

SearchType:
    type: enum
    config:
        values:
            CUSTOMER:
                value: 'customer'
            CUSTOMER_CORPORATE:
                value: 'customer_corporate'

Somewhere in the code:

$searchType = $args->offsetGet('filter')['searchType']; // === 'customer1'

I'd have expected the default value to be validated against the value set of the enum type in the same way as the real input value so that the value "customer1" will never get to the code.

lekseven avatar Jul 10 '23 12:07 lekseven