graphql 1.4.0 → 1.4.1

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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/introspection/schema_type.rb +3 -3
  3. data/lib/graphql/language/nodes.rb +1 -1
  4. data/lib/graphql/query.rb +39 -27
  5. data/lib/graphql/query/executor.rb +1 -1
  6. data/lib/graphql/query/variables.rb +21 -28
  7. data/lib/graphql/relay/connection_type.rb +2 -0
  8. data/lib/graphql/relay/relation_connection.rb +8 -2
  9. data/lib/graphql/schema.rb +3 -0
  10. data/lib/graphql/schema/warden.rb +9 -0
  11. data/lib/graphql/static_validation/rules/mutation_root_exists.rb +1 -1
  12. data/lib/graphql/static_validation/rules/subscription_root_exists.rb +1 -1
  13. data/lib/graphql/version.rb +1 -1
  14. data/spec/graphql/analysis/analyze_query_spec.rb +15 -15
  15. data/spec/graphql/analysis/field_usage_spec.rb +1 -1
  16. data/spec/graphql/analysis/max_query_complexity_spec.rb +8 -8
  17. data/spec/graphql/analysis/max_query_depth_spec.rb +7 -7
  18. data/spec/graphql/analysis/query_complexity_spec.rb +2 -2
  19. data/spec/graphql/analysis/query_depth_spec.rb +1 -1
  20. data/spec/graphql/base_type_spec.rb +19 -11
  21. data/spec/graphql/directive_spec.rb +1 -1
  22. data/spec/graphql/enum_type_spec.rb +2 -2
  23. data/spec/graphql/execution/typecast_spec.rb +19 -19
  24. data/spec/graphql/execution_error_spec.rb +1 -1
  25. data/spec/graphql/field_spec.rb +15 -7
  26. data/spec/graphql/id_type_spec.rb +1 -1
  27. data/spec/graphql/input_object_type_spec.rb +16 -16
  28. data/spec/graphql/interface_type_spec.rb +6 -6
  29. data/spec/graphql/internal_representation/rewrite_spec.rb +34 -34
  30. data/spec/graphql/introspection/directive_type_spec.rb +1 -1
  31. data/spec/graphql/introspection/input_value_type_spec.rb +2 -2
  32. data/spec/graphql/introspection/introspection_query_spec.rb +1 -1
  33. data/spec/graphql/introspection/schema_type_spec.rb +2 -2
  34. data/spec/graphql/introspection/type_type_spec.rb +1 -1
  35. data/spec/graphql/language/parser_spec.rb +1 -1
  36. data/spec/graphql/non_null_type_spec.rb +3 -3
  37. data/spec/graphql/object_type_spec.rb +8 -8
  38. data/spec/graphql/query/executor_spec.rb +4 -4
  39. data/spec/graphql/query/variables_spec.rb +20 -4
  40. data/spec/graphql/query_spec.rb +20 -2
  41. data/spec/graphql/relay/connection_type_spec.rb +1 -1
  42. data/spec/graphql/relay/mutation_spec.rb +9 -9
  43. data/spec/graphql/relay/node_spec.rb +8 -8
  44. data/spec/graphql/relay/relation_connection_spec.rb +24 -6
  45. data/spec/graphql/schema/catchall_middleware_spec.rb +3 -3
  46. data/spec/graphql/schema/reduce_types_spec.rb +9 -9
  47. data/spec/graphql/schema/type_expression_spec.rb +3 -3
  48. data/spec/graphql/schema/validation_spec.rb +1 -1
  49. data/spec/graphql/schema/warden_spec.rb +79 -0
  50. data/spec/graphql/schema_spec.rb +2 -2
  51. data/spec/graphql/static_validation/rules/fragments_are_used_spec.rb +1 -1
  52. data/spec/graphql/static_validation/type_stack_spec.rb +2 -2
  53. data/spec/graphql/static_validation/validator_spec.rb +2 -2
  54. data/spec/graphql/union_type_spec.rb +2 -2
  55. data/spec/spec_helper.rb +1 -1
  56. data/spec/support/dummy/data.rb +27 -0
  57. data/spec/support/dummy/schema.rb +369 -0
  58. data/spec/support/star_wars/data.rb +81 -0
  59. data/spec/support/star_wars/schema.rb +250 -0
  60. data/spec/support/static_validation_helpers.rb +2 -2
  61. metadata +10 -10
  62. data/spec/support/dairy_app.rb +0 -369
  63. data/spec/support/dairy_data.rb +0 -26
  64. data/spec/support/star_wars_data.rb +0 -80
  65. data/spec/support/star_wars_schema.rb +0 -242
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54eddb1e7e7ebdbe1ada0ab8286bda07a4141ebc
4
- data.tar.gz: d9cc5078d078b0d9d8eded46a17ae224d33b738c
3
+ metadata.gz: 5e3922b4ba691948512f6936a9ebf5438e468698
4
+ data.tar.gz: 9162e5e2f437fc323e733a7682dd44dae9bb8cc8
5
5
  SHA512:
