graphql 1.9.21 → 1.10.0.pre1

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 (125) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/core.rb +0 -1
  3. data/lib/generators/graphql/install_generator.rb +0 -1
  4. data/lib/generators/graphql/mutation_generator.rb +1 -1
  5. data/lib/generators/graphql/templates/base_field.erb +4 -0
  6. data/lib/generators/graphql/templates/graphql_controller.erb +0 -5
  7. data/lib/generators/graphql/templates/mutation.erb +1 -1
  8. data/lib/generators/graphql/templates/schema.erb +1 -1
  9. data/lib/graphql.rb +1 -11
  10. data/lib/graphql/analysis/ast.rb +2 -2
  11. data/lib/graphql/analysis/ast/analyzer.rb +4 -23
  12. data/lib/graphql/analysis/ast/max_query_complexity.rb +3 -3
  13. data/lib/graphql/analysis/ast/max_query_depth.rb +3 -7
  14. data/lib/graphql/analysis/ast/query_complexity.rb +2 -2
  15. data/lib/graphql/argument.rb +6 -2
  16. data/lib/graphql/backtrace/table.rb +10 -2
  17. data/lib/graphql/base_type.rb +5 -1
  18. data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +5 -9
  19. data/lib/graphql/define/assign_object_field.rb +2 -2
  20. data/lib/graphql/define/defined_object_proxy.rb +0 -3
  21. data/lib/graphql/define/instance_definable.rb +3 -14
  22. data/lib/graphql/enum_type.rb +4 -0
  23. data/lib/graphql/execution/directive_checks.rb +2 -2
  24. data/lib/graphql/execution/errors.rb +14 -15
  25. data/lib/graphql/execution/execute.rb +1 -1
  26. data/lib/graphql/execution/interpreter/runtime.rb +17 -39
  27. data/lib/graphql/execution/multiplex.rb +3 -3
  28. data/lib/graphql/field.rb +8 -0
  29. data/lib/graphql/filter.rb +1 -1
  30. data/lib/graphql/function.rb +1 -1
  31. data/lib/graphql/input_object_type.rb +1 -2
  32. data/lib/graphql/introspection/entry_points.rb +1 -2
  33. data/lib/graphql/introspection/input_value_type.rb +27 -9
  34. data/lib/graphql/introspection/schema_type.rb +1 -2
  35. data/lib/graphql/language/block_string.rb +2 -2
  36. data/lib/graphql/language/document_from_schema_definition.rb +5 -11
  37. data/lib/graphql/language/lexer.rb +48 -49
  38. data/lib/graphql/language/lexer.rl +48 -49
  39. data/lib/graphql/language/nodes.rb +11 -14
  40. data/lib/graphql/language/parser.rb +645 -650
  41. data/lib/graphql/language/parser.y +7 -8
  42. data/lib/graphql/language/token.rb +1 -1
  43. data/lib/graphql/non_null_type.rb +0 -10
  44. data/lib/graphql/pagination.rb +6 -0
  45. data/lib/graphql/pagination/active_record_relation_connection.rb +35 -0
  46. data/lib/graphql/pagination/array_connection.rb +78 -0
  47. data/lib/graphql/pagination/connection.rb +150 -0
  48. data/lib/graphql/pagination/connections.rb +103 -0
  49. data/lib/graphql/pagination/mongoid_relation_connection.rb +25 -0
  50. data/lib/graphql/pagination/relation_connection.rb +157 -0
  51. data/lib/graphql/pagination/sequel_dataset_connection.rb +28 -0
  52. data/lib/graphql/query.rb +1 -7
  53. data/lib/graphql/query/arguments.rb +3 -9
  54. data/lib/graphql/query/context.rb +9 -31
  55. data/lib/graphql/query/literal_input.rb +29 -10
  56. data/lib/graphql/query/null_context.rb +0 -4
  57. data/lib/graphql/query/variable_validation_error.rb +1 -1
  58. data/lib/graphql/query/variables.rb +2 -4
  59. data/lib/graphql/relay/base_connection.rb +7 -3
  60. data/lib/graphql/relay/edges_instrumentation.rb +1 -1
  61. data/lib/graphql/relay/node.rb +2 -2
  62. data/lib/graphql/relay/relation_connection.rb +5 -9
  63. data/lib/graphql/schema.rb +27 -68
  64. data/lib/graphql/schema/argument.rb +31 -5
  65. data/lib/graphql/schema/base_64_bp.rb +2 -3
  66. data/lib/graphql/schema/build_from_definition.rb +113 -179
  67. data/lib/graphql/schema/build_from_definition/resolve_map.rb +10 -4
  68. data/lib/graphql/schema/build_from_definition/resolve_map/default_resolve.rb +1 -1
  69. data/lib/graphql/schema/directive.rb +6 -7
  70. data/lib/graphql/schema/directive/feature.rb +1 -1
  71. data/lib/graphql/schema/enum.rb +1 -0
  72. data/lib/graphql/schema/enum_value.rb +4 -1
  73. data/lib/graphql/schema/field.rb +37 -39
  74. data/lib/graphql/schema/field/connection_extension.rb +11 -1
  75. data/lib/graphql/schema/input_object.rb +2 -5
  76. data/lib/graphql/schema/interface.rb +2 -0
  77. data/lib/graphql/schema/introspection_system.rb +1 -4
  78. data/lib/graphql/schema/loader.rb +6 -12
  79. data/lib/graphql/schema/member.rb +2 -0
  80. data/lib/graphql/schema/member/base_dsl_methods.rb +2 -2
  81. data/lib/graphql/schema/member/build_type.rb +4 -0
  82. data/lib/graphql/schema/member/cached_graphql_definition.rb +5 -0
  83. data/lib/graphql/schema/member/has_ast_node.rb +17 -0
  84. data/lib/graphql/schema/member/has_fields.rb +10 -16
  85. data/lib/graphql/schema/member/instrumentation.rb +1 -6
  86. data/lib/graphql/schema/member/type_system_helpers.rb +1 -1
  87. data/lib/graphql/schema/mutation.rb +1 -1
  88. data/lib/graphql/schema/object.rb +5 -6
  89. data/lib/graphql/schema/possible_types.rb +3 -3
  90. data/lib/graphql/schema/printer.rb +1 -3
  91. data/lib/graphql/schema/relay_classic_mutation.rb +2 -6
  92. data/lib/graphql/schema/resolver.rb +5 -35
  93. data/lib/graphql/schema/scalar.rb +1 -0
  94. data/lib/graphql/schema/subscription.rb +6 -6
  95. data/lib/graphql/schema/timeout_middleware.rb +2 -3
  96. data/lib/graphql/schema/type_expression.rb +27 -17
  97. data/lib/graphql/schema/union.rb +7 -26
  98. data/lib/graphql/schema/validation.rb +1 -17
  99. data/lib/graphql/schema/warden.rb +3 -77
  100. data/lib/graphql/schema/wrapper.rb +1 -1
  101. data/lib/graphql/static_validation/definition_dependencies.rb +12 -21
  102. data/lib/graphql/static_validation/rules/argument_literals_are_compatible.rb +9 -4
  103. data/lib/graphql/static_validation/rules/arguments_are_defined.rb +10 -7
  104. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +1 -1
  105. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +5 -5
  106. data/lib/graphql/static_validation/rules/fields_will_merge.rb +4 -4
  107. data/lib/graphql/static_validation/rules/required_input_object_attributes_are_present.rb +3 -3
  108. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +3 -3
  109. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +5 -6
  110. data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
  111. data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +1 -1
  112. data/lib/graphql/subscriptions.rb +7 -7
  113. data/lib/graphql/subscriptions/action_cable_subscriptions.rb +2 -2
  114. data/lib/graphql/subscriptions/event.rb +5 -19
  115. data/lib/graphql/subscriptions/instrumentation.rb +9 -4
  116. data/lib/graphql/subscriptions/subscription_root.rb +2 -10
  117. data/lib/graphql/tracing/skylight_tracing.rb +0 -1
  118. data/lib/graphql/types/int.rb +1 -1
  119. data/lib/graphql/types/relay/base_connection.rb +3 -1
  120. data/lib/graphql/union_type.rb +23 -58
  121. data/lib/graphql/upgrader/member.rb +1 -1
  122. data/lib/graphql/version.rb +1 -1
  123. metadata +20 -13
  124. data/lib/generators/graphql/templates/base_mutation.erb +0 -8
  125. data/lib/graphql/schema/type_membership.rb +0 -34
