lib/graphql/language/parser.y in graphql-1.9.4 vs lib/graphql/language/parser.y in graphql-1.9.5
- old
+ new
@@ -57,11 +57,11 @@
operation_name_opt:
/* none */ { return nil }
| name
variable_definitions_opt:
- /* none */ { return [] }
+ /* none */ { return EMPTY_ARRAY }
| LPAREN variable_definitions_list RPAREN { return val[1] }
variable_definitions_list:
variable_definition { return [val[0]] }
| variable_definitions_list variable_definition { val[0] << val[1] }
@@ -87,11 +87,11 @@
selection_set:
LCURLY selection_list RCURLY { return val[1] }
selection_set_opt:
- /* none */ { return [] }
+ /* none */ { return EMPTY_ARRAY }
| selection_set { return val[0] }
selection_list:
selection { return [result] }
| selection_list selection { val[0] << val[1] }
@@ -162,12 +162,12 @@
enum_value_definitions:
enum_value_definition { return [val[0]] }
| enum_value_definitions enum_value_definition { return val[0] << val[1] }
arguments_opt:
- /* none */ { return [] }
- | LPAREN RPAREN { return [] }
+ /* none */ { return EMPTY_ARRAY }
+ | LPAREN RPAREN { return EMPTY_ARRAY }
| LPAREN arguments_list RPAREN { return val[1] }
arguments_list:
argument { return [val[0]] }
| arguments_list argument { val[0] << val[1] }
@@ -193,11 +193,11 @@
null_value: NULL { return make_node(:NullValue, name: val[0], position_source: val[0]) }
variable: VAR_SIGN name { return make_node(:VariableIdentifier, name: val[1], position_source: val[0]) }
list_value:
- LBRACKET RBRACKET { return [] }
+ LBRACKET RBRACKET { return EMPTY_ARRAY }
| LBRACKET list_value_list RBRACKET { return val[1] }
list_value_list:
input_value { return [val[0]] }
| list_value_list input_value { val[0] << val[1] }
@@ -226,11 +226,11 @@
name COLON literal_value { return make_node(:Argument, name: val[0], value: val[2], position_source: val[0])}
enum_value: enum_name { return make_node(:Enum, name: val[0], position_source: val[0]) }
directives_list_opt:
- /* none */ { return [] }
+ /* none */ { return EMPTY_ARRAY }
| directives_list
directives_list:
directive { return [val[0]] }
| directives_list directive { val[0] << val[1] }
@@ -353,11 +353,11 @@
description_opt TYPE name implements_opt directives_list_opt LCURLY field_definition_list RCURLY {
return make_node(:ObjectTypeDefinition, name: val[2], interfaces: val[3], directives: val[4], fields: val[6], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
}
implements_opt:
- /* none */ { return [] }
+ /* none */ { return EMPTY_ARRAY }
| implements
implements:
IMPLEMENTS AMP interfaces_list { return val[2] }
| IMPLEMENTS interfaces_list { return val[1] }
@@ -379,20 +379,20 @@
input_value_definition_list:
input_value_definition { return [val[0]] }
| input_value_definition_list input_value_definition { val[0] << val[1] }
arguments_definitions_opt:
- /* none */ { return [] }
+ /* none */ { return EMPTY_ARRAY }
| LPAREN input_value_definition_list RPAREN { return val[1] }
field_definition:
description_opt name arguments_definitions_opt COLON type directives_list_opt {
return make_node(:FieldDefinition, name: val[1], arguments: val[2], type: val[4], directives: val[5], description: val[0] || get_description(val[1]), definition_line: val[1].line, position_source: val[0] || val[1])
}
field_definition_list:
- /* none */ { return [] }
+ /* none */ { return EMPTY_ARRAY }
| field_definition { return [val[0]] }
| field_definition_list field_definition { val[0] << val[1] }
interface_type_definition:
description_opt INTERFACE name directives_list_opt LCURLY field_definition_list RCURLY {
@@ -431,10 +431,13 @@
---- header ----
---- inner ----
+EMPTY_ARRAY = [].freeze
+
def initialize(query_string, filename:, tracer: Tracing::NullTracer)
+ raise GraphQL::ParseError.new("No query string was present", nil, nil, query_string) if query_string.nil?
@query_string = query_string
@filename = filename
@tracer = tracer
end