6
- metadata.gz: f918ba8ec64d8e3157d454ef76002b4087644fcb1f92a50821f5fd189f40806b4daec24d27049c022a59c27dc9a698742ad099546ce53b20645a7e0f6ebd8c28
7
- data.tar.gz: 21140eaea9b18fd8405cb195f67d8f380d08dbf7d537e191c4672bd65240b1f589074927e0a62951f6506eaf0762efcd351e35b0e7951c4012b3552d70b747e0
6
+ metadata.gz: 1c3763c608645843eaffaa81d95e29d019008209b1af2f91a06d35431403114a4b60feebfec3e7659db45b05695e7a4ce3c67012f573ca4e4283ecc12a2186c3
7
+ data.tar.gz: 08e82e3316840ebaeeb63aee2e73d8909ae863634c00d6eec38e03ba8a2a2038239f1e4ef694af70f952599aafc6d6bd3f1623741ebb0b7d61e3d8f43765c21e
@@ -10,15 +10,15 @@ GraphQL::Introspection::SchemaType = GraphQL::ObjectType.define do
10
10
  end
11
11
 
12
12
  field :queryType, !GraphQL::Introspection::TypeType, "The type that query operations will be rooted at." do
13
- resolve ->(obj, arg, ctx) { obj.query }
13
+ resolve ->(obj, arg, ctx) { ctx.warden.root_type_for_operation("query") }
14
14
  end
15
15
 
16
16
  field :mutationType, GraphQL::Introspection::TypeType, "If this server supports mutation, the type that mutation operations will be rooted at." do
17
- resolve ->(obj, arg, ctx) { obj.mutation }
17
+ resolve ->(obj, arg, ctx) { ctx.warden.root_type_for_operation("mutation") }
18
18
  end
19
19
 
20
20
  field :subscriptionType, GraphQL::Introspection::TypeType, "If this server support subscription, the type that subscription operations will be rooted at." do
21
- resolve ->(obj, arg, ctx) { obj.subscription }
21
+ resolve ->(obj, arg, ctx) { ctx.warden.root_type_for_operation("subscription") }
22
22
  end
23
23
 
24
24
  field :directives, !types[!GraphQL::Introspection::DirectiveType], "A list of all directives supported by this server." do
@@ -319,7 +319,7 @@ module GraphQL
319
319
  scalar_attributes :name, :type, :default_value
320
320
 
321
321
  # @!attribute default_value
322
- # @return [String, Integer, Float, Boolean, Array] A Ruby value to use if no other value is provided
322
+ # @return [String, Integer, Float, Boolean, Array, NullValue] A Ruby value to use if no other value is provided
323
323
 
324
324
  # @!attribute type
325
325
  # @return [TypeName, NonNullType, ListType] The expected type of this value
data/lib/graphql/query.rb CHANGED
@@ -11,6 +11,8 @@ require "graphql/query/variable_validation_error"
11
11
  module GraphQL
12
12
  # A combination of query string and {Schema} instance which can be reduced to a {#result}.
13
13
  class Query
14
+ extend Forwardable
15
+
14
16
  class OperationNameMissingError < GraphQL::ExecutionError
15
17
  def initialize(names)
16
18
  msg = "You must provide an operation name from: #{names.join(", ")}"
@@ -34,13 +36,7 @@ module GraphQL
34
36
  fail ArgumentError, "a query string or document is required" unless query_string || document
35
37
 
36
38
  @schema = schema
37
- mask = if except
38
- wrap_if_legacy_mask(except)
39
- elsif only
40
- InvertedMask.new(wrap_if_legacy_mask(only))
41
- else
42
- schema.default_mask
43
- end
39
+ mask = MergedMask.combine(schema.default_mask, except: except, only: only)
44
40
  @context = Context.new(query: self, values: context)
