Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arbitrary default value for a field of enum type #1125

Open
lekseven opened this issue Jul 10, 2023 · 0 comments
Open

Arbitrary default value for a field of enum type #1125

lekseven opened this issue Jul 10, 2023 · 0 comments

Comments

@lekseven
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant