graphql 1.10.0.pre1 → 1.10.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/core.rb +1 -0
  3. data/lib/generators/graphql/install_generator.rb +1 -0
  4. data/lib/generators/graphql/mutation_generator.rb +1 -1
  5. data/lib/generators/graphql/templates/base_field.erb +0 -4
  6. data/lib/generators/graphql/templates/base_mutation.erb +8 -0
  7. data/lib/generators/graphql/templates/graphql_controller.erb +5 -0
  8. data/lib/generators/graphql/templates/mutation.erb +1 -1
  9. data/lib/generators/graphql/templates/schema.erb +1 -1
  10. data/lib/graphql.rb +4 -1
  11. data/lib/graphql/analysis/ast.rb +14 -13
  12. data/lib/graphql/analysis/ast/analyzer.rb +23 -4
  13. data/lib/graphql/analysis/ast/field_usage.rb +1 -1
  14. data/lib/graphql/analysis/ast/max_query_complexity.rb +3 -3
  15. data/lib/graphql/analysis/ast/max_query_depth.rb +7 -3
  16. data/lib/graphql/analysis/ast/query_complexity.rb +2 -2
  17. data/lib/graphql/analysis/ast/visitor.rb +3 -3
  18. data/lib/graphql/base_type.rb +1 -1
  19. data/lib/graphql/directive.rb +0 -1
  20. data/lib/graphql/directive/deprecated_directive.rb +1 -12
  21. data/lib/graphql/execution/errors.rb +4 -8
  22. data/lib/graphql/execution/interpreter.rb +5 -11
  23. data/lib/graphql/execution/interpreter/runtime.rb +56 -48
  24. data/lib/graphql/execution/lazy/lazy_method_map.rb +4 -0
  25. data/lib/graphql/execution/lookahead.rb +5 -5
  26. data/lib/graphql/execution/multiplex.rb +10 -0
  27. data/lib/graphql/function.rb +1 -1
  28. data/lib/graphql/input_object_type.rb +3 -2
  29. data/lib/graphql/interface_type.rb +1 -1
  30. data/lib/graphql/introspection/base_object.rb +2 -5
  31. data/lib/graphql/introspection/directive_type.rb +1 -1
  32. data/lib/graphql/introspection/entry_points.rb +6 -6
  33. data/lib/graphql/introspection/schema_type.rb +1 -6
  34. data/lib/graphql/introspection/type_type.rb +5 -5
  35. data/lib/graphql/language.rb +1 -1
  36. data/lib/graphql/language/block_string.rb +2 -2
  37. data/lib/graphql/language/definition_slice.rb +21 -10
  38. data/lib/graphql/language/document_from_schema_definition.rb +42 -42
  39. data/lib/graphql/language/lexer.rb +49 -48
  40. data/lib/graphql/language/lexer.rl +49 -48
  41. data/lib/graphql/language/nodes.rb +11 -8
  42. data/lib/graphql/language/parser.rb +4 -1
  43. data/lib/graphql/language/parser.y +4 -1
  44. data/lib/graphql/language/token.rb +1 -1
  45. data/lib/graphql/pagination/array_connection.rb +0 -1
  46. data/lib/graphql/pagination/connection.rb +31 -10
  47. data/lib/graphql/pagination/connections.rb +7 -2
  48. data/lib/graphql/pagination/relation_connection.rb +1 -7
  49. data/lib/graphql/query.rb +9 -4
  50. data/lib/graphql/query/arguments.rb +8 -1
  51. data/lib/graphql/query/literal_input.rb +2 -1
  52. data/lib/graphql/query/variables.rb +5 -1
  53. data/lib/graphql/relay/base_connection.rb +3 -3
  54. data/lib/graphql/relay/relation_connection.rb +9 -5
  55. data/lib/graphql/schema.rb +699 -153
  56. data/lib/graphql/schema/argument.rb +20 -4
  57. data/lib/graphql/schema/build_from_definition.rb +64 -31
  58. data/lib/graphql/schema/built_in_types.rb +5 -5
  59. data/lib/graphql/schema/directive.rb +16 -1
  60. data/lib/graphql/schema/directive/deprecated.rb +18 -0
  61. data/lib/graphql/schema/directive/feature.rb +1 -1
  62. data/lib/graphql/schema/enum.rb +39 -3
  63. data/lib/graphql/schema/field.rb +39 -9
  64. data/lib/graphql/schema/field/connection_extension.rb +4 -4
  65. data/lib/graphql/schema/find_inherited_value.rb +13 -0
  66. data/lib/graphql/schema/finder.rb +13 -11
  67. data/lib/graphql/schema/input_object.rb +109 -1
  68. data/lib/graphql/schema/interface.rb +8 -7
  69. data/lib/graphql/schema/introspection_system.rb +104 -36
  70. data/lib/graphql/schema/late_bound_type.rb +1 -0
  71. data/lib/graphql/schema/list.rb +26 -0
  72. data/lib/graphql/schema/loader.rb +10 -4
  73. data/lib/graphql/schema/member.rb +3 -0
  74. data/lib/graphql/schema/member/base_dsl_methods.rb +23 -13
  75. data/lib/graphql/schema/member/build_type.rb +1 -1
  76. data/lib/graphql/schema/member/has_arguments.rb +2 -2
  77. data/lib/graphql/schema/member/has_fields.rb +15 -6
  78. data/lib/graphql/schema/member/instrumentation.rb +6 -1
  79. data/lib/graphql/schema/member/type_system_helpers.rb +1 -1
  80. data/lib/graphql/schema/member/validates_input.rb +33 -0
  81. data/lib/graphql/schema/non_null.rb +25 -0
  82. data/lib/graphql/schema/object.rb +14 -1
  83. data/lib/graphql/schema/printer.rb +4 -3
  84. data/lib/graphql/schema/relay_classic_mutation.rb +5 -1
  85. data/lib/graphql/schema/resolver.rb +20 -2
  86. data/lib/graphql/schema/scalar.rb +18 -3
  87. data/lib/graphql/schema/subscription.rb +1 -1
  88. data/lib/graphql/schema/timeout_middleware.rb +3 -2
  89. data/lib/graphql/schema/traversal.rb +1 -1
  90. data/lib/graphql/schema/type_expression.rb +22 -24
  91. data/lib/graphql/schema/validation.rb +17 -1
  92. data/lib/graphql/schema/warden.rb +46 -17
  93. data/lib/graphql/schema/wrapper.rb +1 -1
  94. data/lib/graphql/static_validation/base_visitor.rb +10 -6
  95. data/lib/graphql/static_validation/definition_dependencies.rb +21 -12
  96. data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +4 -4
  97. data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
  98. data/lib/graphql/static_validation/type_stack.rb +2 -2
  99. data/lib/graphql/static_validation/validator.rb +1 -1
  100. data/lib/graphql/subscriptions.rb +38 -13
  101. data/lib/graphql/subscriptions/event.rb +24 -7
  102. data/lib/graphql/subscriptions/instrumentation.rb +1 -1
  103. data/lib/graphql/subscriptions/subscription_root.rb +0 -1
  104. data/lib/graphql/tracing/active_support_notifications_tracing.rb +10 -10
  105. data/lib/graphql/tracing/platform_tracing.rb +1 -2
  106. data/lib/graphql/tracing/skylight_tracing.rb +1 -0
  107. data/lib/graphql/unresolved_type_error.rb +2 -2
  108. data/lib/graphql/upgrader/member.rb +1 -1
  109. data/lib/graphql/version.rb +1 -1
  110. metadata +5 -2
@@ -36,6 +36,10 @@ module GraphQL
36
36
  @storage.compute_if_absent(value.class) { find_superclass_method(value.class) }
37
37
  end
38
38
 
39
+ def each
40
+ @storage.each_pair { |k, v| yield(k, v) }
41
+ end
42
+
39
43
  protected
40
44
 
41
45
  attr_reader :storage
@@ -223,14 +223,14 @@ module GraphQL
223
223
  subselections_on_type = selections_on_type
224
224
  if (t = ast_selection.type)
225
225
  # Assuming this is valid, that `t` will be found.
226
- on_type = @query.schema.types[t.name].metadata[:type_class]
226
+ on_type = @query.schema.get_type(t.name).type_class
227
227
  subselections_on_type = subselections_by_type[on_type] ||= {}
228
228
  end
229
229
  find_selections(subselections_by_type, subselections_on_type, on_type, ast_selection.selections, arguments)
230
230
  when GraphQL::Language::Nodes::FragmentSpread
231
231
  frag_defn = @query.fragments[ast_selection.name] || raise("Invariant: Can't look ahead to nonexistent fragment #{ast_selection.name} (found: #{@query.fragments.keys})")
232
232
  # Again, assuming a valid AST
233
- on_type = @query.schema.types[frag_defn.type.name].metadata[:type_class]
233
+ on_type = @query.schema.get_type(frag_defn.type.name).type_class
234
234
  subselections_on_type = subselections_by_type[on_type] ||= {}