@@ -1,7 +1,4 @@
1
1
  # frozen_string_literal: true
2
-
3
- require 'set'
4
-
5
2
  module GraphQL
6
3
  class Schema
7
4
  # Restrict access to a {GraphQL::Schema} with a user-defined filter.
@@ -43,8 +40,7 @@ module GraphQL
43
40
  # @param deep_check [Boolean]
44
41
  def initialize(filter, context:, schema:)
45
42
  @schema = schema
46
- @context = context
47
- @visibility_cache = read_through { |m| filter.call(m, @context) }
43
+ @visibility_cache = read_through { |m| filter.call(m, context) }
48
44
  end
49
45
 
50
46
  # @return [Array<GraphQL::BaseType>] Visible types in the schema
@@ -66,17 +62,6 @@ module GraphQL
66
62
  @visible_types[type_name]
67
63
  end
68
64
 
69
- # @return [Array<GraphQL::BaseType>] Visible and reachable types in the schema
70
- def reachable_types
71
- @reachable_types ||= reachable_type_set.to_a
72
- end
73
-
74
- # @return Boolean True if the type is visible and reachable in the schema
75
- def reachable_type?(type_name)
76
- type = get_type(type_name)
77
- type && reachable_type_set.include?(type)
78
- end
79
-
80
65
  # @return [GraphQL::Field, nil] The field named `field_name` on `parent_type`, if it exists