45
41
  @warden = GraphQL::Schema::Warden.new(mask, schema: @schema, context: @context)
46
42
  @max_depth = max_depth || schema.max_depth
@@ -202,18 +198,8 @@ module GraphQL
202
198
  @valid
203
199
  end
204
200
 
205
- def get_type(type_name)
206
- @warden.get_type(type_name)
207
- end
201
+ def_delegators :@warden, :get_type, :get_field, :possible_types, :root_type_for_operation
208
202
 
209
- def get_field(type, name)
210
- @fields ||= Hash.new { |h, k| h[k] = Hash.new { |h2, k2| h2[k2] = @warden.get_field(k, k2) } }
211
- @fields[type][name]
212
- end
213
-
214
- def possible_types(type)
215
- @warden.possible_types(type)
216
- end
217
203
 
218
204
  # @param value [Object] Any runtime value
219
205
  # @return [GraphQL::ObjectType, nil] The runtime type of `value` from {Schema#resolve_type}
@@ -262,15 +248,6 @@ module GraphQL
262
248
  end
263
249
  end
264
250
 
265
- def wrap_if_legacy_mask(mask)
266
- if (mask.is_a?(Proc) && mask.arity == 1) || mask.method(:call).arity == 1
267
- warn("Schema.execute(..., except:) filters now accept two arguments, `(member, ctx)`. One-argument filters are deprecated.")
268
- LegacyMaskWrap.new(mask)
269
- else
270
- mask
271
- end
272
- end
273
-
274
251
  # @api private
275
252
  class InvertedMask
276
253
  def initialize(inner_mask)
@@ -294,5 +271,40 @@ module GraphQL
294
271
  @inner_mask.call(member)
295
272
  end
296
273
  end
274
+
275
+ # @api private
276
+ class MergedMask
277
+ def initialize(first_mask, second_mask)
278
+ @first_mask = first_mask
279
+ @second_mask = second_mask
280
+ end
281
+
282
+ def call(member, ctx)
283
+ @first_mask.call(member, ctx) || @second_mask.call(member, ctx)
284
+ end
285
+
286
+ def self.combine(default_mask, except:, only:)
287
+ query_mask = if except
288
+ wrap_if_legacy_mask(except)
289
+ elsif only
290
+ InvertedMask.new(wrap_if_legacy_mask(only))
291
+ end
292
+
293
+ if query_mask && (default_mask != GraphQL::Schema::NullMask)
294
+ self.new(default_mask, query_mask)
295
+ else
296
+ query_mask || default_mask
297
+ end
298
+ end
299
+
300
+ def self.wrap_if_legacy_mask(mask)
301
+ if (mask.is_a?(Proc) && mask.arity == 1) || mask.method(:call).arity == 1
302
+ warn("Schema.execute(..., except:) filters now accept two arguments, `(member, ctx)`. One-argument filters are deprecated.")
303
+ LegacyMaskWrap.new(mask)
304
+ else
305
+ mask
306
+ end
307
+ end
308
+ end
297
309
  end
298
310
  end
@@ -28,7 +28,7 @@ module GraphQL
28
28
  return {} if operation.nil?
29
29
 
30
30
  op_type = operation.operation_type
31
- root_type = query.schema.root_type_for_operation(op_type)
31
+ root_type = query.root_type_for_operation(op_type)
32
32
  execution_strategy_class = query.schema.execution_strategy_for_operation(op_type)
33
33
  execution_strategy = execution_strategy_class.new
34
34
 
@@ -14,38 +14,31 @@ module GraphQL
14
14
  @provided_variables = provided_variables
15
15
  @errors = []
16
16
  @storage = ast_variables.each_with_object({}) do |ast_variable, memo|
17
+ # Find the right value for this variable:
18
+ # - First, use the value provided at runtime
19
+ # - Then, fall back to the default value from the query string
20
+ # If it's still nil, raise an error if it's required.
21
+ variable_type = @schema.type_from_ast(ast_variable.type)
17
22
  variable_name = ast_variable.name
18
- memo[variable_name] = get_graphql_value(ast_variable)
19
- end
20
- end
21
-
22
- def [](key)
23
- @storage.fetch(key)
24
- end
23
+ default_value = ast_variable.default_value
24
+ provided_value = @provided_variables[variable_name]
25
+ value_was_provided = @provided_variables.key?(variable_name)
25
26
 
