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

Missing type validation for lists #2428

Closed
ChepChaf opened this issue Aug 15, 2019 · 1 comment · Fixed by #2441
Closed

Missing type validation for lists #2428

ChepChaf opened this issue Aug 15, 2019 · 1 comment · Fixed by #2441

Comments

@ChepChaf
Copy link

ChepChaf commented Aug 15, 2019

I have a resolver that takes a list of enums as an argument, but when i send something other than that enum ir raises an exception instead of returning an error. e.g:
enum:

class Enums::FooEnum < Enums::BaseObject
  value 'Foo1', value: 'foo1'
  value 'Foo2', value: 'foo2'
end

resolver:

class Resolvers::BarResolver < Resolvers::Base
  argument :foo, [Enums::FooEnum], required: true

  def resolve(**args)
    # do something that raises `CantDoThatException`
   #  unless every element of `foo` is a `FooEnum`
  end
end

query_1:

bar(foo: [Foo1, Foo2]) {
  fields
}

query_2:

bar(foo: [Foo1, 'random_value']) {
  fields
}

query_1 works as expected
query_2 raises CantDoThatException instead of returning something like:

{
  "errors": [
    {
      "message": "Argument 'dimensions' on Field 'images' has an invalid value. Expected type '[FooEnum!]!'.", ...
      ...
    }
  ]
}

Edit: After futher investigation i noticed that

>> args[:foo]
['foo1', nil]

So instead of returning an error it is casting all invalidad arguments to nil

@rmosolgo
Copy link
Owner

Thanks for the great bug report! It will be fixed in the next release by #2441

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 a pull request may close this issue.

2 participants