81
66
  def get_field(parent_type, field_name)
82
67
 
@@ -96,7 +81,7 @@ module GraphQL
96
81
 
97
82
  # @return [Array<GraphQL::BaseType>] The types which may be member of `type_defn`
98
83
  def possible_types(type_defn)
99
- @visible_possible_types ||= read_through { |type_defn| @schema.possible_types(type_defn, @context).select { |t| visible_type?(t) } }
84
+ @visible_possible_types ||= read_through { |type_defn| @schema.possible_types(type_defn).select { |t| visible_type?(t) } }
100
85
  @visible_possible_types[type_defn]
101
86
  end
102
87
 
@@ -185,7 +170,7 @@ module GraphQL
185
170
  end
186
171
 
187
172
  def visible_possible_types?(type_defn)
188
- @schema.possible_types(type_defn, @context).any? { |t| visible_type?(t) }
173
+ @schema.possible_types(type_defn).any? { |t| visible_type?(t) }
189
174
  end
190
175
 
191
176
  def visible?(member)
@@ -195,65 +180,6 @@ module GraphQL
195
180
  def read_through
196
181
  Hash.new { |h, k| h[k] = yield(k) }
197
182
  end
198
-
199
- def reachable_type_set
200
- return @reachable_type_set if defined?(@reachable_type_set)
201
-
202
- @reachable_type_set = Set.new
203
-
204
- unvisited_types = []
205
- ['query', 'mutation', 'subscription'].each do |op_name|
206
- root_type = root_type_for_operation(op_name)
207
- unvisited_types << root_type if root_type
208
- end
209
- unvisited_types.concat(@schema.introspection_system.object_types)
210
- @schema.orphan_types.each do |orphan_type|
211
- unvisited_types << orphan_type.graphql_definition if get_type(orphan_type.graphql_name)
212
- end
213
-
214
- until unvisited_types.empty?
215
- type = unvisited_types.pop
216
- if @reachable_type_set.add?(type)
217
- if type.kind.input_object?
218
- # recurse into visible arguments
219
- arguments(type).each do |argument|
220
- argument_type = argument.type.unwrap
221
- unvisited_types << argument_type
222
- end
223
- elsif type.kind.union?
224
- # recurse into visible possible types
225
- possible_types(type).each do |possible_type|
226
- unvisited_types << possible_type
227
- end
228
- elsif type.kind.fields?
229
- if type.kind.interface?
230
- # recurse into visible possible types
231
- possible_types(type).each do |possible_type|
232
- unvisited_types << possible_type
233
- end
234
- elsif type.kind.object?
235
- # recurse into visible implemented interfaces
236
- interfaces(type).each do |interface|
237
- unvisited_types << interface
238
- end
239
- end
240
-
241
- # recurse into visible fields
242
- fields(type).each do |field|
243
- field_type = field.type.unwrap
244
- unvisited_types << field_type
245
- # recurse into visible arguments
246
- arguments(field).each do |argument|
247
- argument_type = argument.type.unwrap
248
- unvisited_types << argument_type
249
- end
250
- end
251
- end
252
- end
253
- end
254
-
255
- @reachable_type_set
256
- end
257
183
  end
258
184
  end
259
185
  end
@@ -14,7 +14,7 @@ module GraphQL
14
14
  end