26
- def_delegators :@storage, :length
27
-
28
- private
29
-
30
- # Find the right value for this variable:
31
- # - First, use the value provided at runtime
32
- # - Then, fall back to the default value from the query string
33
- # If it's still nil, raise an error if it's required.
34
- def get_graphql_value(ast_variable)
35
- variable_type = @schema.type_from_ast(ast_variable.type)
36
- variable_name = ast_variable.name
37
- default_value = ast_variable.default_value
38
- provided_value = @provided_variables[variable_name]
39
-
40
- validation_result = variable_type.validate_input(provided_value, @warden)
41
- if !validation_result.valid?
42
- @errors << GraphQL::Query::VariableValidationError.new(ast_variable, variable_type, provided_value, validation_result)
43
- elsif !@provided_variables.key?(variable_name) && provided_value.nil?
44
- GraphQL::Query::LiteralInput.coerce(variable_type, default_value, {})
45
- else
46
- variable_type.coerce_input(provided_value)
27
+ validation_result = variable_type.validate_input(provided_value, @warden)
28
+ if !validation_result.valid?
29
+ # This finds variables that were required but not provided
30
+ @errors << GraphQL::Query::VariableValidationError.new(ast_variable, variable_type, provided_value, validation_result)
31
+ elsif value_was_provided
32
+ # Add the variable if a value was provided
33
+ memo[variable_name] = variable_type.coerce_input(provided_value)
34
+ elsif default_value
35
+ # Add the variable if it wasn't provided but it has a default value (including `null`)
36
+ memo[variable_name] = GraphQL::Query::LiteralInput.coerce(variable_type, default_value, {})
37
+ end
47
38
  end
48
39
  end
40
+
41
+ def_delegators :@storage, :length, :key?, :[], :fetch
49
42
  end
50
43
  end
51
44
  end
@@ -13,9 +13,11 @@ module GraphQL
13
13
  edge_type ||= wrapped_type.edge_type
14
14
  edge_class ||= GraphQL::Relay::Edge
15
15
  connection_type_name = "#{wrapped_type.name}Connection"
16
+ connection_type_description = "The connection type for #{wrapped_type.name}."
16
17
 
17
18
  connection_type = ObjectType.define do
18
19
  name(connection_type_name)
20
+ description(connection_type_description)
19
21
  field :edges, types[edge_type] do
20
22
  description "A list of edges."