235
235
  find_selections(subselections_by_type, subselections_on_type, on_type, frag_defn.selections, arguments)
236
236
  else
@@ -366,10 +366,10 @@ module GraphQL
366
366
 
367
367
  def get_field(schema, owner_type, field_name)
368
368
  field_defn = owner_type.get_field(field_name)
369
- field_defn ||= if owner_type == schema.query.metadata[:type_class] && (entry_point_field = schema.introspection_system.entry_point(name: field_name))
370
- entry_point_field.metadata[:type_class]
369
+ field_defn ||= if owner_type == schema.query.type_class && (entry_point_field = schema.introspection_system.entry_point(name: field_name))
370
+ entry_point_field.type_class
371
371
  elsif (dynamic_field = schema.introspection_system.dynamic_field(name: field_name))
372
- dynamic_field.metadata[:type_class]
372
+ dynamic_field.type_class
373
373
  else
374
374
  nil
375
375
  end
@@ -95,6 +95,7 @@ module GraphQL
95
95
  query.result
96
96
  end
97
97
  rescue Exception
98
+ # TODO rescue at a higher level so it will catch errors in analysis, too
98
99
  # Assign values here so that the query's `@executed` becomes true
99
100
  queries.map { |q| q.result_values ||= {} }
100
101
  raise
@@ -173,6 +174,15 @@ module GraphQL
173
174
  def instrument_and_analyze(multiplex)
174
175
  GraphQL::Execution::Instrumentation.apply_instrumenters(multiplex) do
175
176
  schema = multiplex.schema
177
+ if schema.interpreter? && schema.analysis_engine != GraphQL::Analysis::AST
178
+ raise <<-ERR
179
+ Can't use `GraphQL::Execution::Interpreter` without `GraphQL::Analysis::AST`, please add this plugin to your schema:
180
+
181
+ use GraphQL::Analysis::AST
182
+
183
+ For information about the new analysis engine: https://graphql-ruby.org/queries/ast_analysis.html
184
+ ERR
185
+ end
176
186
  multiplex_analyzers = schema.multiplex_analyzers
177
187
  if multiplex.max_complexity
178
188
  multiplex_analyzers += if schema.using_ast_analysis?
@@ -43,7 +43,7 @@ module GraphQL
43
43
 
44
44
  # @return [Object] This function's resolver
45
45
  def call(obj, args, ctx)
46
- raise NotImplementedError
46
+ raise GraphQL::RequiredImplementationMissingError
47
47
  end
48
48
 
49
49
  # @return [String, nil]
