From cdcc7b5733593a827a9988d3d7af0fbb66a95d77 Mon Sep 17 00:00:00 2001 From: Robert Mosolgo Date: Fri, 1 Dec 2023 11:19:08 -0500 Subject: [PATCH] Try skipping some method calls? --- .../language/recursive_descent_parser.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/graphql/language/recursive_descent_parser.rb b/lib/graphql/language/recursive_descent_parser.rb index 8bc17b2081a..c19e14de795 100644 --- a/lib/graphql/language/recursive_descent_parser.rb +++ b/lib/graphql/language/recursive_descent_parser.rb @@ -157,9 +157,9 @@ def operation_type def selection_set expect_token(:LCURLY) selections = [] - while !at?(:RCURLY) + while @token_name != :RCURLY selections << if at?(:ELLIPSIS) - expect_token(:ELLIPSIS) + advance_token case token_name when :ON, :DIR_SIGN, :LCURLY loc = pos @@ -189,19 +189,19 @@ def selection_set loc = pos name = self.name - aliaz = nil + field_alias = nil if at?(:COLON) - expect_token(:COLON) - aliaz = name + advance_token + field_alias = name name = self.name end - arguments = parse_arguments - directives = parse_directives - selection_set = if at?(:LCURLY); self.selection_set; end + arguments = at?(:LPAREN) ? parse_arguments : nil + directives = at?(:DIR_SIGN) ? parse_directives : nil + selection_set = at?(:LCURLY) ? self.selection_set : nil - Nodes::Field.new(pos: loc, alias: aliaz, name: name, arguments: arguments, directives: directives, selections: selection_set) + Nodes::Field.new(pos: loc, alias: field_alias, name: name, arguments: arguments, directives: directives, selections: selection_set) end end expect_token(:RCURLY)