21
23
  resolve ->(obj, args, ctx) {
@@ -17,7 +17,7 @@ module GraphQL
17
17
  end
18
18
 
19
19
  def has_next_page
20
- !!(first && sliced_nodes.limit(limit + 1).count > limit)
20
+ !!(first && count(sliced_nodes.limit(limit + 1)) > limit)
21
21
  end
22
22
 
23
23
  def has_previous_page
@@ -26,6 +26,12 @@ module GraphQL
26
26
 
27
27
  private
28
28
 
29
+ # If a relation contains a `.group` clause, a `.count` will return a Hash.
30
+ def count(nodes)
31
+ count_or_hash = nodes.count
32
+ count_or_hash.is_a?(Integer) ? count_or_hash : count_or_hash.length
33
+ end
34
+
29
35
  # apply first / last limit results
30
36
  def paged_nodes
31
37
  @paged_nodes ||= sliced_nodes.limit(limit)
@@ -45,7 +51,7 @@ module GraphQL
45
51
  if before
46
52
  [previous_offset, 0].max
47
53
  elsif last
48
- nodes.count - last
54
+ count(nodes) - last
49
55
  else
50
56
  previous_offset
51
57
  end
@@ -215,6 +215,9 @@ module GraphQL
215
215
  @possible_types.possible_types(type_defn)
216
216
  end
217
217
 
218
+
219
+ # @see [GraphQL::Schema::Warden] Resticted access to root types
220
+ # @return [GraphQL::ObjectType, nil]
218
221
  def root_type_for_operation(operation)
219
222
  case operation
220
223
  when "query"
@@ -120,6 +120,15 @@ module GraphQL
120
120
  @schema.directives.each_value.select { |d| visible?(d) }
121
121
  end
122
122
 
123
+ def root_type_for_operation(op_name)
124
+ root_type = @schema.root_type_for_operation(op_name)
125
+ if root_type && visible?(root_type)
126
+ root_type
127
+ else
128
+ nil
129
+ end
130
+ end
131
+
123
132
  private
124
133
 
125
134
  def visible_field?(field_defn)
@@ -5,7 +5,7 @@ module GraphQL
5
5
  include GraphQL::StaticValidation::Message::MessageHelper
6
6
 
7
7
  def validate(context)
8
- return if context.schema.mutation
8
+ return if context.warden.root_type_for_operation("mutation")
9
9
 
10
10
  visitor = context.visitor
11
11
 
@@ -5,7 +5,7 @@ module GraphQL
5
5
  include GraphQL::StaticValidation::Message::MessageHelper
6
6
 
7
7
  def validate(context)
8
- return if context.schema.subscription
8
+ return if context.warden.root_type_for_operation("subscription")
9
9
 
10
10
  visitor = context.visitor
11
11
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.4.0"
3
+ VERSION = "1.4.1"
4
4
  end
@@ -28,7 +28,7 @@ describe GraphQL::Analysis do
28
28
  let(:analyzers) { [type_collector, node_counter] }
29
29
  let(:reduce_result) { GraphQL::Analysis.analyze_query(query, analyzers) }
30
30
  let(:variables) { {} }
31
- let(:query) { GraphQL::Query.new(DummySchema, query_string, variables: variables) }
31
+ let(:query) { GraphQL::Query.new(Dummy::Schema, query_string, variables: variables) }
32
32
  let(:query_string) {%|
33
33
  {
34
34
  cheese(id: 1) {
@@ -40,7 +40,7 @@ describe GraphQL::Analysis do
40
40
 
41
41
  it "calls the defined analyzers" do
42
42
  collected_types, node_counts = reduce_result
43
- expected_visited_types = [DairyAppQueryType, CheeseType, GraphQL::INT_TYPE, GraphQL::STRING_TYPE]
43
+ expected_visited_types = [Dummy::DairyAppQueryType, Dummy::CheeseType, GraphQL::INT_TYPE, GraphQL::STRING_TYPE]
44
44
  assert_equal expected_visited_types, collected_types
45
45
  expected_node_counts = {
46
46
  GraphQL::Language::Nodes::OperationDefinition => 1,
@@ -61,14 +61,14 @@ describe GraphQL::Analysis do
61
61
  let(:variable_accessor) { ->(memo, visit_type, irep_node) { query.variables["cheeseId"] } }
62
62
 
63
63
  before do
64
- @previous_query_analyzers = DummySchema.query_analyzers.dup
65
- DummySchema.query_analyzers.clear
66
- DummySchema.query_analyzers << variable_accessor
64
+ @previous_query_analyzers = Dummy::Schema.query_analyzers.dup
65
+ Dummy::Schema.query_analyzers.clear
66
+ Dummy::Schema.query_analyzers << variable_accessor
67
67
  end
68
68
 
69
69
  after do
70
- DummySchema.query_analyzers.clear
71
- DummySchema.query_analyzers.push(*@previous_query_analyzers)
70
+ Dummy::Schema.query_analyzers.clear
71
+ Dummy::Schema.query_analyzers.push(*@previous_query_analyzers)
72
72
  end
73
73
 
74
74
  it "returns an error" do
@@ -97,7 +97,7 @@ describe GraphQL::Analysis do
97
97
  }
98
98
  let(:analyzers) { [connection_counter] }
99
99
  let(:reduce_result) { GraphQL::Analysis.analyze_query(query, analyzers) }
100
- let(:query) { GraphQL::Query.new(StarWarsSchema, query_string, variables: variables) }
100
+ let(:query) { GraphQL::Query.new(StarWars::Schema, query_string, variables: variables) }
101
101
  let(:query_string) {%|
102
102
  query getBases {
103
103
  empire {
@@ -155,7 +155,7 @@ describe GraphQL::Analysis do
155
155
  let(:flavor_catcher) { FlavorCatcher.new }
156
156
  let(:analyzers) { [id_catcher, flavor_catcher] }
157
157
  let(:reduce_result) { GraphQL::Analysis.analyze_query(query, analyzers) }
158
- let(:query) { GraphQL::Query.new(DummySchema, query_string) }
158
+ let(:query) { GraphQL::Query.new(Dummy::Schema, query_string) }
159
159
  let(:query_string) {%|
160
160
  {
161
161
  cheese(id: 1) {
@@ -164,7 +164,7 @@ describe GraphQL::Analysis do
164
164
  }
165
165
  }
166
166
  |}
167
- let(:schema) { DummySchema }
167
+ let(:schema) { Dummy::Schema }
168
168
  let(:result) { schema.execute(query_string) }
169
169
  let(:query_string) {%|
170
170
  {
@@ -176,14 +176,14 @@ describe GraphQL::Analysis do
176
176
  |}
177
177
 
178
178
  before do
179
- @previous_query_analyzers = DummySchema.query_analyzers.dup
180
- DummySchema.query_analyzers.clear
181
- DummySchema.query_analyzers << id_catcher << flavor_catcher
179
+ @previous_query_analyzers = Dummy::Schema.query_analyzers.dup
180
+ Dummy::Schema.query_analyzers.clear
181
+ Dummy::Schema.query_analyzers << id_catcher << flavor_catcher
182
182
  end
183
183
 
184
184
  after do
185
- DummySchema.query_analyzers.clear
186
- DummySchema.query_analyzers.push(*@previous_query_analyzers)
185
+ Dummy::Schema.query_analyzers.clear
186
+ Dummy::Schema.query_analyzers.push(*@previous_query_analyzers)
187
187
  end
188
188
 
189
189
  it "groups all errors together" do
@@ -5,7 +5,7 @@ describe GraphQL::Analysis::FieldUsage do
5
5
  let(:result) { [] }
6
6
  let(:field_usage_analyzer) { GraphQL::Analysis::FieldUsage.new { |query, used_fields, used_deprecated_fields| result << query << used_fields << used_deprecated_fields } }
7
7
  let(:reduce_result) { GraphQL::Analysis.analyze_query(query, [field_usage_analyzer]) }
8
- let(:query) { GraphQL::Query.new(DummySchema, query_string, variables: variables) }
8
+ let(:query) { GraphQL::Query.new(Dummy::Schema, query_string, variables: variables) }
9
9
  let(:variables) { {} }
10
10
 
11
11
  describe "query with deprecated fields" do
@@ -3,15 +3,15 @@ require "spec_helper"
3
3
 
4
4
  describe GraphQL::Analysis::MaxQueryComplexity do
5
5
  before do
6
- @prev_max_complexity = DummySchema.max_complexity
6
+ @prev_max_complexity = Dummy::Schema.max_complexity
7
7
  end
8
8
 
9
9
  after do
10
- DummySchema.max_complexity = @prev_max_complexity
10
+ Dummy::Schema.max_complexity = @prev_max_complexity
11
11
  end
12
12
 
13
13
 
14
- let(:result) { DummySchema.execute(query_string) }
14
+ let(:result) { Dummy::Schema.execute(query_string) }
15
15
  let(:query_string) {%|
16
16
  {
17
17
  a: cheese(id: 1) { id }
@@ -24,7 +24,7 @@ describe GraphQL::Analysis::MaxQueryComplexity do
24
24
 
25
25
  describe "when a query goes over max complexity" do
26
26
  before do
27
- DummySchema.max_complexity = 9
27
+ Dummy::Schema.max_complexity = 9
28
28
  end
29
29
 
30
30
  it "returns an error" do
@@ -34,7 +34,7 @@ describe GraphQL::Analysis::MaxQueryComplexity do
34
34
 
35
35
  describe "when there is no max complexity" do
36
36
  before do
37
- DummySchema.max_complexity = nil
37
+ Dummy::Schema.max_complexity = nil
38
38
  end
39
39
  it "doesn't error" do
40
40
  assert_equal nil, result["errors"]
@@ -43,7 +43,7 @@ describe GraphQL::Analysis::MaxQueryComplexity do
43
43
 
44
44
  describe "when the query is less than the max complexity" do
45
45
  before do
46
- DummySchema.max_complexity = 99
46
+ Dummy::Schema.max_complexity = 99
47
47
  end
48
48
  it "doesn't error" do
49
49
  assert_equal nil, result["errors"]
@@ -52,9 +52,9 @@ describe GraphQL::Analysis::MaxQueryComplexity do
52
52
 
53
53
  describe "when complexity is overriden at query-level" do
54
54
  before do
55
- DummySchema.max_complexity = 100
55
+ Dummy::Schema.max_complexity = 100
56
56
  end
57
- let(:result) { DummySchema.execute(query_string, max_complexity: 7) }
57
+ let(:result) { Dummy::Schema.execute(query_string, max_complexity: 7) }
58
58
 
59
59
  it "is applied" do
60
60
  assert_equal "Query has complexity of 10, which exceeds max complexity of 7", result["errors"][0]["message"]