Consider a query like
{
node(id: garbage) {
id
}
}
GraphiQL red-underlines this as invalid syntax (since IDs are strings and should be quoted). On graphql-js similarly you get back a top-level error "Expected type ID!, found garbage".
In graphql-ruby (1.8.7) it executes the query with id given the value of "garbage". As far as I can tell this is not spec-compliant.
cc @bernardoamc @swalkinshaw
yes, seems wrong 馃槅
It's a feature, not a bug 馃槅, new RFC to add this to the spec please :trollface:
Probably related, but this also parses correctly:
{
node(id:) {
id
}
}
I'll take a look later, unless someone gets to it before.
I made a PR for another issue that parses # comment as an empty document (should raise error)
https://github.com/rmosolgo/graphql-ruby/pull/2344
Long story short, I got racc/ragel/colm setup, would like to give this a shot.
This was pretty fun, took quite a bit of head banging to spot the subtle issue. @cjoudrey
https://github.com/rmosolgo/graphql-ruby/pull/2344/commits/f2191b33e29272b326ef30183e967b8859873b9b
What a find! 馃嵒
Same as #2371, I think
I think garbage is still parsed correctly as an enum value when the spec might specify that it must be all caps. Let me check that!
it looks like this is fixed in the latest version:
# test.rb
require "graphql"
class Query < GraphQL::Schema::Object
field :str, String, null: false do
argument :input, String, required: true
end
def str(input:)
input
end
end
class Schema < GraphQL::Schema
query(Query)
end
p Schema.execute('{ str(input: "abc") }')
p Schema.execute('{ str(input: abc) }')
$ ruby test.rb
#<GraphQL::Query::Result @query=... @to_h={"data"=>{"str"=>"abc"}}>
#<GraphQL::Query::Result @query=... @to_h={"errors"=>[{"message"=>"Argument 'input' on Field 'str' has an invalid value (abc). Expected type 'String!'.", "locations"=>[{"line"=>1, "column"=>3}], "path"=>["query", "str", "input"], "extensions"=>{"code"=>"argumentLiteralsIncompatible", "typeName"=>"Field", "argumentName"=>"input"}}]}>
Most helpful comment
Probably related, but this also parses correctly:
I'll take a look later, unless someone gets to it before.