@@ -99,7 +99,8 @@ module GraphQL
99
99
  end
100
100
  end
101
101
 
102
- arguments_class.new(input_values, context: ctx, defaults_used: defaults_used)
102
+ result = arguments_class.new(input_values, context: ctx, defaults_used: defaults_used)
103
+ result.prepare
103
104
  end
104
105
 
105
106
  # @api private
@@ -135,7 +136,7 @@ module GraphQL
135
136
  # Items in the input that are unexpected
136
137
  input.each do |name, value|
137
138
  if visible_arguments_map[name].nil?
138
- result.add_problem("Field is not defined on #{self.name}", [name])
139
+ result.add_problem("Field is not defined on #{self.graphql_name}", [name])
139
140
  end
140
141
  end
141
142
 
@@ -71,7 +71,7 @@ module GraphQL
71
71
  # @return [GraphQL::ObjectType, nil] The type named `type_name` if it exists and implements this {InterfaceType}, (else `nil`)
72
72
  def get_possible_type(type_name, ctx)
73
73
  type = ctx.query.get_type(type_name)
74
- type if type && ctx.query.schema.possible_types(self).include?(type)
74
+ type if type && ctx.query.warden.possible_types(self).include?(type)
75
75
  end
76
76
 
77
77
  # Check if a type is a possible type of this {InterfaceType}
@@ -2,15 +2,12 @@
2
2
  module GraphQL
3
3
  module Introspection
4
4
  class BaseObject < GraphQL::Schema::Object
5
+ introspection(true)
6
+
5
7
  def self.field(*args, **kwargs, &block)
6
8
  kwargs[:introspection] = true
7
9
  super(*args, **kwargs, &block)
8
10
  end
9
-
10
- def self.inherited(child_class)
11
- child_class.introspection(true)
12
- super
13
- end
14
11
  end
15
12
  end
16
13
  end
@@ -9,7 +9,7 @@ module GraphQL
9
9
  "in ways field arguments will not suffice, such as conditionally including or "\
10
10
  "skipping a field. Directives provide this by describing additional information "\
11
11
  "to the executor."
12
- field :name, String, null: false
12
+ field :name, String, null: false, method: :graphql_name
13
13
  field :description, String, null: true
14
14
  field :locations, [GraphQL::Schema::LateBoundType.new("__DirectiveLocation")], null: false
15
15
  field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false
@@ -10,22 +10,22 @@ module GraphQL
10
10
  def __schema
11
11
  # Apply wrapping manually since this field isn't wrapped by instrumentation
12
12
  schema = @context.query.schema
13
- schema_type = schema.introspection_system.schema_type
14
- schema_type.metadata[:type_class].authorized_new(schema, @context)
13
+ schema_type = schema.introspection_system.types["__Schema"]
14
+ schema_type.type_class.authorized_new(schema, @context)
15
15
  end
16
16
 
17
17
  def __type(name:)
18
18
  type = context.warden.get_type(name)
19
19
 
20
- if type && context.interpreter?
21
- type = type.metadata[:type_class] || raise("Invariant: interpreter requires class-based type for #{name}")
20
+ if type && context.interpreter? && !type.is_a?(Module)
21
+ type = type.type_class || raise("Invariant: interpreter requires class-based type for #{name}")
22
22
  end
23
23
 
24
24
  # The interpreter provides this wrapping, other execution doesnt, so support both.
25
25
  if type && !context.interpreter?
26
26
  # Apply wrapping manually since this field isn't wrapped by instrumentation
27
- type_type = context.schema.introspection_system.type_type
28
- type = type_type.metadata[:type_class].authorized_new(type, context)
27
+ type_type = context.schema.introspection_system.types["__Type"]
28
+ type = type_type.type_class.authorized_new(type, context)
29
29
  end
30
30
  type
31
31
  end
@@ -14,12 +14,7 @@ module GraphQL
14
14
  field :directives, [GraphQL::Schema::LateBoundType.new("__Directive")], "A list of all directives supported by this server.", null: false
