Skip to content

Commit 35c6bc2

Browse files
committed
Properly parse fields named on and directive
1 parent 1380354 commit 35c6bc2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/graphql/language/parser.rb

+6
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,12 @@ def parse_name
566566
when :NULL
567567
advance_token
568568
"null"
569+
when :ON
570+
advance_token
571+
"on"
572+
when :DIRECTIVE
573+
advance_token
574+
"directive"
569575
else
570576
expect_token(:NAME)
571577
end

spec/graphql/language/parser_spec.rb

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
assert GraphQL.parse("{ field(null: false) ... null } fragment null on Query { null }")
2929
end
3030

31+
it "allows fields and arguments named on and directive" do
32+
assert GraphQL.parse("{ on(on: false) directive(directive: false)}")
33+
end
34+
3135
it "raises an error when unicode is used as names" do
3236
err = assert_raises(GraphQL::ParseError) {
3337
GraphQL.parse('query 😘 { a b }')

0 commit comments

Comments
 (0)