15
15
 
16
16
  def to_graphql
17
- raise GraphQL::RequiredImplementationMissingError
17
+ raise NotImplementedError
18
18
  end
19
19
 
20
20
  def unwrap
@@ -11,11 +11,11 @@ module GraphQL
11
11
  super
12
12
  @defdep_node_paths = {}
13
13
 
14
- # { name => [node, ...] } pairs for fragments (although duplicate-named fragments are _invalid_, they are _possible_)
15
- @defdep_fragment_definitions = Hash.new{ |h, k| h[k] = [] }
14
+ # { name => node } pairs for fragments
15
+ @defdep_fragment_definitions = {}
16
16
 
17
17
  # This tracks dependencies from fragment to Node where it was used
18
- # { fragment_definition_name => [dependent_node, dependent_node]}
18
+ # { fragment_definition_node => [dependent_node, dependent_node]}
19
19
  @defdep_dependent_definitions = Hash.new { |h, k| h[k] = Set.new }
20
20
 
21
21
  # First-level usages of spreads within definitions
@@ -32,7 +32,7 @@ module GraphQL
32
32
  def on_document(node, parent)
33
33
  node.definitions.each do |definition|
34
34
  if definition.is_a? GraphQL::Language::Nodes::FragmentDefinition
35
- @defdep_fragment_definitions[definition.name] << definition
35
+ @defdep_fragment_definitions[definition.name] = definition
36
36
  end
37
37
  end
38
38
  super
@@ -42,7 +42,7 @@ module GraphQL
42
42
  end
43
43
 
44
44
  def on_operation_definition(node, prev_node)
45
- @defdep_node_paths[node.name] = NodeWithPath.new(node, context.path)
45
+ @defdep_node_paths[node] = NodeWithPath.new(node, context.path)
46
46
  @defdep_current_parent = node
47
47
  super
48
48
  @defdep_current_parent = nil
@@ -59,7 +59,7 @@ module GraphQL
59
59
  @defdep_node_paths[node] = NodeWithPath.new(node, context.path)
60
60
 
61
61
  # Track both sides of the dependency
62
- @defdep_dependent_definitions[node.name] << @defdep_current_parent
62
+ @defdep_dependent_definitions[@defdep_fragment_definitions[node.name]] << @defdep_current_parent
63
63
  @defdep_immediate_dependencies[@defdep_current_parent] << node
64
64
  super
65
65
  end
@@ -116,28 +116,24 @@ module GraphQL
116
116
  dependency_map = DependencyMap.new
117
117
  # Don't allow the loop to run more times
118
118
  # than the number of fragments in the document
119
- max_loops = 0
120
- @defdep_fragment_definitions.each_value do |v|
121
- max_loops += v.size
122
- end
123
-
119
+ max_loops = @defdep_fragment_definitions.size
124
120
  loops = 0
125
121
 
126
122
  # Instead of tracking independent fragments _as you visit_,
127
123
  # determine them at the end. This way, we can treat fragments with the
128
124
  # same name as if they were the same name. If _any_ of the fragments
129
125
  # with that name has a dependency, we record it.
130
- independent_fragment_nodes = @defdep_fragment_definitions.values.flatten - @defdep_immediate_dependencies.keys
126
+ independent_fragment_nodes = @defdep_fragment_definitions.values - @defdep_immediate_dependencies.keys
131
127
 
132
128
  while fragment_node = independent_fragment_nodes.pop
133
129
  loops += 1
134
130
  if loops > max_loops
135
- raise("Resolution loops exceeded the number of definitions; infinite loop detected. (Max: #{max_loops}, Current: #{loops})")
131
+ raise("Resolution loops exceeded the number of definitions; infinite loop detected.")
136
132
  end
137
133
  # Since it's independent, let's remove it from here.
138
134
  # That way, we can use the remainder to identify cycles
139
135
  @defdep_immediate_dependencies.delete(fragment_node)
140
- fragment_usages = @defdep_dependent_definitions[fragment_node.name]
136
+ fragment_usages = @defdep_dependent_definitions[fragment_node]
141
137
  if fragment_usages.empty?
142
138
  # If we didn't record any usages during the visit,
143
139
  # then this fragment is unused.
@@ -155,15 +151,10 @@ module GraphQL
155
151
  if block_given?
156
152
  yield(definition_node, removed, fragment_node)
157
153
  end