15
15
 
16
16
  def types
17
- types = @context.warden.types
18
- if context.interpreter?
19
- types.map { |t| t.metadata[:type_class] || raise("Invariant: can't introspect non-class-based type: #{t}") }
20
- else
21
- types
22
- end
17
+ @context.warden.types.values
23
18
  end
24
19
 
25
20
  def query_type
@@ -37,7 +37,7 @@ module GraphQL
37
37
  if !@object.kind.enum?
38
38
  nil
39
39
  else
40
- enum_values = @context.warden.enum_values(@object.graphql_definition)
40
+ enum_values = @context.warden.enum_values(@object)
41
41
 
42
42
  if !include_deprecated
43
43
  enum_values = enum_values.select {|f| !f.deprecation_reason }
@@ -49,7 +49,7 @@ module GraphQL
49
49
 
50
50
  def interfaces
51
51
  if @object.kind == GraphQL::TypeKinds::OBJECT
52
- @context.warden.interfaces(@object.graphql_definition)
52
+ @context.warden.interfaces(@object)
53
53
  else
54
54
  nil
55
55
  end
@@ -57,7 +57,7 @@ module GraphQL
57
57
 
58
58
  def input_fields
59
59
  if @object.kind.input_object?
60
- @context.warden.arguments(@object.graphql_definition)
60
+ @context.warden.arguments(@object)
61
61
  else
62
62
  nil
63
63
  end
@@ -65,7 +65,7 @@ module GraphQL
65
65
 
66
66
  def possible_types
67
67
  if @object.kind.abstract?
68
- @context.warden.possible_types(@object.graphql_definition)
68
+ @context.warden.possible_types(@object).sort_by(&:graphql_name)
69
69
  else
70
70
  nil
71
71
  end
@@ -75,7 +75,7 @@ module GraphQL
75
75
  if !@object.kind.fields?
76
76
  nil
77
77
  else
78
- fields = @context.warden.fields(@object.graphql_definition)
78
+ fields = @context.warden.fields(@object)
79
79
  if !include_deprecated
80
80
  fields = fields.select {|f| !f.deprecation_reason }
81
81
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require "graphql/language/block_string"
3
3
  require "graphql/language/printer"
4
- require "graphql/language/definition_slice"
5
4
  require "graphql/language/document_from_schema_definition"
6
5
  require "graphql/language/generation"
7
6
  require "graphql/language/lexer"
@@ -9,6 +8,7 @@ require "graphql/language/nodes"
9
8
  require "graphql/language/parser"
10
9
  require "graphql/language/token"
11
10
  require "graphql/language/visitor"
11
+ require "graphql/language/definition_slice"
12
12
 
13
13
  module GraphQL
14
14
  module Language
@@ -32,10 +32,10 @@ module GraphQL
32
32
  end
33
33
 
34
34
  # Remove leading & trailing blank lines
35
- while lines.first.empty?
35
+ while lines.size > 0 && lines[0].empty?
36
36
  lines.shift
37
37
  end
38
- while lines.last.empty?
38
+ while lines.size > 0 && lines[-1].empty?
39
39
  lines.pop
40
40
  end
41
41
 
@@ -7,23 +7,34 @@ module GraphQL
7
7
  def slice(document, name)
8
8
  definitions = {}
9
9
  document.definitions.each { |d| definitions[d.name] = d }
10
- names = find_definition_dependencies(definitions, name)
10
+ names = Set.new
11
+ DependencyVisitor.find_definition_dependencies(definitions, name, names)
11
12
  definitions = document.definitions.select { |d| names.include?(d.name) }
12
13
  Nodes::Document.new(definitions: definitions)
13
14
  end
14
15
 
15
16
  private
16
17
 
