graphql 1.7.14 → 1.8.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/generators/graphql/function_generator.rb +1 -1
- data/lib/generators/graphql/loader_generator.rb +1 -1
- data/lib/generators/graphql/mutation_generator.rb +1 -6
- data/lib/generators/graphql/templates/function.erb +2 -2
- data/lib/generators/graphql/templates/loader.erb +2 -2
- data/lib/graphql.rb +2 -0
- data/lib/graphql/argument.rb +0 -1
- data/lib/graphql/backwards_compatibility.rb +2 -3
- data/lib/graphql/base_type.rb +18 -16
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -117
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -14
- data/lib/graphql/define/assign_object_field.rb +5 -12
- data/lib/graphql/deprecated_dsl.rb +28 -0
- data/lib/graphql/directive.rb +0 -1
- data/lib/graphql/enum_type.rb +1 -3
- data/lib/graphql/execution.rb +0 -1
- data/lib/graphql/execution/multiplex.rb +29 -12
- data/lib/graphql/field.rb +5 -20
- data/lib/graphql/function.rb +12 -0
- data/lib/graphql/input_object_type.rb +1 -3
- data/lib/graphql/internal_representation/node.rb +14 -26
- data/lib/graphql/internal_representation/visit.rb +6 -3
- data/lib/graphql/introspection/arguments_field.rb +0 -1
- data/lib/graphql/introspection/enum_values_field.rb +0 -1
- data/lib/graphql/introspection/fields_field.rb +0 -1
- data/lib/graphql/introspection/input_fields_field.rb +0 -1
- data/lib/graphql/introspection/interfaces_field.rb +0 -1
- data/lib/graphql/introspection/of_type_field.rb +0 -1
- data/lib/graphql/introspection/possible_types_field.rb +0 -1
- data/lib/graphql/introspection/schema_field.rb +0 -1
- data/lib/graphql/introspection/type_by_name_field.rb +0 -1
- data/lib/graphql/introspection/typename_field.rb +0 -1
- data/lib/graphql/language.rb +0 -3
- data/lib/graphql/language/generation.rb +182 -3
- data/lib/graphql/language/lexer.rb +69 -144
- data/lib/graphql/language/lexer.rl +4 -15
- data/lib/graphql/language/nodes.rb +76 -136
- data/lib/graphql/language/parser.rb +621 -668
- data/lib/graphql/language/parser.y +11 -17
- data/lib/graphql/language/token.rb +3 -10
- data/lib/graphql/object_type.rb +6 -1
- data/lib/graphql/query.rb +13 -8
- data/lib/graphql/query/arguments.rb +33 -48
- data/lib/graphql/query/context.rb +1 -0
- data/lib/graphql/query/literal_input.rb +1 -4
- data/lib/graphql/relay/connection_resolve.rb +3 -0
- data/lib/graphql/relay/global_id_resolve.rb +5 -1
- data/lib/graphql/relay/relation_connection.rb +19 -14
- data/lib/graphql/schema.rb +219 -12
- data/lib/graphql/schema/argument.rb +33 -0
- data/lib/graphql/schema/build_from_definition.rb +18 -64
- data/lib/graphql/schema/enum.rb +76 -0
- data/lib/graphql/schema/field.rb +127 -0
- data/lib/graphql/schema/field/dynamic_resolve.rb +63 -0
- data/lib/graphql/schema/field/unwrapped_resolve.rb +20 -0
- data/lib/graphql/schema/input_object.rb +61 -0
- data/lib/graphql/schema/interface.rb +32 -0
- data/lib/graphql/schema/loader.rb +2 -2
- data/lib/graphql/schema/member.rb +97 -0
- data/lib/graphql/schema/member/build_type.rb +106 -0
- data/lib/graphql/schema/member/has_fields.rb +56 -0
- data/lib/graphql/schema/member/instrumentation.rb +113 -0
- data/lib/graphql/schema/member/list_type_proxy.rb +21 -0
- data/lib/graphql/schema/member/non_null_type_proxy.rb +21 -0
- data/lib/graphql/schema/object.rb +65 -0
- data/lib/graphql/schema/printer.rb +266 -33
- data/lib/graphql/schema/scalar.rb +25 -0
- data/lib/graphql/schema/traversal.rb +26 -17
- data/lib/graphql/schema/union.rb +48 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -5
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +8 -15
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +1 -11
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +5 -7
- data/lib/graphql/tracing.rb +0 -1
- data/lib/graphql/tracing/platform_tracing.rb +7 -20
- data/lib/graphql/tracing/scout_tracing.rb +2 -2
- data/lib/graphql/unresolved_type_error.rb +2 -3
- data/lib/graphql/version.rb +1 -1
- data/readme.md +1 -1
- data/spec/dummy/app/channels/graphql_channel.rb +1 -22
- data/spec/dummy/log/development.log +0 -239
- data/spec/dummy/log/test.log +0 -204
- data/spec/dummy/test/system/action_cable_subscription_test.rb +0 -4
- data/spec/dummy/tmp/screenshots/failures_test_it_handles_subscriptions.png +0 -0
- data/spec/generators/graphql/function_generator_spec.rb +0 -26
- data/spec/generators/graphql/loader_generator_spec.rb +0 -24
- data/spec/graphql/analysis/max_query_complexity_spec.rb +3 -3
- data/spec/graphql/analysis/max_query_depth_spec.rb +3 -3
- data/spec/graphql/backtrace_spec.rb +0 -10
- data/spec/graphql/base_type_spec.rb +5 -19
- data/spec/graphql/boolean_type_spec.rb +3 -3
- data/spec/graphql/directive_spec.rb +1 -3
- data/spec/graphql/enum_type_spec.rb +5 -18
- data/spec/graphql/execution/execute_spec.rb +1 -1
- data/spec/graphql/execution/multiplex_spec.rb +2 -2
- data/spec/graphql/float_type_spec.rb +2 -2
- data/spec/graphql/id_type_spec.rb +1 -1
- data/spec/graphql/input_object_type_spec.rb +2 -15
- data/spec/graphql/int_type_spec.rb +2 -2
- data/spec/graphql/internal_representation/rewrite_spec.rb +2 -2
- data/spec/graphql/introspection/schema_type_spec.rb +0 -1
- data/spec/graphql/language/generation_spec.rb +186 -21
- data/spec/graphql/language/lexer_spec.rb +1 -21
- data/spec/graphql/language/nodes_spec.rb +12 -21
- data/spec/graphql/language/parser_spec.rb +1 -1
- data/spec/graphql/query/arguments_spec.rb +15 -37
- data/spec/graphql/query/serial_execution/value_resolution_spec.rb +2 -2
- data/spec/graphql/query/variables_spec.rb +1 -1
- data/spec/graphql/query_spec.rb +5 -31
- data/spec/graphql/rake_task_spec.rb +1 -3
- data/spec/graphql/relay/base_connection_spec.rb +1 -1
- data/spec/graphql/relay/connection_instrumentation_spec.rb +2 -2
- data/spec/graphql/relay/connection_resolve_spec.rb +1 -1
- data/spec/graphql/relay/connection_type_spec.rb +1 -1
- data/spec/graphql/relay/mutation_spec.rb +3 -3
- data/spec/graphql/relay/relation_connection_spec.rb +1 -65
- data/spec/graphql/schema/build_from_definition_spec.rb +4 -86
- data/spec/graphql/schema/enum_spec.rb +60 -0
- data/spec/graphql/schema/field_spec.rb +14 -0
- data/spec/graphql/schema/input_object_spec.rb +43 -0
- data/spec/graphql/schema/interface_spec.rb +98 -0
- data/spec/graphql/schema/object_spec.rb +119 -0
- data/spec/graphql/schema/printer_spec.rb +15 -92
- data/spec/graphql/schema/scalar_spec.rb +40 -0
- data/spec/graphql/schema/union_spec.rb +35 -0
- data/spec/graphql/schema/validation_spec.rb +1 -1
- data/spec/graphql/schema/warden_spec.rb +11 -11
- data/spec/graphql/schema_spec.rb +25 -23
- data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +2 -10
- data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +2 -2
- data/spec/graphql/string_type_spec.rb +3 -3
- data/spec/graphql/subscriptions_spec.rb +1 -1
- data/spec/graphql/tracing/platform_tracing_spec.rb +1 -60
- data/spec/support/dummy/schema.rb +25 -39
- data/spec/support/jazz.rb +334 -0
- data/spec/support/lazy_helpers.rb +21 -23
- data/spec/support/star_wars/data.rb +7 -6
- data/spec/support/star_wars/schema.rb +109 -142
- metadata +39 -33
- data/lib/graphql/execution/instrumentation.rb +0 -82
- data/lib/graphql/language/block_string.rb +0 -47
- data/lib/graphql/language/document_from_schema_definition.rb +0 -277
- data/lib/graphql/language/printer.rb +0 -351
- data/lib/graphql/tracing/data_dog_tracing.rb +0 -49
- data/spec/graphql/execution/instrumentation_spec.rb +0 -165
- data/spec/graphql/language/block_string_spec.rb +0 -70
- data/spec/graphql/language/document_from_schema_definition_spec.rb +0 -770
- data/spec/graphql/language/printer_spec.rb +0 -203
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 909c3eda6b9624635a5901ceddee57a8e714a96c
|
4
|
+
data.tar.gz: 7cc0f7c57d20b6979fba3156077e7989d55d6646
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d94639f25409ba6fb4504fd9cd5fba087e717c36f88ef6329202c3f286050927ca73d67bba12313368f0aa8080af408611184b6f7bb2a4f0e24a327a76e124e7
|
7
|
+
data.tar.gz: d84a84ad71225d052113c863b69ff25cb724fc97d31db680b8eee1befe7252ee94e50ff5b4cf23018fc8460c20dc80c60075dc00f42af5138c01f1f7342af9d3
|
@@ -11,7 +11,7 @@ module Graphql
|
|
11
11
|
source_root File.expand_path('../templates', __FILE__)
|
12
12
|
|
13
13
|
def create_function_file
|
14
|
-
template "function.erb", "#{options[:directory]}/functions/#{
|
14
|
+
template "function.erb", "#{options[:directory]}/functions/#{file_name}.rb"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -13,7 +13,7 @@ module Graphql
|
|
13
13
|
source_root File.expand_path('../templates', __FILE__)
|
14
14
|
|
15
15
|
def create_loader_file
|
16
|
-
template "loader.erb", "#{options[:directory]}/loaders/#{
|
16
|
+
template "loader.erb", "#{options[:directory]}/loaders/#{file_name}.rb"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -27,12 +27,7 @@ module Graphql
|
|
27
27
|
attr_reader :file_name, :mutation_name, :field_name
|
28
28
|
|
29
29
|
def create_mutation_file
|
30
|
-
|
31
|
-
create_mutation_root_type
|
32
|
-
else
|
33
|
-
log :gsub, "#{options[:directory]}/types/mutation_type.rb"
|
34
|
-
end
|
35
|
-
|
30
|
+
create_mutation_root_type
|
36
31
|
template "mutation.erb", "#{options[:directory]}/mutations/#{file_name}.rb"
|
37
32
|
|
38
33
|
sentinel = /name "Mutation"\s*\n/m
|
@@ -1,7 +1,7 @@
|
|
1
|
-
class Functions::<%=
|
1
|
+
class Functions::<%= name %> < GraphQL::Function
|
2
2
|
# Define `initialize` to store field-level options, eg
|
3
3
|
#
|
4
|
-
# field :myField, function: Functions::<%=
|
4
|
+
# field :myField, function: Functions::<%= name %>.new(type: MyType)
|
5
5
|
#
|
6
6
|
# attr_reader :type
|
7
7
|
# def initialize(type:)
|
@@ -1,7 +1,7 @@
|
|
1
|
-
class Loaders::<%=
|
1
|
+
class Loaders::<%= name %> < GraphQL::Batch::Loader
|
2
2
|
# Define `initialize` to store grouping arguments, eg
|
3
3
|
#
|
4
|
-
# Loaders::<%=
|
4
|
+
# Loaders::<%= name %>.for(group).load(value)
|
5
5
|
#
|
6
6
|
# def initialize()
|
7
7
|
# end
|
data/lib/graphql.rb
CHANGED
data/lib/graphql/argument.rb
CHANGED
@@ -37,7 +37,6 @@ module GraphQL
|
|
37
37
|
include GraphQL::Define::InstanceDefinable
|
38
38
|
accepts_definitions :name, :type, :description, :default_value, :as, :prepare
|
39
39
|
attr_accessor :type, :description, :default_value, :name, :as
|
40
|
-
attr_accessor :ast_node
|
41
40
|
|
42
41
|
ensure_defined(:name, :description, :default_value, :type=, :type, :as, :expose_as, :prepare)
|
43
42
|
|
@@ -12,11 +12,10 @@ module GraphQL
|
|
12
12
|
# If `last`, then use the last arguments to call the function.
|
13
13
|
def wrap_arity(callable, from:, to:, name:, last: false)
|
14
14
|
arity = get_arity(callable)
|
15
|
-
|
16
|
-
when to
|
15
|
+
if arity == to || arity < 0
|
17
16
|
# It already matches, return it as is
|
18
17
|
callable
|
19
|
-
|
18
|
+
elsif arity == from
|
20
19
|
# It has the old arity, so wrap it with an arity converter
|
21
20
|
message ="#{name} with #{from} arguments is deprecated, it now accepts #{to} arguments, see:"
|
22
21
|
backtrace = caller(0, 20)
|
data/lib/graphql/base_type.rb
CHANGED
@@ -15,8 +15,6 @@ module GraphQL
|
|
15
15
|
|
16
16
|
ensure_defined(:name, :description, :introspection?, :default_scalar?)
|
17
17
|
|
18
|
-
attr_accessor :ast_node
|
19
|
-
|
20
18
|
def initialize
|
21
19
|
@introspection = false
|
22
20
|
@default_scalar = false
|
@@ -32,11 +30,12 @@ module GraphQL
|
|
32
30
|
|
33
31
|
# @return [String] the name of this type, must be unique within a Schema
|
34
32
|
attr_accessor :name
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
# Future-compatible alias
|
34
|
+
# @see {GraphQL::SchemaMember}
|
35
|
+
alias :graphql_name :name
|
36
|
+
# Future-compatible alias
|
37
|
+
# @see {GraphQL::SchemaMember}
|
38
|
+
alias :graphql_definition :itself
|
40
39
|
|
41
40
|
# @return [String, nil] a description for this type
|
42
41
|
attr_accessor :description
|
@@ -61,9 +60,12 @@ module GraphQL
|
|
61
60
|
|
62
61
|
# @param other [GraphQL::BaseType] compare to this object
|
63
62
|
# @return [Boolean] are these types equivalent? (incl. non-null, list)
|
64
|
-
# @see {ModifiesAnotherType#==} for override on List & NonNull types
|
65
63
|
def ==(other)
|
66
|
-
other.is_a?(GraphQL::BaseType)
|
64
|
+
if other.is_a?(GraphQL::BaseType)
|
65
|
+
self.to_s == other.to_s
|
66
|
+
else
|
67
|
+
super
|
68
|
+
end
|
67
69
|
end
|
68
70
|
|
69
71
|
# If this type is modifying an underlying type,
|
@@ -86,10 +88,6 @@ module GraphQL
|
|
86
88
|
def unwrap
|
87
89
|
self.of_type.unwrap
|
88
90
|
end
|
89
|
-
|
90
|
-
def ==(other)
|
91
|
-
other.is_a?(ModifiesAnotherType) && other.of_type == of_type
|
92
|
-
end
|
93
91
|
end
|
94
92
|
|
95
93
|
# Find out which possible type to use for `value`.
|
@@ -172,13 +170,17 @@ module GraphQL
|
|
172
170
|
def self.resolve_related_type(type_arg)
|
173
171
|
case type_arg
|
174
172
|
when Proc
|
175
|
-
# lazy-eval it
|
176
|
-
type_arg.call
|
173
|
+
# lazy-eval it, then try again
|
174
|
+
resolve_related_type(type_arg.call)
|
177
175
|
when String
|
178
176
|
# Get a constant by this name
|
179
177
|
Object.const_get(type_arg)
|
180
178
|
else
|
181
|
-
type_arg
|
179
|
+
if type_arg.respond_to?(:graphql_definition)
|
180
|
+
type_arg.graphql_definition
|
181
|
+
else
|
182
|
+
type_arg
|
183
|
+
end
|
182
184
|
end
|
183
185
|
end
|
184
186
|
|
@@ -67,10 +67,6 @@ module GraphQL
|
|
67
67
|
nullValue: null
|
68
68
|
nullValueInObject: {a: null, b: "b"}
|
69
69
|
nullValueInArray: ["a", null, "b"]
|
70
|
-
blockString: """
|
71
|
-
Hello,
|
72
|
-
World
|
73
|
-
"""
|
74
70
|
)
|
75
71
|
}
|
76
72
|
|
|
@@ -104,9 +100,6 @@ module GraphQL
|
|
104
100
|
assert_equal 'a', values[0]
|
105
101
|
assert_instance_of GraphQL::Language::Nodes::NullValue, values[1]
|
106
102
|
assert_equal 'b', values[2]
|
107
|
-
|
108
|
-
block_str_value = inputs[12].value
|
109
|
-
assert_equal "Hello,\n World", block_str_value
|
110
103
|
end
|
111
104
|
|
112
105
|
def test_it_doesnt_parse_nonsense_variables
|
@@ -123,116 +116,6 @@ module GraphQL
|
|
123
116
|
end
|
124
117
|
assert_equal [1,26], [err_2.line, err_2.col]
|
125
118
|
end
|
126
|
-
|
127
|
-
def test_enum_value_definitions_have_a_position
|
128
|
-
document = parse("""
|
129
|
-
enum Enum {
|
130
|
-
VALUE
|
131
|
-
}
|
132
|
-
""")
|
133
|
-
|
134
|
-
assert_equal [3, 17], document.definitions[0].values[0].position
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_field_definitions_have_a_position
|
138
|
-
document = parse("""
|
139
|
-
type A {
|
140
|
-
field: String
|
141
|
-
}
|
142
|
-
""")
|
143
|
-
|
144
|
-
assert_equal [3, 17], document.definitions[0].fields[0].position
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_input_value_definitions_have_a_position
|
148
|
-
document = parse("""
|
149
|
-
input A {
|
150
|
-
field: String
|
151
|
-
}
|
152
|
-
""")
|
153
|
-
|
154
|
-
assert_equal [3, 17], document.definitions[0].fields[0].position
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_parses_when_there_are_no_interfaces
|
158
|
-
schema = "
|
159
|
-
type A {
|
160
|
-
a: String
|
161
|
-
}
|
162
|
-
"
|
163
|
-
|
164
|
-
document = parse(schema)
|
165
|
-
|
166
|
-
assert_equal [], document.definitions[0].interfaces.map(&:name)
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_parses_implements_with_leading_ampersand
|
170
|
-
schema = "
|
171
|
-
type A implements & B {
|
172
|
-
a: String
|
173
|
-
}
|
174
|
-
"
|
175
|
-
|
176
|
-
document = parse(schema)
|
177
|
-
|
178
|
-
assert_equal ["B"], document.definitions[0].interfaces.map(&:name)
|
179
|
-
assert_equal [2, 35], document.definitions[0].interfaces[0].position
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_parses_implements_with_leading_ampersand_and_multiple_interfaces
|
183
|
-
schema = "
|
184
|
-
type A implements & B & C {
|
185
|
-
a: String
|
186
|
-
}
|
187
|
-
"
|
188
|
-
|
189
|
-
document = parse(schema)
|
190
|
-
|
191
|
-
assert_equal ["B", "C"], document.definitions[0].interfaces.map(&:name)
|
192
|
-
assert_equal [2, 35], document.definitions[0].interfaces[0].position
|
193
|
-
assert_equal [2, 39], document.definitions[0].interfaces[1].position
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_parses_implements_without_leading_ampersand
|
197
|
-
schema = "
|
198
|
-
type A implements B {
|
199
|
-
a: String
|
200
|
-
}
|
201
|
-
"
|
202
|
-
|
203
|
-
document = parse(schema)
|
204
|
-
|
205
|
-
assert_equal ["B"], document.definitions[0].interfaces.map(&:name)
|
206
|
-
assert_equal [2, 33], document.definitions[0].interfaces[0].position
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_parses_implements_without_leading_ampersand_and_multiple_interfaces
|
210
|
-
schema = "
|
211
|
-
type A implements B & C {
|
212
|
-
a: String
|
213
|
-
}
|
214
|
-
"
|
215
|
-
|
216
|
-
document = parse(schema)
|
217
|
-
|
218
|
-
assert_equal ["B", "C"], document.definitions[0].interfaces.map(&:name)
|
219
|
-
assert_equal [2, 33], document.definitions[0].interfaces[0].position
|
220
|
-
assert_equal [2, 37], document.definitions[0].interfaces[1].position
|
221
|
-
end
|
222
|
-
|
223
|
-
def test_supports_old_syntax_for_parsing_multiple_interfaces
|
224
|
-
schema = "
|
225
|
-
type A implements B, C {
|
226
|
-
a: String
|
227
|
-
}
|
228
|
-
"
|
229
|
-
|
230
|
-
document = parse(schema)
|
231
|
-
|
232
|
-
assert_equal ["B", "C"], document.definitions[0].interfaces.map(&:name)
|
233
|
-
assert_equal [2, 33], document.definitions[0].interfaces[0].position
|
234
|
-
assert_equal [2, 36], document.definitions[0].interfaces[1].position
|
235
|
-
end
|
236
119
|
end
|
237
120
|
end
|
238
121
|
|
@@ -56,20 +56,6 @@ module GraphQL
|
|
56
56
|
assert_raises_parse_error(%|{ field(arg:"\\uXXXF") }|)
|
57
57
|
end
|
58
58
|
|
59
|
-
def test_it_rejects_empty_inline_fragments
|
60
|
-
assert_raises_parse_error("
|
61
|
-
query {
|
62
|
-
viewer {
|
63
|
-
login {
|
64
|
-
... on String {
|
65
|
-
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
")
|
71
|
-
end
|
72
|
-
|
73
59
|
def assert_empty_document(query_string)
|
74
60
|
doc = parse(query_string)
|
75
61
|
assert_equal 0, doc.definitions.length
|
@@ -18,23 +18,16 @@ module GraphQL
|
|
18
18
|
base_field = if type_or_field.is_a?(GraphQL::Field)
|
19
19
|
type_or_field.redefine(name: name_s)
|
20
20
|
elsif function
|
21
|
-
GraphQL::
|
22
|
-
|
23
|
-
|
24
|
-
name: name_s,
|
25
|
-
type: function.type,
|
26
|
-
resolve: function,
|
27
|
-
description: function.description,
|
28
|
-
function: function,
|
29
|
-
deprecation_reason: function.deprecation_reason,
|
30
|
-
)
|
21
|
+
func_field = GraphQL::Function.build_field(function)
|
22
|
+
func_field.name = name_s
|
23
|
+
func_field
|
31
24
|
elsif field.is_a?(GraphQL::Field)
|
32
25
|
field.redefine(name: name_s)
|
33
26
|
else
|
34
27
|
nil
|
35
28
|
end
|
36
29
|
|
37
|
-
|
30
|
+
obj_field = if base_field
|
38
31
|
base_field.redefine(kwargs, &block)
|
39
32
|
else
|
40
33
|
GraphQL::Field.define(kwargs, &block)
|
@@ -42,7 +35,7 @@ module GraphQL
|
|
42
35
|
|
43
36
|
|
44
37
|
# Attach the field to the type
|
45
|
-
owner_type.fields[name_s] =
|
38
|
+
owner_type.fields[name_s] = obj_field
|
46
39
|
end
|
47
40
|
end
|
48
41
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module GraphQL
|
3
|
+
# There are two ways to apply the deprecated `!` DSL to class-style schema definitions:
|
4
|
+
#
|
5
|
+
# 1. Scoped by file (CRuby only), add to the top of the file:
|
6
|
+
#
|
7
|
+
# using GraphQL::DeprecatedDSL
|
8
|
+
#
|
9
|
+
# (This is a "refinement", there are also other ways to scope it.)
|
10
|
+
#
|
11
|
+
# 2. Global application, add before schema definition:
|
12
|
+
#
|
13
|
+
# GraphQL::DeprecatedDSL.activate
|
14
|
+
#
|
15
|
+
module DeprecatedDSL
|
16
|
+
def self.activate
|
17
|
+
GraphQL::Schema::Member.extend(Methods)
|
18
|
+
end
|
19
|
+
module Methods
|
20
|
+
def !
|
21
|
+
to_non_null_type
|
22
|
+
end
|
23
|
+
end
|
24
|
+
refine GraphQL::Schema::Member.singleton_class do
|
25
|
+
include Methods
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/graphql/directive.rb
CHANGED
@@ -11,7 +11,6 @@ module GraphQL
|
|
11
11
|
accepts_definitions :locations, :name, :description, :arguments, :default_directive, argument: GraphQL::Define::AssignArgument
|
12
12
|
|
13
13
|
attr_accessor :locations, :arguments, :name, :description, :arguments_class
|
14
|
-
attr_accessor :ast_node
|
15
14
|
# @api private
|
16
15
|
attr_writer :default_directive
|
17
16
|
ensure_defined(:locations, :arguments, :name, :description, :default_directive?)
|
data/lib/graphql/enum_type.rb
CHANGED
@@ -74,7 +74,6 @@ module GraphQL
|
|
74
74
|
class EnumType < GraphQL::BaseType
|
75
75
|
accepts_definitions :values, value: GraphQL::Define::AssignEnumValue
|
76
76
|
ensure_defined(:values, :validate_non_null_input, :coerce_non_null_input, :coerce_result)
|
77
|
-
attr_accessor :ast_node
|
78
77
|
|
79
78
|
def initialize
|
80
79
|
super
|
@@ -122,7 +121,7 @@ module GraphQL
|
|
122
121
|
if enum_value
|
123
122
|
enum_value.name
|
124
123
|
else
|
125
|
-
raise(UnresolvedValueError, "Can't resolve enum #{name} for #{value
|
124
|
+
raise(UnresolvedValueError, "Can't resolve enum #{name} for #{value}")
|
126
125
|
end
|
127
126
|
end
|
128
127
|
|
@@ -138,7 +137,6 @@ module GraphQL
|
|
138
137
|
ATTRIBUTES = [:name, :description, :deprecation_reason, :value]
|
139
138
|
accepts_definitions(*ATTRIBUTES)
|
140
139
|
attr_accessor(*ATTRIBUTES)
|
141
|
-
attr_accessor :ast_node
|
142
140
|
ensure_defined(*ATTRIBUTES)
|
143
141
|
|
144
142
|
def name=(new_name)
|
data/lib/graphql/execution.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
require "graphql/execution/directive_checks"
|
3
3
|
require "graphql/execution/execute"
|
4
4
|
require "graphql/execution/flatten"
|
5
|
-
require "graphql/execution/instrumentation"
|
6
5
|
require "graphql/execution/lazy"
|
7
6
|
require "graphql/execution/multiplex"
|
8
7
|
require "graphql/execution/typecast"
|
@@ -60,12 +60,12 @@ module GraphQL
|
|
60
60
|
if queries.length != 1
|
61
61
|
raise ArgumentError, "Multiplexing doesn't support custom execution strategies, run one query at a time instead"
|
62
62
|
else
|
63
|
-
|
63
|
+
with_instrumentation(multiplex, max_complexity: max_complexity) do
|
64
64
|
[run_one_legacy(schema, queries.first)]
|
65
65
|
end
|
66
66
|
end
|
67
67
|
else
|
68
|
-
|
68
|
+
with_instrumentation(multiplex, max_complexity: max_complexity) do
|
69
69
|
run_as_multiplex(multiplex)
|
70
70
|
end
|
71
71
|
end
|
@@ -93,7 +93,7 @@ module GraphQL
|
|
93
93
|
end
|
94
94
|
rescue StandardError
|
95
95
|
# Assign values here so that the query's `@executed` becomes true
|
96
|
-
queries.map { |q| q.result_values ||=
|
96
|
+
queries.map { |q| q.result_values ||= nil }
|
97
97
|
raise
|
98
98
|
end
|
99
99
|
|
@@ -162,17 +162,34 @@ module GraphQL
|
|
162
162
|
# Apply multiplex & query instrumentation to `queries`.
|
163
163
|
#
|
164
164
|
# It yields when the queries should be executed, then runs teardown.
|
165
|
-
def
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
165
|
+
def with_instrumentation(multiplex, max_complexity:)
|
166
|
+
schema = multiplex.schema
|
167
|
+
queries = multiplex.queries
|
168
|
+
query_instrumenters = schema.instrumenters[:query]
|
169
|
+
multiplex_instrumenters = schema.instrumenters[:multiplex]
|
170
|
+
|
171
|
+
# First, run multiplex instrumentation, then query instrumentation for each query
|
172
|
+
multiplex_instrumenters.each { |i| i.before_multiplex(multiplex) }
|
173
|
+
queries.each do |query|
|
174
|
+
query_instrumenters.each { |i| i.before_query(query) }
|
175
|
+
end
|
176
|
+
|
177
|
+
multiplex_analyzers = schema.multiplex_analyzers
|
178
|
+
if max_complexity
|
179
|
+
multiplex_analyzers += [GraphQL::Analysis::MaxQueryComplexity.new(max_complexity)]
|
180
|
+
end
|
181
|
+
|
182
|
+
GraphQL::Analysis.analyze_multiplex(multiplex, multiplex_analyzers)
|
172
183
|
|
173
|
-
|
174
|
-
|
184
|
+
# Let them be executed
|
185
|
+
yield
|
186
|
+
ensure
|
187
|
+
# Finally, run teardown instrumentation for each query + the multiplex
|
188
|
+
# Use `reverse_each` so instrumenters are treated like a stack
|
189
|
+
queries.each do |query|
|
190
|
+
query_instrumenters.reverse_each { |i| i.after_query(query) }
|
175
191
|
end
|
192
|
+
multiplex_instrumenters.reverse_each { |i| i.after_multiplex(multiplex) }
|
176
193
|
end
|
177
194
|
end
|
178
195
|
end
|