158
- if remaining.empty? &&
159
- definition_node.is_a?(GraphQL::Language::Nodes::FragmentDefinition) &&
160
- definition_node.name != fragment_node.name
154
+ if remaining.empty? && definition_node.is_a?(GraphQL::Language::Nodes::FragmentDefinition)
161
155
  # If all of this definition's dependencies have
162
156
  # been resolved, we can now resolve its
163
157
  # own dependents.
164
- #
165
- # But, it's possible to have a duplicate-named fragment here.
166
- # Skip it in that case
167
158
  independent_fragment_nodes << definition_node
168
159
  end
169
160
  end
@@ -175,7 +166,7 @@ module GraphQL
175
166
  # then they're still in there
176
167
  @defdep_immediate_dependencies.each do |defn_node, deps|
177
168
  deps.each do |spread|
178
- if !@defdep_fragment_definitions.key?(spread.name)
169
+ if @defdep_fragment_definitions[spread.name].nil?
179
170
  dependency_map.unmet_dependencies[@defdep_node_paths[defn_node]] << @defdep_node_paths[spread]
180
171
  deps.delete(spread)
181
172
  end
@@ -11,7 +11,7 @@ module GraphQL
11
11
  nil
12
12
  else
13
13
  arg_ret_type = arg_defn.type.unwrap
14
- if !arg_ret_type.is_a?(GraphQL::InputObjectType)
14
+ if !arg_ret_type.kind.input_object?
15
15
  nil
16
16
  else
17
17
  arg_ret_type
@@ -54,7 +54,7 @@ module GraphQL
54
54
  node.value.arguments.include?(err.ast_value)
55
55
  else
56
56
  # otherwise we just check equality
57
- node.value == (err.ast_value)
57
+ node.value == err.ast_value
58
58
  end
59
59
  if !matched
60
60
  # This node isn't the node that caused the error,
@@ -67,9 +67,14 @@ module GraphQL
67
67
  error ||= begin
68
68
  kind_of_node = node_type(parent)
69
69
  error_arg_name = parent_name(parent, parent_defn)
70
+ string_value = if node.value == Float::INFINITY
71
+ ""
72
+ else
73
+ " (#{GraphQL::Language::Printer.new.print(node.value)})"
74
+ end
70
75
 
71
76
  GraphQL::StaticValidation::ArgumentLiteralsAreCompatibleError.new(
72
- "Argument '#{node.name}' on #{kind_of_node} '#{error_arg_name}' has an invalid value. Expected type '#{arg_defn.type}'.",
77
+ "Argument '#{node.name}' on #{kind_of_node} '#{error_arg_name}' has an invalid value#{string_value}. Expected type '#{arg_defn.type.to_type_signature}'.",
73
78
  nodes: parent,
74
79
  type: kind_of_node,
75
80
  argument: node.name
@@ -92,7 +97,7 @@ module GraphQL
92
97
  elsif parent.is_a?(GraphQL::Language::Nodes::InputObject)
93
98
  type_defn.name
94
99
  else
95
- parent.name
100
+ parent.graphql_name
96
101
  end
97
102
  end
98
103
 
@@ -10,10 +10,10 @@ module GraphQL
10
10
  nil
11
11
  else
12
12
  arg_ret_type = arg_defn.type.unwrap
13
- if !arg_ret_type.is_a?(GraphQL::InputObjectType)
14
- nil
15
- else
13
+ if arg_ret_type.kind.input_object?
16
14
  arg_ret_type
15
+ else
16
+ nil
17
17
  end
18
18
  end
19
19
  when GraphQL::Language::Nodes::Directive
@@ -45,12 +45,15 @@ module GraphQL
45
45
  private
46
46
 
47
47
  def parent_name(parent, type_defn)
48
- if parent.is_a?(GraphQL::Language::Nodes::Field)
48
+ case parent
49
+ when GraphQL::Language::Nodes::Field
49
50
  parent.alias || parent.name
50
- elsif parent.is_a?(GraphQL::Language::Nodes::InputObject)
51
- type_defn.name
52
- else
51
+ when GraphQL::Language::Nodes::InputObject
52
+ type_defn.graphql_name
53
+ when GraphQL::Language::Nodes::Argument, GraphQL::Language::Nodes::Directive
53
54
  parent.name
55
+ else
56
+ raise "Invariant: Unexpected parent #{parent.inspect} (#{parent.class})"
54
57
  end
55
58
  end
56
59
 
@@ -56,7 +56,7 @@ module GraphQL
56
56
  "'@#{directive_defn.graphql_name}' can't be applied to #{location_name} (allowed: #{allowed_location_names.join(", ")})",
57
57
  nodes: directive_ast,
58
58
  target: location_name,
59
- name: directive_defn.name
59
+ name: directive_defn.graphql_name
60
60
  ))
61
61
  end
62
62
  end
@@ -27,12 +27,12 @@ module GraphQL
27
27
  nil
28
28
  elsif resolved_type.kind.scalar? && ast_node.selections.any?
29
29
  if ast_node.selections.first.is_a?(GraphQL::Language::Nodes::InlineFragment)
30
- "Selections can't be made on scalars (%{node_name} returns #{resolved_type.name} but has inline fragments [#{ast_node.selections.map(&:type).map(&:name).join(", ")}])"
30
+ "Selections can't be made on scalars (%{node_name} returns #{resolved_type.graphql_name} but has inline fragments [#{ast_node.selections.map(&:type).map(&:name).join(", ")}])"
31
31
  else
32
- "Selections can't be made on scalars (%{node_name} returns #{resolved_type.name} but has selections [#{ast_node.selections.map(&:name).join(", ")}])"
32
+ "Selections can't be made on scalars (%{node_name} returns #{resolved_type.graphql_name} but has selections [#{ast_node.selections.map(&:name).join(", ")}])"
33
33
  end
34
34
  elsif resolved_type.kind.fields? && ast_node.selections.empty?
35
- "Field must have selections (%{node_name} returns #{resolved_type.name} but has no selections. Did you mean '#{ast_node.name} { ... }'?)"
35
+ "Field must have selections (%{node_name} returns #{resolved_type.graphql_name} but has no selections. Did you mean '#{ast_node.name} { ... }'?)"
36
36
  else
37
37
  nil
38
38
  end
@@ -55,13 +55,13 @@ module GraphQL
55
55
  "name": node_name.to_s
56
56
  }
57
57
  unless resolved_type.nil?
58
- extensions["type"] = resolved_type.to_s
58
+ extensions["type"] = resolved_type.to_type_signature
59
59
  end
60
60
  add_error(GraphQL::StaticValidation::FieldsHaveAppropriateSelectionsError.new(
61
61
  msg % { node_name: node_name },
62
62
  nodes: ast_node,
63
63
  node_name: node_name.to_s,
64
- type: resolved_type.nil? ? nil : resolved_type.to_s
64
+ type: resolved_type.nil? ? nil : resolved_type.graphql_name,
65
65
  ))
66
66
  false
67
67
  else
@@ -93,8 +93,8 @@ module GraphQL
93
93
 
94
94
  return if fragment1.nil? || fragment2.nil?
95
95
 
96
- fragment_type1 = context.schema.types[fragment1.type.name]
97
- fragment_type2 = context.schema.types[fragment2.type.name]
96
+ fragment_type1 = context.warden.get_type(fragment1.type.name)
97
+ fragment_type2 = context.warden.get_type(fragment2.type.name)
98
98
 
99
99
  return if fragment_type1.nil? || fragment_type2.nil?
100
100
 
@@ -146,7 +146,7 @@ module GraphQL
146
146
  fragment = context.fragments[fragment_name]
147
147
  return if fragment.nil?
148
148
 
149
- fragment_type = context.schema.types[fragment.type.name]
149
+ fragment_type = context.warden.get_type(fragment.type.name)
150
150
  return if fragment_type.nil?
151
151
 
152
152
  fragment_fields, fragment_spreads = fields_and_fragments_from_selection(fragment, owner_type: fragment_type, parents: [*fragment_spread.parents, fragment_type])
@@ -316,7 +316,7 @@ module GraphQL
316
316
  definition = context.schema.get_field(owner_type, node.name)
317
317
  fields << Field.new(node, definition, owner_type, parents)
318
318
  when GraphQL::Language::Nodes::InlineFragment
319
- fragment_type = node.type ? context.schema.types[node.type.name] : owner_type
319
+ fragment_type = node.type ? context.warden.get_type(node.type.name) : owner_type
320
320
  find_fields_and_fragments(node.selections, parents: [*parents, fragment_type], owner_type: owner_type, fields: fields, fragment_spreads: fragment_spreads) if fragment_type
321
321
  when GraphQL::Language::Nodes::FragmentSpread