17
- def find_definition_dependencies(definitions, name)
18
- names = Set.new([name])
19
- visitor = Visitor.new(definitions[name])
20
- visitor[Nodes::FragmentSpread] << ->(node, parent) {
21
- if fragment = definitions[node.name]
22
- names.merge(find_definition_dependencies(definitions, fragment.name))
18
+ class DependencyVisitor < GraphQL::Language::Visitor
19
+ def initialize(doc, definitions, names)
20
+ @names = names
21
+ @definitions = definitions
22
+ super(doc)
23
+ end
24
+
25
+ def on_fragment_spread(node, parent)
26
+ if fragment = @definitions[node.name]
27
+ self.class.find_definition_dependencies(@definitions, fragment.name, @names)
23
28
  end
24
- }
25
- visitor.visit
26
- names
29
+ super
30
+ end
31
+
32
+ def self.find_definition_dependencies(definitions, name, names)
33
+ names.add(name)
34
+ visitor = self.new(definitions[name], definitions, names)
35
+ visitor.visit
36
+ nil
37
+ end
27
38
  end
28
39
  end
29
40
  end
@@ -38,9 +38,9 @@ module GraphQL
38
38
 
39
39
  def build_schema_node
40
40
  GraphQL::Language::Nodes::SchemaDefinition.new(
41
- query: warden.root_type_for_operation("query"),
42
- mutation: warden.root_type_for_operation("mutation"),
43
- subscription: warden.root_type_for_operation("subscription"),
41
+ query: (q = warden.root_type_for_operation("query")) && q.graphql_name,
42
+ mutation: (m = warden.root_type_for_operation("mutation")) && m.graphql_name,
43
+ subscription: (s = warden.root_type_for_operation("subscription")) && s.graphql_name,
44
44
  # This only supports directives from parsing,
45
45
  # use a custom printer to add to this list.
46
46
  directives: @schema.ast_node ? @schema.ast_node.directives : [],
@@ -49,8 +49,8 @@ module GraphQL
49
49
 
50
50
  def build_object_type_node(object_type)
51
51
  GraphQL::Language::Nodes::ObjectTypeDefinition.new(
52
- name: object_type.name,
53
- interfaces: warden.interfaces(object_type).sort_by(&:name).map { |iface| build_type_name_node(iface) },
52
+ name: object_type.graphql_name,
53
+ interfaces: warden.interfaces(object_type).sort_by(&:graphql_name).map { |iface| build_type_name_node(iface) },
54
54
  fields: build_field_nodes(warden.fields(object_type)),
55
55
  description: object_type.description,
56
56
  )
@@ -58,7 +58,7 @@ module GraphQL
58
58
 
59
59
  def build_field_node(field)
60
60
  field_node = GraphQL::Language::Nodes::FieldDefinition.new(
61
- name: field.name,
61
+ name: field.graphql_name,
62
62
  arguments: build_argument_nodes(warden.arguments(field)),
63
63
  type: build_type_name_node(field.type),
64
64
  description: field.description,
@@ -66,7 +66,7 @@ module GraphQL
66
66
 
67
67
  if field.deprecation_reason
68
68
  field_node = field_node.merge_directive(
69
- name: GraphQL::Directive::DeprecatedDirective.name,
69
+ name: GraphQL::Directive::DeprecatedDirective.graphql_name,
70
70
  arguments: [GraphQL::Language::Nodes::Argument.new(name: "reason", value: field.deprecation_reason)]
71
71
  )
72
72
  end
@@ -76,15 +76,15 @@ module GraphQL
76
76
 
77
77
  def build_union_type_node(union_type)
78
78
  GraphQL::Language::Nodes::UnionTypeDefinition.new(
79
- name: union_type.name,
79
+ name: union_type.graphql_name,
80
80
  description: union_type.description,
81
- types: warden.possible_types(union_type).sort_by(&:name).map { |type| build_type_name_node(type) }
81
+ types: warden.possible_types(union_type).sort_by(&:graphql_name).map { |type| build_type_name_node(type) }
82
82
  )
83
83
  end
84
84
 
85
85
  def build_interface_type_node(interface_type)
86
86
  GraphQL::Language::Nodes::InterfaceTypeDefinition.new(
87
- name: interface_type.name,
87
+ name: interface_type.graphql_name,
88
88
  description: interface_type.description,
89
89
  fields: build_field_nodes(warden.fields(interface_type))
90
90
  )
@@ -92,8 +92,8 @@ module GraphQL
92
92
 
93
93
  def build_enum_type_node(enum_type)
94
94
  GraphQL::Language::Nodes::EnumTypeDefinition.new(
95
- name: enum_type.name,
96
- values: warden.enum_values(enum_type).sort_by(&:name).map do |enum_value|
95
+ name: enum_type.graphql_name,
96
+ values: warden.enum_values(enum_type).sort_by(&:graphql_name).map do |enum_value|
97
97
  build_enum_value_node(enum_value)
98
98
  end,
99
99
  description: enum_type.description,
@@ -102,13 +102,13 @@ module GraphQL
102
102
 
103
103
  def build_enum_value_node(enum_value)
104
104
  enum_value_node = GraphQL::Language::Nodes::EnumValueDefinition.new(
105
- name: enum_value.name,
105
+ name: enum_value.graphql_name,
106
106
  description: enum_value.description,
107
107
  )
108
108
 
109
109
  if enum_value.deprecation_reason
110
110
  enum_value_node = enum_value_node.merge_directive(
111
- name: GraphQL::Directive::DeprecatedDirective.name,
111
+ name: GraphQL::Directive::DeprecatedDirective.graphql_name,
112
112
  arguments: [GraphQL::Language::Nodes::Argument.new(name: "reason", value: enum_value.deprecation_reason)]
113
113
  )
114
114
  end
@@ -118,7 +118,7 @@ module GraphQL
118
118
 
119
119
  def build_scalar_type_node(scalar_type)
120
120
  GraphQL::Language::Nodes::ScalarTypeDefinition.new(
121
- name: scalar_type.name,
121
+ name: scalar_type.graphql_name,
122
122
  description: scalar_type.description,
123
123
  )
124
124
  end
@@ -131,7 +131,7 @@ module GraphQL
131
131
  end
132
132
 
133
133
  argument_node = GraphQL::Language::Nodes::InputValueDefinition.new(
134
- name: argument.name,
134
+ name: argument.graphql_name,
135
135
  description: argument.description,
136
136
  type: build_type_name_node(argument.type),
137
137
  default_value: default_value,
@@ -142,7 +142,7 @@ module GraphQL
142
142
 
143
143
  def build_input_object_node(input_object)
144
144
  GraphQL::Language::Nodes::InputObjectTypeDefinition.new(
145
- name: input_object.name,
145
+ name: input_object.graphql_name,
146
146
  fields: build_argument_nodes(warden.arguments(input_object)),
147
147
  description: input_object.description,
148
148
  )
@@ -168,17 +168,17 @@ module GraphQL
168
168
  end
169
169
 
170
170
  def build_type_name_node(type)
171
- case type
172
- when GraphQL::ListType
171
+ case type.kind.name
172
+ when "LIST"
173
173
  GraphQL::Language::Nodes::ListType.new(
174
174
  of_type: build_type_name_node(type.of_type)
175
175
  )
176
- when GraphQL::NonNullType
176
+ when "NON_NULL"
177
177
  GraphQL::Language::Nodes::NonNullType.new(
178
178
  of_type: build_type_name_node(type.of_type)
179
179
  )
180
180
  else
181
- GraphQL::Language::Nodes::TypeName.new(name: type.name)
181
+ GraphQL::Language::Nodes::TypeName.new(name: type.graphql_name)
182
182
  end
183
183
  end
184
184
 
@@ -187,43 +187,43 @@ module GraphQL
187
187
  return GraphQL::Language::Nodes::NullValue.new(name: "null")
188
188
  end
189
189
 
190
- case type
191
- when GraphQL::ScalarType
190
+ case type.kind.name
191
+ when "SCALAR"
192
192
  type.coerce_isolated_result(default_value)
193
- when EnumType
193
+ when "ENUM"
194
194
  GraphQL::Language::Nodes::Enum.new(name: type.coerce_isolated_result(default_value))
195
- when InputObjectType
195
+ when "INPUT_OBJECT"
196
196
  GraphQL::Language::Nodes::InputObject.new(
197
197
  arguments: default_value.to_h.map do |arg_name, arg_value|
198
- arg_type = type.input_fields.fetch(arg_name.to_s).type
198
+ arg_type = type.arguments.fetch(arg_name.to_s).type
199
199
  GraphQL::Language::Nodes::Argument.new(
200
- name: arg_name,
200
+ name: arg_name.to_s,
201
201
  value: build_default_value(arg_value, arg_type)
202
202
  )
203
203
  end
204
204
  )
205
- when NonNullType
205
+ when "NON_NULL"
206
206
  build_default_value(default_value, type.of_type)
207
- when ListType
207
+ when "LIST"
208
208
  default_value.to_a.map { |v| build_default_value(v, type.of_type) }
209
209
  else
210
- raise NotImplementedError, "Unexpected default value type #{type.inspect}"
210
+ raise GraphQL::RequiredImplementationMissingError, "Unexpected default value type #{type.inspect}"
211
211
  end
212
212
  end
213
213
 
214
214
  def build_type_definition_node(type)
215
- case type
216
- when GraphQL::ObjectType
215
+ case type.kind.name
216
+ when "OBJECT"
217
217
  build_object_type_node(type)
218
- when GraphQL::UnionType
218
+ when "UNION"
219
219
  build_union_type_node(type)
220
- when GraphQL::InterfaceType
220
+ when "INTERFACE"
221
221
  build_interface_type_node(type)
222
- when GraphQL::ScalarType
222
+ when "SCALAR"
223
223
  build_scalar_type_node(type)
224
- when GraphQL::EnumType
224
+ when "ENUM"
225
225
  build_enum_type_node(type)
226
- when GraphQL::InputObjectType
226
+ when "INPUT_OBJECT"
227
227
  build_input_object_node(type)
228
228
  else
229
229
  raise TypeError
@@ -250,7 +250,7 @@ module GraphQL
250
250
  definitions = []
251
251
  definitions << build_schema_node if include_schema_node?
252
252
  definitions += build_directive_nodes(warden.directives)
253
- definitions += build_type_definition_nodes(warden.types)
253
+ definitions += build_type_definition_nodes(warden.types.values)
254
254
  definitions
255
255
  end
256
256
 
@@ -260,7 +260,7 @@ module GraphQL
260
260
  end
261
261
 
262
262
  if !include_built_in_scalars
263
- types = types.reject { |type| type.default_scalar? }
263
+ types = types.reject { |type| type.kind.scalar? && type.default_scalar? }
264
264
  end
265
265
 
266
266
  types
@@ -281,9 +281,9 @@ module GraphQL
281
281
  end
282
282
 
283
283
  def schema_respects_root_name_conventions?(schema)
284
- (schema.query.nil? || schema.query.name == 'Query') &&
285
- (schema.mutation.nil? || schema.mutation.name == 'Mutation') &&
286
- (schema.subscription.nil? || schema.subscription.name == 'Subscription')
284
+ (schema.query.nil? || schema.query.graphql_name == 'Query') &&
285
+ (schema.mutation.nil? || schema.mutation.graphql_name == 'Mutation') &&
286
+ (schema.subscription.nil? || schema.subscription.graphql_name == 'Subscription')
287
287
  end
288
288
 
289
289
  attr_reader :schema, :warden, :always_include_schema,