-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Variables aren't coerced. #46
Comments
Oh, it actually looks like values are also not coerced. E.g. require 'graphql'
require 'json'
QueryRoot = GraphQL::ObjectType.define do
name "Query"
field :add, types.String do
argument :a, types.Int
argument :b, types.Int
resolve ->(obj, args, ctx) {
"#{args['a'].inspect} + #{args['b'].inspect}"
}
end
end
Schema = GraphQL::Schema.new(query: QueryRoot)
result = Schema.execute('{ add(a: 1.2, b: 2.3) }')
puts JSON.pretty_generate(result) outputs
because the static validator coerces the inputs, but the result isn't used, so the original float values get passed in as integer arguments. |
Here we go: fa7a2db You can see where it was just reading the value and not coercing it at all, now it's coercing it! Also it will raise if it fails to coerce |
This was referenced Oct 13, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is an example script that shows the problem:
outputs
despite the fact that a string variable value was accepted in an Int typed argument.
There is a check to make sure the declared variables type matches the argument type, but no coercion of the variable values themselves.
The text was updated successfully, but these errors were encountered: