graphql 0.19.3 → 0.19.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/graphql/analysis/max_query_complexity.rb +1 -1
- data/lib/graphql/analysis/max_query_depth.rb +1 -1
- data/lib/graphql/boolean_type.rb +2 -2
- data/lib/graphql/define/instance_definable.rb +2 -2
- data/lib/graphql/enum_type.rb +3 -3
- data/lib/graphql/field.rb +6 -6
- data/lib/graphql/float_type.rb +2 -2
- data/lib/graphql/id_type.rb +2 -2
- data/lib/graphql/input_object_type.rb +1 -1
- data/lib/graphql/int_type.rb +2 -2
- data/lib/graphql/internal_representation/rewrite.rb +12 -12
- data/lib/graphql/introspection/arguments_field.rb +1 -1
- data/lib/graphql/introspection/enum_value_type.rb +1 -1
- data/lib/graphql/introspection/enum_values_field.rb +1 -1
- data/lib/graphql/introspection/field_type.rb +1 -1
- data/lib/graphql/introspection/fields_field.rb +1 -1
- data/lib/graphql/introspection/input_fields_field.rb +1 -1
- data/lib/graphql/introspection/input_value_type.rb +2 -2
- data/lib/graphql/introspection/interfaces_field.rb +1 -1
- data/lib/graphql/introspection/of_type_field.rb +1 -1
- data/lib/graphql/introspection/possible_types_field.rb +1 -1
- data/lib/graphql/introspection/schema_field.rb +1 -1
- data/lib/graphql/introspection/schema_type.rb +5 -5
- data/lib/graphql/introspection/type_by_name_field.rb +1 -1
- data/lib/graphql/introspection/type_type.rb +6 -6
- data/lib/graphql/introspection/typename_field.rb +1 -1
- data/lib/graphql/language.rb +1 -0
- data/lib/graphql/language/comments.rb +44 -0
- data/lib/graphql/language/definition_slice.rb +1 -1
- data/lib/graphql/language/generation.rb +35 -12
- data/lib/graphql/language/lexer.rb +29 -10
- data/lib/graphql/language/lexer.rl +25 -6
- data/lib/graphql/language/nodes.rb +30 -23
- data/lib/graphql/language/parser.rb +33 -14
- data/lib/graphql/language/parser.y +33 -14
- data/lib/graphql/language/parser_tests.rb +86 -2
- data/lib/graphql/language/token.rb +3 -2
- data/lib/graphql/language/visitor.rb +3 -3
- data/lib/graphql/object_type.rb +1 -1
- data/lib/graphql/query/arguments.rb +23 -2
- data/lib/graphql/query/serial_execution/field_resolution.rb +31 -14
- data/lib/graphql/relay/base_connection.rb +1 -3
- data/lib/graphql/relay/connection_type.rb +1 -1
- data/lib/graphql/relay/mutation.rb +1 -1
- data/lib/graphql/relay/relation_connection.rb +7 -3
- data/lib/graphql/scalar_type.rb +1 -1
- data/lib/graphql/schema.rb +19 -8
- data/lib/graphql/schema/loader.rb +2 -2
- data/lib/graphql/schema/printer.rb +63 -8
- data/lib/graphql/schema/timeout_middleware.rb +11 -11
- data/lib/graphql/schema/validation.rb +12 -12
- data/lib/graphql/static_validation/arguments_validator.rb +1 -1
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +1 -1
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +1 -1
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +1 -1
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -1
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +3 -2
- data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
- data/lib/graphql/static_validation/rules/fragment_types_exist.rb +1 -1
- data/lib/graphql/static_validation/rules/fragments_are_finite.rb +9 -4
- data/lib/graphql/static_validation/rules/fragments_are_named.rb +1 -1
- data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +1 -1
- data/lib/graphql/static_validation/rules/fragments_are_used.rb +3 -3
- data/lib/graphql/static_validation/rules/mutation_root_exists.rb +1 -1
- data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +2 -2
- data/lib/graphql/static_validation/rules/subscription_root_exists.rb +1 -1
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +1 -1
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +2 -2
- data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +6 -6
- data/lib/graphql/static_validation/type_stack.rb +2 -2
- data/lib/graphql/string_type.rb +2 -2
- data/lib/graphql/version.rb +1 -1
- data/readme.md +1 -1
- data/spec/graphql/analysis/analyze_query_spec.rb +3 -3
- data/spec/graphql/analysis/query_complexity_spec.rb +7 -7
- data/spec/graphql/introspection/directive_type_spec.rb +2 -2
- data/spec/graphql/introspection/introspection_query_spec.rb +26 -26
- data/spec/graphql/language/generation_spec.rb +137 -53
- data/spec/graphql/language/lexer_spec.rb +22 -0
- data/spec/graphql/language/visitor_spec.rb +6 -6
- data/spec/graphql/query/arguments_spec.rb +45 -1
- data/spec/graphql/query/context_spec.rb +4 -4
- data/spec/graphql/query/executor_spec.rb +1 -1
- data/spec/graphql/query/serial_execution/value_resolution_spec.rb +1 -1
- data/spec/graphql/relay/mutation_spec.rb +2 -2
- data/spec/graphql/relay/node_spec.rb +2 -2
- data/spec/graphql/relay/relation_connection_spec.rb +16 -0
- data/spec/graphql/schema/loader_spec.rb +2 -2
- data/spec/graphql/schema/middleware_chain_spec.rb +6 -6
- data/spec/graphql/schema/printer_spec.rb +268 -18
- data/spec/graphql/schema/rescue_middleware_spec.rb +1 -1
- data/spec/graphql/schema/timeout_middleware_spec.rb +2 -2
- data/spec/graphql/schema_spec.rb +2 -2
- data/spec/graphql/static_validation/rules/fragments_are_finite_spec.rb +13 -0
- data/spec/graphql/static_validation/rules/fragments_are_used_spec.rb +1 -1
- data/spec/graphql/static_validation/type_stack_spec.rb +1 -1
- data/spec/support/dairy_app.rb +25 -25
- data/spec/support/dairy_data.rb +2 -0
- data/spec/support/star_wars_data.rb +2 -1
- data/spec/support/star_wars_schema.rb +18 -18
- metadata +19 -2
data/lib/graphql/language.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
module GraphQL
|
2
|
+
module Language
|
3
|
+
module Comments
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def commentize(description, indent: '')
|
7
|
+
lines = description.split("\n")
|
8
|
+
|
9
|
+
comment = ''
|
10
|
+
|
11
|
+
lines.each do |line|
|
12
|
+
if line == ''
|
13
|
+
comment << "#{indent}#\n"
|
14
|
+
else
|
15
|
+
sublines = break_line(line, 120 - indent.length)
|
16
|
+
sublines.each do |subline|
|
17
|
+
comment << "#{indent}# #{subline}\n"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
comment
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def break_line(line, length)
|
28
|
+
return [line] if line.length < length + 5
|
29
|
+
|
30
|
+
parts = line.split(Regexp.new("((?: |^).{15,#{length - 40}}(?= |$))"))
|
31
|
+
return [line] if parts.length < 4
|
32
|
+
|
33
|
+
sublines = [parts.slice!(0, 3).join]
|
34
|
+
|
35
|
+
parts.each_with_index do |part, i|
|
36
|
+
next if i % 2 == 1
|
37
|
+
sublines << "#{part[1..-1]}#{parts[i + 1]}"
|
38
|
+
end
|
39
|
+
|
40
|
+
sublines
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -16,7 +16,7 @@ module GraphQL
|
|
16
16
|
def find_definition_dependencies(definitions, name)
|
17
17
|
names = Set.new([name])
|
18
18
|
visitor = Visitor.new(definitions[name])
|
19
|
-
visitor[Nodes::FragmentSpread] << ->
|
19
|
+
visitor[Nodes::FragmentSpread] << ->(node, parent) {
|
20
20
|
if fragment = definitions[node.name]
|
21
21
|
names.merge(find_definition_dependencies(definitions, fragment.name))
|
22
22
|
end
|
@@ -72,18 +72,26 @@ module GraphQL
|
|
72
72
|
when Nodes::VariableIdentifier
|
73
73
|
"$#{node.name}"
|
74
74
|
when Nodes::SchemaDefinition
|
75
|
+
if (node.query.nil? || node.query == 'Query') &&
|
76
|
+
(node.mutation.nil? || node.mutation == 'Mutation') &&
|
77
|
+
(node.subscription.nil? || node.subscription == 'Subscription')
|
78
|
+
return
|
79
|
+
end
|
80
|
+
|
75
81
|
out = "schema {\n"
|
76
82
|
out << " query: #{node.query}\n" if node.query
|
77
83
|
out << " mutation: #{node.mutation}\n" if node.mutation
|
78
84
|
out << " subscription: #{node.subscription}\n" if node.subscription
|
79
85
|
out << "}"
|
80
86
|
when Nodes::ScalarTypeDefinition
|
81
|
-
out =
|
87
|
+
out = generate_description(node)
|
88
|
+
out << "scalar #{node.name}"
|
82
89
|
out << generate_directives(node.directives)
|
83
90
|
when Nodes::ObjectTypeDefinition
|
84
|
-
out =
|
91
|
+
out = generate_description(node)
|
92
|
+
out << "type #{node.name}"
|
85
93
|
out << generate_directives(node.directives)
|
86
|
-
out << " implements " << node.interfaces.join(", ") unless node.interfaces.empty?
|
94
|
+
out << " implements " << node.interfaces.map(&:name).join(", ") unless node.interfaces.empty?
|
87
95
|
out << generate_field_definitions(node.fields)
|
88
96
|
when Nodes::InputValueDefinition
|
89
97
|
out = "#{node.name}: #{generate(node.type)}"
|
@@ -97,16 +105,20 @@ module GraphQL
|
|
97
105
|
out << ": #{generate(node.type)}"
|
98
106
|
out << generate_directives(node.directives)
|
99
107
|
when Nodes::InterfaceTypeDefinition
|
100
|
-
out =
|
108
|
+
out = generate_description(node)
|
109
|
+
out << "interface #{node.name}"
|
101
110
|
out << generate_directives(node.directives)
|
102
111
|
out << generate_field_definitions(node.fields)
|
103
112
|
when Nodes::UnionTypeDefinition
|
104
|
-
out =
|
113
|
+
out = generate_description(node)
|
114
|
+
out << "union #{node.name}"
|
105
115
|
out << generate_directives(node.directives)
|
106
|
-
out << " = " + node.types.join(" | ")
|
116
|
+
out << " = " + node.types.map(&:name).join(" | ")
|
107
117
|
when Nodes::EnumTypeDefinition
|
108
|
-
out =
|
109
|
-
node.
|
118
|
+
out = generate_description(node)
|
119
|
+
out << "enum #{node.name}#{generate_directives(node.directives)} {\n"
|
120
|
+
node.values.each.with_index do |value, i|
|
121
|
+
out << generate_description(value, indent: ' ', first_in_block: i == 0)
|
110
122
|
out << generate(value)
|
111
123
|
end
|
112
124
|
out << "}"
|
@@ -115,15 +127,18 @@ module GraphQL
|
|
115
127
|
out << generate_directives(node.directives)
|
116
128
|
out << "\n"
|
117
129
|
when Nodes::InputObjectTypeDefinition
|
118
|
-
out =
|
130
|
+
out = generate_description(node)
|
131
|
+
out << "input #{node.name}"
|
119
132
|
out << generate_directives(node.directives)
|
120
133
|
out << " {\n"
|
121
|
-
node.fields.each do |field|
|
134
|
+
node.fields.each.with_index do |field, i|
|
135
|
+
out << generate_description(field, indent: ' ', first_in_block: i == 0)
|
122
136
|
out << " #{generate(field)}\n"
|
123
137
|
end
|
124
138
|
out << "}"
|
125
139
|
when Nodes::DirectiveDefinition
|
126
|
-
out =
|
140
|
+
out = generate_description(node)
|
141
|
+
out << "directive @#{node.name}"
|
127
142
|
out << "(#{node.arguments.map { |a| generate(a) }.join(", ")})" if node.arguments.any?
|
128
143
|
out << " on #{node.locations.join(' | ')}"
|
129
144
|
when Nodes::AbstractNode
|
@@ -161,9 +176,17 @@ module GraphQL
|
|
161
176
|
end
|
162
177
|
end
|
163
178
|
|
179
|
+
def generate_description(node, indent: '', first_in_block: true)
|
180
|
+
return '' unless node.description
|
181
|
+
|
182
|
+
description = indent != '' && !first_in_block ? "\n" : ""
|
183
|
+
description << GraphQL::Language::Comments.commentize(node.description, indent: indent)
|
184
|
+
end
|
185
|
+
|
164
186
|
def generate_field_definitions(fields)
|
165
187
|
out = " {\n"
|
166
|
-
fields.each do |field|
|
188
|
+
fields.each.with_index do |field, i|
|
189
|
+
out << generate_description(field, indent: ' ', first_in_block: i == 0)
|
167
190
|
out << " #{generate(field)}\n"
|
168
191
|
end
|
169
192
|
out << "}"
|
@@ -333,7 +333,7 @@ self._graphql_lexer_trans_actions = [
|
|
333
333
|
25, 17, 15, 117, 0, 0, 0, 0,
|
334
334
|
0, 0, 0, 0, 0, 0, 0, 9,
|
335
335
|
33, 7, 57, 117, 117, 37, 0, 0,
|
336
|
-
0,
|
336
|
+
0, 47, 21, 0, 0, 45, 45, 0,
|
337
337
|
57, 57, 49, 0, 0, 0, 0, 0,
|
338
338
|
0, 39, 0, 41, 0, 0, 0, 0,
|
339
339
|
60, 41, 0, 0, 0, 0, 0, 57,
|
@@ -400,7 +400,7 @@ self._graphql_lexer_trans_actions = [
|
|
400
400
|
117, 43, 117, 0, 117, 117, 117, 43,
|
401
401
|
117, 0, 117, 117, 117, 43, 117, 102,
|
402
402
|
117, 117, 117, 43, 55, 55, 55, 51,
|
403
|
-
55, 53,
|
403
|
+
55, 53, 47, 55, 45, 49, 39, 41,
|
404
404
|
41, 39, 49, 55, 43, 43, 43, 43,
|
405
405
|
43, 43, 43, 43, 43, 43, 43, 43,
|
406
406
|
43, 43, 43, 43, 43, 43, 43, 43,
|
@@ -519,7 +519,7 @@ end
|
|
519
519
|
|
520
520
|
# line 132 "lib/graphql/language/lexer.rl"
|
521
521
|
|
522
|
-
emit_token = ->
|
522
|
+
emit_token = ->(name) {
|
523
523
|
emit(name, ts, te, meta)
|
524
524
|
}
|
525
525
|
|
@@ -798,7 +798,7 @@ te = p+1
|
|
798
798
|
begin emit_token.call(:PIPE) end
|
799
799
|
end
|
800
800
|
when 39 then
|
801
|
-
# line
|
801
|
+
# line 88 "lib/graphql/language/lexer.rl"
|
802
802
|
begin
|
803
803
|
te = p+1
|
804
804
|
begin
|
@@ -831,10 +831,10 @@ te = p
|
|
831
831
|
p = p - 1; begin emit_token.call(:IDENTIFIER) end
|
832
832
|
end
|
833
833
|
when 44 then
|
834
|
-
# line
|
834
|
+
# line 86 "lib/graphql/language/lexer.rl"
|
835
835
|
begin
|
836
836
|
te = p
|
837
|
-
p = p - 1; begin
|
837
|
+
p = p - 1; begin record_comment(ts, te, meta) end
|
838
838
|
end
|
839
839
|
when 45 then
|
840
840
|
# line 93 "lib/graphql/language/lexer.rl"
|
@@ -984,13 +984,29 @@ end
|
|
984
984
|
meta[:tokens]
|
985
985
|
end
|
986
986
|
|
987
|
+
def self.record_comment(ts, te, meta)
|
988
|
+
token = GraphQL::Language::Token.new(
|
989
|
+
name: :COMMENT,
|
990
|
+
value: meta[:data][ts...te].pack("c*"),
|
991
|
+
line: meta[:line],
|
992
|
+
col: meta[:col],
|
993
|
+
prev_token: @previous_token,
|
994
|
+
)
|
995
|
+
|
996
|
+
@previous_token = token
|
997
|
+
|
998
|
+
meta[:col] += te - ts
|
999
|
+
end
|
1000
|
+
|
987
1001
|
def self.emit(token_name, ts, te, meta)
|
988
|
-
meta[:tokens] << GraphQL::Language::Token.new(
|
1002
|
+
meta[:tokens] << token = GraphQL::Language::Token.new(
|
989
1003
|
name: token_name,
|
990
1004
|
value: meta[:data][ts...te].pack("c*"),
|
991
1005
|
line: meta[:line],
|
992
1006
|
col: meta[:col],
|
1007
|
+
prev_token: @previous_token,
|
993
1008
|
)
|
1009
|
+
@previous_token = token
|
994
1010
|
# Bump the column counter for the next token
|
995
1011
|
meta[:col] += te - ts
|
996
1012
|
end
|
@@ -1008,28 +1024,31 @@ end
|
|
1008
1024
|
}
|
1009
1025
|
|
1010
1026
|
UTF_8 = /\\u[\dAa-f]{4}/i
|
1011
|
-
UTF_8_REPLACE = ->
|
1027
|
+
UTF_8_REPLACE = ->(m) { [m[-4..-1].to_i(16)].pack('U'.freeze) }
|
1012
1028
|
|
1013
1029
|
def self.emit_string(ts, te, meta)
|
1014
1030
|
value = meta[:data][ts...te].pack("c*").force_encoding("UTF-8")
|
1015
1031
|
if value =~ /\\u|\\./ && value !~ ESCAPES
|
1016
|
-
meta[:tokens] << GraphQL::Language::Token.new(
|
1032
|
+
meta[:tokens] << token = GraphQL::Language::Token.new(
|
1017
1033
|
name: :BAD_UNICODE_ESCAPE,
|
1018
1034
|
value: value,
|
1019
1035
|
line: meta[:line],
|
1020
1036
|
col: meta[:col],
|
1037
|
+
prev_token: @previous_token,
|
1021
1038
|
)
|
1022
1039
|
else
|
1023
1040
|
replace_escaped_characters_in_place(value)
|
1024
1041
|
|
1025
|
-
meta[:tokens] << GraphQL::Language::Token.new(
|
1042
|
+
meta[:tokens] << token = GraphQL::Language::Token.new(
|
1026
1043
|
name: :STRING,
|
1027
1044
|
value: value,
|
1028
1045
|
line: meta[:line],
|
1029
1046
|
col: meta[:col],
|
1047
|
+
prev_token: @previous_token,
|
1030
1048
|
)
|
1031
1049
|
end
|
1032
1050
|
|
1051
|
+
@previous_token = token
|
1033
1052
|
meta[:col] += te - ts
|
1034
1053
|
end
|
1035
1054
|
end
|
@@ -83,6 +83,7 @@
|
|
83
83
|
BANG => { emit_token.call(:BANG) };
|
84
84
|
PIPE => { emit_token.call(:PIPE) };
|
85
85
|
IDENTIFIER => { emit_token.call(:IDENTIFIER) };
|
86
|
+
COMMENT => { record_comment(ts, te, meta) };
|
86
87
|
|
87
88
|
NEWLINE => {
|
88
89
|
meta[:line] += 1
|
@@ -90,7 +91,6 @@
|
|
90
91
|
};
|
91
92
|
|
92
93
|
BLANK => { meta[:col] += te - ts };
|
93
|
-
COMMENT => { meta[:col] += te - ts };
|
94
94
|
|
95
95
|
UNKNOWN_CHAR => { emit_token.call(:UNKNOWN_CHAR) };
|
96
96
|
|
@@ -130,7 +130,7 @@ module GraphQL
|
|
130
130
|
|
131
131
|
%% write init;
|
132
132
|
|
133
|
-
emit_token = ->
|
133
|
+
emit_token = ->(name) {
|
134
134
|
emit(name, ts, te, meta)
|
135
135
|
}
|
136
136
|
|
@@ -139,13 +139,29 @@ module GraphQL
|
|
139
139
|
meta[:tokens]
|
140
140
|
end
|
141
141
|
|
142
|
+
def self.record_comment(ts, te, meta)
|
143
|
+
token = GraphQL::Language::Token.new(
|
144
|
+
name: :COMMENT,
|
145
|
+
value: meta[:data][ts...te].pack("c*"),
|
146
|
+
line: meta[:line],
|
147
|
+
col: meta[:col],
|
148
|
+
prev_token: @previous_token,
|
149
|
+
)
|
150
|
+
|
151
|
+
@previous_token = token
|
152
|
+
|
153
|
+
meta[:col] += te - ts
|
154
|
+
end
|
155
|
+
|
142
156
|
def self.emit(token_name, ts, te, meta)
|
143
|
-
meta[:tokens] << GraphQL::Language::Token.new(
|
157
|
+
meta[:tokens] << token = GraphQL::Language::Token.new(
|
144
158
|
name: token_name,
|
145
159
|
value: meta[:data][ts...te].pack("c*"),
|
146
160
|
line: meta[:line],
|
147
161
|
col: meta[:col],
|
162
|
+
prev_token: @previous_token,
|
148
163
|
)
|
164
|
+
@previous_token = token
|
149
165
|
# Bump the column counter for the next token
|
150
166
|
meta[:col] += te - ts
|
151
167
|
end
|
@@ -163,28 +179,31 @@ module GraphQL
|
|
163
179
|
}
|
164
180
|
|
165
181
|
UTF_8 = /\\u[\dAa-f]{4}/i
|
166
|
-
UTF_8_REPLACE = ->
|
182
|
+
UTF_8_REPLACE = ->(m) { [m[-4..-1].to_i(16)].pack('U'.freeze) }
|
167
183
|
|
168
184
|
def self.emit_string(ts, te, meta)
|
169
185
|
value = meta[:data][ts...te].pack("c*").force_encoding("UTF-8")
|
170
186
|
if value =~ /\\u|\\./ && value !~ ESCAPES
|
171
|
-
meta[:tokens] << GraphQL::Language::Token.new(
|
187
|
+
meta[:tokens] << token = GraphQL::Language::Token.new(
|
172
188
|
name: :BAD_UNICODE_ESCAPE,
|
173
189
|
value: value,
|
174
190
|
line: meta[:line],
|
175
191
|
col: meta[:col],
|
192
|
+
prev_token: @previous_token,
|
176
193
|
)
|
177
194
|
else
|
178
195
|
replace_escaped_characters_in_place(value)
|
179
196
|
|
180
|
-
meta[:tokens] << GraphQL::Language::Token.new(
|
197
|
+
meta[:tokens] << token = GraphQL::Language::Token.new(
|
181
198
|
name: :STRING,
|
182
199
|
value: value,
|
183
200
|
line: meta[:line],
|
184
201
|
col: meta[:col],
|
202
|
+
prev_token: @previous_token,
|
185
203
|
)
|
186
204
|
end
|
187
205
|
|
206
|
+
@previous_token = token
|
188
207
|
meta[:col] += te - ts
|
189
208
|
end
|
190
209
|
end
|
@@ -17,9 +17,6 @@ module GraphQL
|
|
17
17
|
if options.key?(:position_source)
|
18
18
|
position_source = options.delete(:position_source)
|
19
19
|
@line, @col = position_source.line_and_column
|
20
|
-
elsif options.key?(:line)
|
21
|
-
@line = options.delete(:line)
|
22
|
-
@col = options.delete(:col)
|
23
20
|
end
|
24
21
|
|
25
22
|
initialize_node(options)
|
@@ -143,14 +140,15 @@ module GraphQL
|
|
143
140
|
end
|
144
141
|
|
145
142
|
class DirectiveDefinition < AbstractNode
|
146
|
-
attr_accessor :name, :arguments, :locations
|
143
|
+
attr_accessor :name, :arguments, :locations, :description
|
147
144
|
scalar_attributes :name
|
148
145
|
child_attributes :arguments, :locations
|
149
146
|
|
150
|
-
def initialize_node(name: nil, arguments: [], locations: [])
|
147
|
+
def initialize_node(name: nil, arguments: [], locations: [], description: nil)
|
151
148
|
@name = name
|
152
149
|
@arguments = arguments
|
153
150
|
@locations = locations
|
151
|
+
@description = description
|
154
152
|
end
|
155
153
|
end
|
156
154
|
|
@@ -347,111 +345,120 @@ module GraphQL
|
|
347
345
|
end
|
348
346
|
|
349
347
|
class ScalarTypeDefinition < AbstractNode
|
350
|
-
attr_accessor :name, :directives
|
348
|
+
attr_accessor :name, :directives, :description
|
351
349
|
scalar_attributes :name
|
352
350
|
child_attributes :directives
|
353
351
|
|
354
|
-
def initialize_node(name:, directives: [])
|
352
|
+
def initialize_node(name:, directives: [], description: nil)
|
355
353
|
@name = name
|
356
354
|
@directives = directives
|
355
|
+
@description = description
|
357
356
|
end
|
358
357
|
end
|
359
358
|
|
360
359
|
class ObjectTypeDefinition < AbstractNode
|
361
|
-
attr_accessor :name, :interfaces, :fields, :directives
|
360
|
+
attr_accessor :name, :interfaces, :fields, :directives, :description
|
362
361
|
scalar_attributes :name
|
363
362
|
child_attributes :interfaces, :fields, :directives
|
364
363
|
|
365
|
-
def initialize_node(name:, interfaces:, fields:, directives: [])
|
364
|
+
def initialize_node(name:, interfaces:, fields:, directives: [], description: nil)
|
366
365
|
@name = name
|
367
366
|
@interfaces = interfaces || []
|
368
367
|
@directives = directives
|
369
368
|
@fields = fields
|
369
|
+
@description = description
|
370
370
|
end
|
371
371
|
end
|
372
372
|
|
373
373
|
class InputValueDefinition < AbstractNode
|
374
|
-
attr_accessor :name, :type, :default_value, :directives
|
374
|
+
attr_accessor :name, :type, :default_value, :directives,:description
|
375
375
|
scalar_attributes :name, :type, :default_value
|
376
376
|
child_attributes :directives
|
377
377
|
|
378
|
-
def initialize_node(name:, type:, default_value: nil, directives: [])
|
378
|
+
def initialize_node(name:, type:, default_value: nil, directives: [], description: nil)
|
379
379
|
@name = name
|
380
380
|
@type = type
|
381
381
|
@default_value = default_value
|
382
382
|
@directives = directives
|
383
|
+
@description = description
|
383
384
|
end
|
384
385
|
end
|
385
386
|
|
386
387
|
class FieldDefinition < AbstractNode
|
387
|
-
attr_accessor :name, :arguments, :type, :directives
|
388
|
+
attr_accessor :name, :arguments, :type, :directives, :description
|
388
389
|
scalar_attributes :name, :type
|
389
390
|
child_attributes :arguments, :directives
|
390
391
|
|
391
|
-
def initialize_node(name:, arguments:, type:, directives: [])
|
392
|
+
def initialize_node(name:, arguments:, type:, directives: [], description: nil)
|
392
393
|
@name = name
|
393
394
|
@arguments = arguments
|
394
395
|
@type = type
|
395
396
|
@directives = directives
|
397
|
+
@description = description
|
396
398
|
end
|
397
399
|
end
|
398
400
|
|
399
401
|
class InterfaceTypeDefinition < AbstractNode
|
400
|
-
attr_accessor :name, :fields, :directives
|
402
|
+
attr_accessor :name, :fields, :directives, :description
|
401
403
|
scalar_attributes :name
|
402
404
|
child_attributes :fields, :directives
|
403
405
|
|
404
|
-
def initialize_node(name:, fields:, directives: [])
|
406
|
+
def initialize_node(name:, fields:, directives: [], description: nil)
|
405
407
|
@name = name
|
406
408
|
@fields = fields
|
407
409
|
@directives = directives
|
410
|
+
@description = description
|
408
411
|
end
|
409
412
|
end
|
410
413
|
|
411
414
|
class UnionTypeDefinition < AbstractNode
|
412
|
-
attr_accessor :name, :types, :directives
|
415
|
+
attr_accessor :name, :types, :directives, :description
|
413
416
|
scalar_attributes :name
|
414
417
|
child_attributes :types, :directives
|
415
418
|
|
416
|
-
def initialize_node(name:, types:, directives: [])
|
419
|
+
def initialize_node(name:, types:, directives: [], description: nil)
|
417
420
|
@name = name
|
418
421
|
@types = types
|
419
422
|
@directives = directives
|
423
|
+
@description = description
|
420
424
|
end
|
421
425
|
end
|
422
426
|
|
423
427
|
class EnumTypeDefinition < AbstractNode
|
424
|
-
attr_accessor :name, :values, :directives
|
428
|
+
attr_accessor :name, :values, :directives, :description
|
425
429
|
scalar_attributes :name
|
426
430
|
child_attributes :values, :directives
|
427
431
|
|
428
|
-
def initialize_node(name:, values:, directives: [])
|
432
|
+
def initialize_node(name:, values:, directives: [], description: nil)
|
429
433
|
@name = name
|
430
434
|
@values = values
|
431
435
|
@directives = directives
|
436
|
+
@description = description
|
432
437
|
end
|
433
438
|
end
|
434
439
|
|
435
440
|
class EnumValueDefinition < AbstractNode
|
436
|
-
attr_accessor :name, :directives
|
441
|
+
attr_accessor :name, :directives, :description
|
437
442
|
scalar_attributes :name
|
438
443
|
child_attributes :directives
|
439
444
|
|
440
|
-
def initialize_node(name:, directives: [])
|
445
|
+
def initialize_node(name:, directives: [], description: nil)
|
441
446
|
@name = name
|
442
447
|
@directives = directives
|
448
|
+
@description = description
|
443
449
|
end
|
444
450
|
end
|
445
451
|
|
446
452
|
class InputObjectTypeDefinition < AbstractNode
|
447
|
-
attr_accessor :name, :fields, :directives
|
453
|
+
attr_accessor :name, :fields, :directives, :description
|
448
454
|
scalar_attributes :name
|
449
455
|
child_attributes :fields
|
450
456
|
|
451
|
-
def initialize_node(name:, fields:, directives: [])
|
457
|
+
def initialize_node(name:, fields:, directives: [], description: nil)
|
452
458
|
@name = name
|
453
459
|
@fields = fields
|
454
460
|
@directives = directives
|
461
|
+
@description = description
|
455
462
|
end
|
456
463
|
end
|
457
464
|
end
|