Skip to content

Commit ff2fdd8

Browse files
committed
Add a spec to assert that enums used as strings will raise argumentLiteralsIncompatible
1 parent 02e05ea commit ff2fdd8

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

spec/graphql/static_validation/rules/argument_literals_are_compatible_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,40 @@
137137
end
138138
end
139139

140+
describe "using enums for scalar arguments it adds an error" do
141+
let(:query_string) { <<~GRAPHQL
142+
{
143+
cheese(id: I_AM_ENUM_VALUE) {
144+
source
145+
}
146+
}
147+
GRAPHQL
148+
}
149+
150+
let(:enum_invalid_for_id_error) do
151+
{
152+
"message" => "Argument 'id' on Field 'cheese' has an invalid value. Expected type 'Int!'.",
153+
"locations" => [{ "line" => 2, "column" => 3 }],
154+
"path"=> ["query", "cheese", "id"],
155+
"extensions"=> { "code" => "argumentLiteralsIncompatible", "typeName" => "Field", "argumentName" => "id" }
156+
}
157+
end
158+
159+
it "works with error bubbling disabled" do
160+
without_error_bubbling(schema) do
161+
assert_includes(errors, enum_invalid_for_id_error)
162+
assert_equal 1, errors.length
163+
end
164+
end
165+
166+
it "works with error bubbling enabled" do
167+
with_error_bubbling(schema) do
168+
assert_includes(errors, enum_invalid_for_id_error)
169+
assert_equal 1, errors.length
170+
end
171+
end
172+
end
173+
140174
describe "null value" do
141175
describe "nullable arg" do
142176
let(:schema) {

0 commit comments

Comments
 (0)