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

Fix dynamic enums when used as arguments with default value #1239

Closed
wants to merge 3 commits into from

Conversation

rewritten
Copy link
Contributor

@rewritten rewritten commented Apr 5, 2023

When an enum is defined dynamically, its values field will contain a list-of-one-list-of-atoms (see #1041) and the validator will fail.

This change allows the validator to be used for dynamic enums too.

Actual example:

enum :country_codes, values: Cldr.Territory.country_codes()

query do
  field :things, list_of(:thing) do
    arg :country_code, :country_code, default_value: :US
  end
end

Copy link
Contributor

@benwilson512 benwilson512 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rewritten I think the issue here is that the way this ought to be handled is that we ought to be normalizing the values of the enum so that they are the same shape no matter how they are in the schema.

If all of the code has to worry about it being both a list of atoms AND a list of structs it's going to get a lot more complicated.

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

Successfully merging this pull request may close these issues.

2 participants