322
322
  fragment_spreads << FragmentSpread.new(node.name, parents)
@@ -46,10 +46,10 @@ module GraphQL
46
46
  path = [*context.path, missing_field]
47
47
  missing_field_type = parent_type.arguments[missing_field].type
48
48
  add_error(RequiredInputObjectAttributesArePresentError.new(
49
- "Argument '#{missing_field}' on InputObject '#{parent_type}' is required. Expected type #{missing_field_type}",
49
+ "Argument '#{missing_field}' on InputObject '#{parent_type.to_type_signature}' is required. Expected type #{missing_field_type.to_type_signature}",
50
50
  argument_name: missing_field,
51
- argument_type: missing_field_type.to_s,
52
- input_object_type: parent_type.to_s,
51
+ argument_type: missing_field_type.to_type_signature,
52
+ input_object_type: parent_type.to_type_signature,
53
53
  path: path,
54
54
  nodes: ast_node,
55
55
  ))
@@ -13,7 +13,7 @@ module GraphQL
13
13
  error_type: VariableDefaultValuesAreCorrectlyTypedError::VIOLATIONS[:INVALID_ON_NON_NULL]
14
14
  ))
15
15
  else
16
- type = context.schema.type_from_ast(node.type)
16
+ type = context.schema.type_from_ast(node.type, context: context)
17
17
  if type.nil?
18
18
  # This is handled by another validator
19
19
  else
@@ -26,13 +26,13 @@ module GraphQL
26
26
  end
27
27
 
28
28
  if !valid
29
- error_message ||= "Default value for $#{node.name} doesn't match type #{type}"
29
+ error_message ||= "Default value for $#{node.name} doesn't match type #{type.to_type_signature}"
30
30
  VariableDefaultValuesAreCorrectlyTypedError
31
31
  add_error(GraphQL::StaticValidation::VariableDefaultValuesAreCorrectlyTypedError.new(
32
32
  error_message,
33
33
  nodes: node,
34
34
  name: node.name,
35
- type: type.to_s,
35
+ type: type.to_type_signature,
36
36
  error_type: VariableDefaultValuesAreCorrectlyTypedError::VIOLATIONS[:INVALID_TYPE]
37
37
  ))
38
38
  end
@@ -52,17 +52,16 @@ module GraphQL
52
52
  private
53
53
 
54
54
  def validate_usage(arguments, arg_node, ast_var)
55
- var_type = context.schema.type_from_ast(ast_var.type)
55
+ var_type = context.schema.type_from_ast(ast_var.type, context: context)
56
56
  if var_type.nil?
57
57
  return
58
58
  end
59
59
  if !ast_var.default_value.nil?
60
- unless var_type.is_a?(GraphQL::NonNullType)
60
+ unless var_type.kind.non_null?
61
61
  # If the value is required, but the argument is not,
62
62
  # and yet there's a non-nil default, then we impliclty
63
63
  # make the argument also a required type.
64
-
65
- var_type = GraphQL::NonNullType.new(of_type: var_type)
64
+ var_type = var_type.to_non_null_type
66
65
  end
67
66
  end
68
67
 
@@ -85,10 +84,10 @@ module GraphQL
85
84
 
86
85
  def create_error(error_message, var_type, ast_var, arg_defn, arg_node)
87
86
  add_error(GraphQL::StaticValidation::VariableUsagesAreAllowedError.new(
88
- "#{error_message} on variable $#{ast_var.name} and argument #{arg_node.name} (#{var_type.to_s} / #{arg_defn.type.to_s})",
87
+ "#{error_message} on variable $#{ast_var.name} and argument #{arg_node.name} (#{var_type.to_type_signature} / #{arg_defn.type.to_type_signature})",
89
88
  nodes: arg_node,
90
89
  name: ast_var.name,
91
- type: var_type.to_s,
90
+ type: var_type.to_type_signature,
92
91
  argument: arg_node.name,
93
92
  error: error_message
94
93
  ))
@@ -15,7 +15,7 @@ module GraphQL
15
15
  ))
16
16
  elsif !type.kind.input?
17
17
  add_error(GraphQL::StaticValidation::VariablesAreInputTypesError.new(
18
- "#{type.name} isn't a valid input type (on $#{node.name})",
18
+ "#{type.graphql_name} isn't a valid input type (on $#{node.name})",
19
19
  nodes: node,
20
20
  name: node.name,
21
21
  type: type_name