graphql 1.13.13 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/ast/query_complexity.rb +1 -1
  3. data/lib/graphql/analysis/ast/query_depth.rb +0 -1
  4. data/lib/graphql/analysis/ast/visitor.rb +1 -1
  5. data/lib/graphql/analysis/ast.rb +0 -10
  6. data/lib/graphql/analysis.rb +0 -7
  7. data/lib/graphql/backtrace/table.rb +0 -18
  8. data/lib/graphql/backtrace/tracer.rb +1 -2
  9. data/lib/graphql/backtrace.rb +2 -8
  10. data/lib/graphql/dig.rb +1 -1
  11. data/lib/graphql/execution/errors.rb +1 -9
  12. data/lib/graphql/execution/interpreter/runtime.rb +2 -9
  13. data/lib/graphql/execution/interpreter.rb +0 -22
  14. data/lib/graphql/execution/lazy.rb +1 -1
  15. data/lib/graphql/execution/lookahead.rb +6 -13
  16. data/lib/graphql/execution/multiplex.rb +50 -107
  17. data/lib/graphql/execution.rb +11 -3
  18. data/lib/graphql/introspection/dynamic_fields.rb +3 -8
  19. data/lib/graphql/introspection/entry_points.rb +2 -15
  20. data/lib/graphql/language/document_from_schema_definition.rb +0 -17
  21. data/lib/graphql/pagination/connections.rb +2 -28
  22. data/lib/graphql/query/context.rb +1 -185
  23. data/lib/graphql/query/literal_input.rb +8 -13
  24. data/lib/graphql/query/validation_pipeline.rb +8 -37
  25. data/lib/graphql/query/variables.rb +22 -18
  26. data/lib/graphql/query.rb +5 -35
  27. data/lib/graphql/railtie.rb +0 -104
  28. data/lib/graphql/relay/range_add.rb +0 -4
  29. data/lib/graphql/relay.rb +0 -15
  30. data/lib/graphql/schema/addition.rb +1 -8
  31. data/lib/graphql/schema/argument.rb +1 -25
  32. data/lib/graphql/schema/build_from_definition.rb +0 -1
  33. data/lib/graphql/schema/directive.rb +0 -21
  34. data/lib/graphql/schema/enum.rb +1 -18
  35. data/lib/graphql/schema/enum_value.rb +0 -22
  36. data/lib/graphql/schema/field.rb +2 -183
  37. data/lib/graphql/schema/input_object.rb +9 -56
  38. data/lib/graphql/schema/interface.rb +0 -25
  39. data/lib/graphql/schema/introspection_system.rb +3 -8
  40. data/lib/graphql/schema/late_bound_type.rb +2 -2
  41. data/lib/graphql/schema/list.rb +0 -6
  42. data/lib/graphql/schema/loader.rb +0 -1
  43. data/lib/graphql/schema/member/base_dsl_methods.rb +0 -5
  44. data/lib/graphql/schema/member/build_type.rb +4 -6
  45. data/lib/graphql/schema/member/has_arguments.rb +14 -18
  46. data/lib/graphql/schema/member/has_fields.rb +2 -2
  47. data/lib/graphql/schema/member/has_interfaces.rb +0 -2
  48. data/lib/graphql/schema/member.rb +0 -6
  49. data/lib/graphql/schema/mutation.rb +0 -9
  50. data/lib/graphql/schema/non_null.rb +1 -7
  51. data/lib/graphql/schema/object.rb +0 -40
  52. data/lib/graphql/schema/relay_classic_mutation.rb +17 -28
  53. data/lib/graphql/schema/scalar.rb +0 -15
  54. data/lib/graphql/schema/union.rb +0 -16
  55. data/lib/graphql/schema/warden.rb +1 -1
  56. data/lib/graphql/schema/wrapper.rb +0 -5
  57. data/lib/graphql/schema.rb +106 -945
  58. data/lib/graphql/static_validation/base_visitor.rb +4 -21
  59. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +12 -12
  60. data/lib/graphql/static_validation/validator.rb +2 -24
  61. data/lib/graphql/static_validation.rb +0 -2
  62. data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +38 -1
  63. data/lib/graphql/subscriptions/event.rb +1 -1
  64. data/lib/graphql/subscriptions/instrumentation.rb +0 -51
  65. data/lib/graphql/subscriptions.rb +4 -13
  66. data/lib/graphql/tracing/data_dog_tracing.rb +1 -16
  67. data/lib/graphql/tracing/platform_tracing.rb +4 -31
  68. data/lib/graphql/tracing.rb +0 -2
  69. data/lib/graphql/types/relay/connection_behaviors.rb +2 -6
  70. data/lib/graphql/types/relay/default_relay.rb +0 -10
  71. data/lib/graphql/types/relay/node_behaviors.rb +5 -1
  72. data/lib/graphql/types/relay.rb +0 -2
  73. data/lib/graphql/version.rb +1 -1
  74. data/lib/graphql.rb +1 -65
  75. metadata +6 -132
  76. data/lib/graphql/analysis/analyze_query.rb +0 -98
  77. data/lib/graphql/analysis/field_usage.rb +0 -45
  78. data/lib/graphql/analysis/max_query_complexity.rb +0 -26
  79. data/lib/graphql/analysis/max_query_depth.rb +0 -26
  80. data/lib/graphql/analysis/query_complexity.rb +0 -88
  81. data/lib/graphql/analysis/query_depth.rb +0 -43
  82. data/lib/graphql/analysis/reducer_state.rb +0 -48
  83. data/lib/graphql/argument.rb +0 -131
  84. data/lib/graphql/authorization.rb +0 -82
  85. data/lib/graphql/backtrace/legacy_tracer.rb +0 -56
  86. data/lib/graphql/backwards_compatibility.rb +0 -61
  87. data/lib/graphql/base_type.rb +0 -232
  88. data/lib/graphql/boolean_type.rb +0 -2
  89. data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
  90. data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
  91. data/lib/graphql/compatibility/execution_specification.rb +0 -436
  92. data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
  93. data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -215
  94. data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -87
  95. data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
  96. data/lib/graphql/compatibility/query_parser_specification.rb +0 -266
  97. data/lib/graphql/compatibility/schema_parser_specification.rb +0 -682
  98. data/lib/graphql/compatibility.rb +0 -5
  99. data/lib/graphql/define/assign_argument.rb +0 -12
  100. data/lib/graphql/define/assign_connection.rb +0 -13
  101. data/lib/graphql/define/assign_enum_value.rb +0 -18
  102. data/lib/graphql/define/assign_global_id_field.rb +0 -11
  103. data/lib/graphql/define/assign_mutation_function.rb +0 -34
  104. data/lib/graphql/define/assign_object_field.rb +0 -42
  105. data/lib/graphql/define/defined_object_proxy.rb +0 -53
  106. data/lib/graphql/define/instance_definable.rb +0 -255
  107. data/lib/graphql/define/no_definition_error.rb +0 -7
  108. data/lib/graphql/define/non_null_with_bang.rb +0 -16
  109. data/lib/graphql/define/type_definer.rb +0 -31
  110. data/lib/graphql/define.rb +0 -31
  111. data/lib/graphql/deprecated_dsl.rb +0 -55
  112. data/lib/graphql/directive/deprecated_directive.rb +0 -2
  113. data/lib/graphql/directive/include_directive.rb +0 -2
  114. data/lib/graphql/directive/skip_directive.rb +0 -2
  115. data/lib/graphql/directive.rb +0 -107
  116. data/lib/graphql/enum_type.rb +0 -133
  117. data/lib/graphql/execution/execute.rb +0 -333
  118. data/lib/graphql/execution/flatten.rb +0 -40
  119. data/lib/graphql/execution/typecast.rb +0 -50
  120. data/lib/graphql/field/resolve.rb +0 -59
  121. data/lib/graphql/field.rb +0 -226
  122. data/lib/graphql/float_type.rb +0 -2
  123. data/lib/graphql/function.rb +0 -128
  124. data/lib/graphql/id_type.rb +0 -2
  125. data/lib/graphql/input_object_type.rb +0 -138
  126. data/lib/graphql/int_type.rb +0 -2
  127. data/lib/graphql/interface_type.rb +0 -72
  128. data/lib/graphql/internal_representation/document.rb +0 -27
  129. data/lib/graphql/internal_representation/node.rb +0 -206
  130. data/lib/graphql/internal_representation/print.rb +0 -51
  131. data/lib/graphql/internal_representation/rewrite.rb +0 -184
  132. data/lib/graphql/internal_representation/scope.rb +0 -88
  133. data/lib/graphql/internal_representation/visit.rb +0 -36
  134. data/lib/graphql/internal_representation.rb +0 -7
  135. data/lib/graphql/list_type.rb +0 -80
  136. data/lib/graphql/non_null_type.rb +0 -71
  137. data/lib/graphql/object_type.rb +0 -130
  138. data/lib/graphql/query/arguments.rb +0 -189
  139. data/lib/graphql/query/arguments_cache.rb +0 -24
  140. data/lib/graphql/query/executor.rb +0 -52
  141. data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
  142. data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
  143. data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
  144. data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
  145. data/lib/graphql/query/serial_execution.rb +0 -40
  146. data/lib/graphql/relay/array_connection.rb +0 -83
  147. data/lib/graphql/relay/base_connection.rb +0 -189
  148. data/lib/graphql/relay/connection_instrumentation.rb +0 -54
  149. data/lib/graphql/relay/connection_resolve.rb +0 -43
  150. data/lib/graphql/relay/connection_type.rb +0 -54
  151. data/lib/graphql/relay/edge.rb +0 -27
  152. data/lib/graphql/relay/edge_type.rb +0 -19
  153. data/lib/graphql/relay/edges_instrumentation.rb +0 -39
  154. data/lib/graphql/relay/global_id_resolve.rb +0 -17
  155. data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
  156. data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
  157. data/lib/graphql/relay/mutation/resolve.rb +0 -56
  158. data/lib/graphql/relay/mutation/result.rb +0 -38
  159. data/lib/graphql/relay/mutation.rb +0 -106
  160. data/lib/graphql/relay/node.rb +0 -39
  161. data/lib/graphql/relay/page_info.rb +0 -7
  162. data/lib/graphql/relay/relation_connection.rb +0 -188
  163. data/lib/graphql/relay/type_extensions.rb +0 -32
  164. data/lib/graphql/scalar_type.rb +0 -91
  165. data/lib/graphql/schema/catchall_middleware.rb +0 -35
  166. data/lib/graphql/schema/default_parse_error.rb +0 -10
  167. data/lib/graphql/schema/default_type_error.rb +0 -17
  168. data/lib/graphql/schema/member/accepts_definition.rb +0 -164
  169. data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -58
  170. data/lib/graphql/schema/member/instrumentation.rb +0 -131
  171. data/lib/graphql/schema/middleware_chain.rb +0 -82
  172. data/lib/graphql/schema/possible_types.rb +0 -44
  173. data/lib/graphql/schema/rescue_middleware.rb +0 -60
  174. data/lib/graphql/schema/timeout_middleware.rb +0 -88
  175. data/lib/graphql/schema/traversal.rb +0 -228
  176. data/lib/graphql/schema/validation.rb +0 -313
  177. data/lib/graphql/static_validation/default_visitor.rb +0 -15
  178. data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
  179. data/lib/graphql/string_type.rb +0 -2
  180. data/lib/graphql/subscriptions/subscription_root.rb +0 -76
  181. data/lib/graphql/tracing/opentelemetry_tracing.rb +0 -101
  182. data/lib/graphql/tracing/skylight_tracing.rb +0 -70
  183. data/lib/graphql/types/relay/node_field.rb +0 -24
  184. data/lib/graphql/types/relay/nodes_field.rb +0 -43
  185. data/lib/graphql/union_type.rb +0 -115
  186. data/lib/graphql/upgrader/member.rb +0 -937
  187. data/lib/graphql/upgrader/schema.rb +0 -38
@@ -2,8 +2,6 @@
2
2
  module GraphQL
3
3
  class Schema
4
4
  class Argument
5
- include GraphQL::Schema::Member::CachedGraphQLDefinition
6
- include GraphQL::Schema::Member::AcceptsDefinition
7
5
  include GraphQL::Schema::Member::HasPath
8
6
  include GraphQL::Schema::Member::HasAstNode
9
7
  include GraphQL::Schema::Member::HasDirectives
@@ -44,12 +42,11 @@ module GraphQL
44
42
  # @param prepare [Symbol] A method to call to transform this argument's valuebefore sending it to field resolution
45
43
  # @param camelize [Boolean] if true, the name will be camelized when building the schema
46
44
  # @param from_resolver [Boolean] if true, a Resolver class defined this argument
47
- # @param method_access [Boolean] If false, don't build method access on legacy {Query::Arguments} instances.
48
45
  # @param directives [Hash{Class => Hash}]
49
46
  # @param deprecation_reason [String]
50
47
  # @param validates [Hash, nil] Options for building validators, if any should be applied
51
48
  # @param replace_null_with_default [Boolean] if `true`, incoming values of `null` will be replaced with the configured `default_value`
52
- def initialize(arg_name = nil, type_expr = nil, desc = nil, required: true, type: nil, name: nil, loads: nil, description: nil, ast_node: nil, default_value: NO_DEFAULT, as: nil, from_resolver: false, camelize: true, prepare: nil, method_access: true, owner:, validates: nil, directives: nil, deprecation_reason: nil, replace_null_with_default: false, &definition_block)
49
+ def initialize(arg_name = nil, type_expr = nil, desc = nil, required: true, type: nil, name: nil, loads: nil, description: nil, ast_node: nil, default_value: NO_DEFAULT, as: nil, from_resolver: false, camelize: true, prepare: nil, owner:, validates: nil, directives: nil, deprecation_reason: nil, replace_null_with_default: false, &definition_block)
53
50
  arg_name ||= name
54
51
  @name = -(camelize ? Member::BuildType.camelize(arg_name.to_s) : arg_name.to_s)
55
52
  @type_expr = type_expr || type
@@ -70,7 +67,6 @@ module GraphQL
70
67
  @prepare = prepare
71
68
  @ast_node = ast_node
72
69
  @from_resolver = from_resolver
73
- @method_access = method_access
74
70
  self.deprecation_reason = deprecation_reason
75
71
 
76
72
  if directives
@@ -169,26 +165,6 @@ module GraphQL
169
165
  true
170
166
  end
171
167
 
172
- prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
173
-
174
- def to_graphql
175
- argument = GraphQL::Argument.new
176
- argument.name = @name
177
- argument.type = -> { type }
178
- argument.description = @description
179
- argument.metadata[:type_class] = self
180
- argument.as = @as
181
- argument.ast_node = ast_node
182
- argument.method_access = @method_access
183
- if NO_DEFAULT != @default_value
184
- argument.default_value = @default_value
185
- end
186
- if self.deprecation_reason
187
- argument.deprecation_reason = self.deprecation_reason
188
- end
189
- argument
190
- end
191
-
192
168
  def type=(new_type)
193
169
  validate_input_type(new_type)
194
170
  # This isn't true for LateBoundTypes, but we can assume those will
@@ -365,7 +365,6 @@ module GraphQL
365
365
  deprecation_reason: builder.build_deprecation_reason(argument_defn.directives),
366
366
  ast_node: argument_defn,
367
367
  camelize: false,
368
- method_access: false,
369
368
  directives: prepare_directives(argument_defn, type_resolver),
370
369
  **default_value_kwargs
371
370
  )
@@ -8,7 +8,6 @@ module GraphQL
8
8
  # - {.resolve}: Wraps field resolution (so it should call `yield` to continue)
9
9
  class Directive < GraphQL::Schema::Member
10
10
  extend GraphQL::Schema::Member::HasArguments
11
- extend GraphQL::Schema::Member::AcceptsDefinition
12
11
 
13
12
  class << self
14
13
  # Directives aren't types, they don't have kinds.
@@ -55,26 +54,6 @@ module GraphQL
55
54
  default_directive
56
55
  end
57
56
 
58
- prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
59
-
60
- def to_graphql
61
- defn = GraphQL::Directive.new
62
- defn.name = self.graphql_name
63
- defn.description = self.description
64
- defn.locations = self.locations
65
- defn.default_directive = self.default_directive
66
- defn.ast_node = ast_node
67
- defn.metadata[:type_class] = self
68
- all_argument_definitions.each do |arg_defn|
69
- arg_graphql = arg_defn.to_graphql(silence_deprecation_warning: true)
70
- defn.arguments[arg_graphql.name] = arg_graphql # rubocop:disable Development/ContextIsPassedCop -- legacy-related
71
- end
72
- # Make a reference to a classic-style Arguments class
73
- defn.arguments_class = GraphQL::Query::Arguments.construct_arguments_class(defn)
74
-
75
- defn
76
- end
77
-
78
57
  # If false, this part of the query won't be evaluated
79
58
  def include?(_object, arguments, context)
80
59
  static_include?(arguments, context)
@@ -20,10 +20,9 @@ module GraphQL
20
20
  # end
21
21
  class Schema
22
22
  class Enum < GraphQL::Schema::Member
23
- extend GraphQL::Schema::Member::AcceptsDefinition
24
23
  extend GraphQL::Schema::Member::ValidatesInput
25
24
 
26
- class UnresolvedValueError < GraphQL::EnumType::UnresolvedValueError
25
+ class UnresolvedValueError < GraphQL::Error
27
26
  def initialize(value:, enum:, context:)
28
27
  fix_message = ", but this isn't a valid value for `#{enum.graphql_name}`. Update the field or resolver to return one of `#{enum.graphql_name}`'s values instead."
29
28
  message = if (cp = context[:current_path]) && (cf = context[:current_field])
@@ -108,22 +107,6 @@ module GraphQL
108
107
  enum_values(context).each_with_object({}) { |val, obj| obj[val.graphql_name] = val }
109
108
  end
110
109
 
111
- prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
112
-
113
- # @return [GraphQL::EnumType]
114
- def to_graphql
115
- enum_type = GraphQL::EnumType.new
116
- enum_type.name = graphql_name
117
- enum_type.description = description
118
- enum_type.introspection = introspection
119
- enum_type.ast_node = ast_node
120
- values.each do |name, val|
121
- enum_type.add_value(val.deprecated_to_graphql)
122
- end
123
- enum_type.metadata[:type_class] = self
124
- enum_type
125
- end
126
-
127
110
  # @return [Class] for handling `value(...)` inputs and building `GraphQL::Enum::EnumValue`s out of them
128
111
  def enum_value_class(new_enum_value_class = nil)
129
112
  if new_enum_value_class
@@ -13,12 +13,6 @@ module GraphQL
13
13
  # # arguments to `value(...)` in Enum classes are passed here
14
14
  # super
15
15
  # end
16
- #
17
- # def to_graphql
18
- # enum_value = super
19
- # # customize the derived GraphQL::EnumValue here
20
- # enum_value
21
- # end
22
16
  # end
23
17
  #
24
18
  # class BaseEnum < GraphQL::Schema::Enum
@@ -26,8 +20,6 @@ module GraphQL
26
20
  # enum_value_class CustomEnumValue
27
21
  # end
28
22
  class EnumValue < GraphQL::Schema::Member
29
- include GraphQL::Schema::Member::CachedGraphQLDefinition
30
- include GraphQL::Schema::Member::AcceptsDefinition
31
23
  include GraphQL::Schema::Member::HasPath
32
24
  include GraphQL::Schema::Member::HasAstNode
33
25
  include GraphQL::Schema::Member::HasDirectives
@@ -73,20 +65,6 @@ module GraphQL
73
65
  @value
74
66
  end
75
67
 
76
- prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
77
-
78
- # @return [GraphQL::EnumType::EnumValue] A runtime-ready object derived from this object
79
- def to_graphql
80
- enum_value = GraphQL::EnumType::EnumValue.new
81
- enum_value.name = @graphql_name
82
- enum_value.description = @description
83
- enum_value.value = @value
84
- enum_value.deprecation_reason = self.deprecation_reason
85
- enum_value.metadata[:type_class] = self
86
- enum_value.ast_node = ast_node
87
- enum_value
88
- end
89
-
90
68
  def inspect
91
69
  "#<#{self.class} #{path} @value=#{@value.inspect}#{description ? " @description=#{description.inspect}" : ""}>"
92
70
  end
@@ -5,8 +5,6 @@ require "graphql/schema/field/scope_extension"
5
5
  module GraphQL
6
6
  class Schema
7
7
  class Field
8
- include GraphQL::Schema::Member::CachedGraphQLDefinition
9
- include GraphQL::Schema::Member::AcceptsDefinition
10
8
  include GraphQL::Schema::Member::HasArguments
11
9
  include GraphQL::Schema::Member::HasAstNode
12
10
  include GraphQL::Schema::Member::HasPath
@@ -84,16 +82,6 @@ module GraphQL
84
82
  # @return [GraphQL::Schema:Field] an instance of `self
85
83
  # @see {.initialize} for other options
86
84
  def self.from_options(name = nil, type = nil, desc = nil, resolver: nil, mutation: nil, subscription: nil,**kwargs, &block)
87
- if kwargs[:field]
88
- if kwargs[:field].is_a?(GraphQL::Field) && kwargs[:field] == GraphQL::Types::Relay::NodeField.graphql_definition
89
- GraphQL::Deprecation.warn("Legacy-style `GraphQL::Relay::Node.field` is being added to a class-based type. See `GraphQL::Types::Relay::NodeField` for a replacement.")
90
- return GraphQL::Types::Relay::NodeField
91
- elsif kwargs[:field].is_a?(GraphQL::Field) && kwargs[:field] == GraphQL::Types::Relay::NodesField.graphql_definition
92
- GraphQL::Deprecation.warn("Legacy-style `GraphQL::Relay::Node.plural_field` is being added to a class-based type. See `GraphQL::Types::Relay::NodesField` for a replacement.")
93
- return GraphQL::Types::Relay::NodesField
94
- end
95
- end
96
-
97
85
  if (parent_config = resolver || mutation || subscription)
98
86
  # Get the parent config, merge in local overrides
99
87
  kwargs = parent_config.field_options.merge(kwargs)
@@ -106,9 +94,6 @@ module GraphQL
106
94
  end
107
95
 
108
96
  if !type.nil?
109
- if type.is_a?(GraphQL::Field)
110
- raise ArgumentError, "A GraphQL::Field was passed as the second argument, use the `field:` keyword for this instead."
111
- end
112
97
  if desc
113
98
  if kwargs[:description]
114
99
  raise ArgumentError, "Provide description as a positional argument or `description:` keyword, but not both (#{desc.inspect}, #{kwargs[:description].inspect})"
@@ -212,8 +197,7 @@ module GraphQL
212
197
  # @param ast_node [Language::Nodes::FieldDefinition, nil] If this schema was parsed from definition, this AST node defined the field
213
198
  # @param method_conflict_warning [Boolean] If false, skip the warning if this field's method conflicts with a built-in method
214
199
  # @param validates [Array<Hash>] Configurations for validating this field
215
- # @param legacy_edge_class [Class, nil] (DEPRECATED) If present, pass this along to the legacy field definition
216
- def initialize(type: nil, name: nil, owner: nil, null: true, field: nil, function: nil, description: nil, deprecation_reason: nil, method: nil, hash_key: nil, dig: nil, resolver_method: nil, resolve: nil, connection: nil, max_page_size: :not_given, scope: nil, introspection: false, camelize: true, trace: nil, complexity: 1, ast_node: nil, extras: EMPTY_ARRAY, extensions: EMPTY_ARRAY, connection_extension: self.class.connection_extension, resolver_class: nil, subscription_scope: nil, relay_node_field: false, relay_nodes_field: false, method_conflict_warning: true, broadcastable: nil, arguments: EMPTY_HASH, directives: EMPTY_HASH, validates: EMPTY_ARRAY, legacy_edge_class: nil, &definition_block)
200
+ def initialize(type: nil, name: nil, owner: nil, null: true, field: nil, function: nil, description: nil, deprecation_reason: nil, method: nil, hash_key: nil, dig: nil, resolver_method: nil, resolve: nil, connection: nil, max_page_size: :not_given, scope: nil, introspection: false, camelize: true, trace: nil, complexity: 1, ast_node: nil, extras: EMPTY_ARRAY, extensions: EMPTY_ARRAY, connection_extension: self.class.connection_extension, resolver_class: nil, subscription_scope: nil, relay_node_field: false, relay_nodes_field: false, method_conflict_warning: true, broadcastable: nil, arguments: EMPTY_HASH, directives: EMPTY_HASH, validates: EMPTY_ARRAY, &definition_block)
217
201
  if name.nil?
218
202
  raise ArgumentError, "missing first `name` argument or keyword `name:`"
219
203
  end
@@ -277,7 +261,6 @@ module GraphQL
277
261
  @relay_nodes_field = relay_nodes_field
278
262
  @ast_node = ast_node
279
263
  @method_conflict_warning = method_conflict_warning
280
- @legacy_edge_class = legacy_edge_class
281
264
 
282
265
  arguments.each do |name, arg|
283
266
  case arg
@@ -508,82 +491,6 @@ module GraphQL
508
491
  # @return [Integer, nil] Applied to connections if {#has_max_page_size?}
509
492
  attr_reader :max_page_size
510
493
 
511
- prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
512
-
513
- # @return [GraphQL::Field]
514
- def to_graphql
515
- field_defn = if @field
516
- @field.dup
517
- elsif @function
518
- GraphQL::Function.build_field(@function)
519
- else
520
- GraphQL::Field.new
521
- end
522
-
523
- field_defn.name = @name
524
- if @return_type_expr
525
- field_defn.type = -> { type }
526
- end
527
-
528
- if @description
529
- field_defn.description = @description
530
- end
531
-
532
- if self.deprecation_reason
533
- field_defn.deprecation_reason = self.deprecation_reason
534
- end
535
-
536
- if @resolver_class
537
- if @resolver_class < GraphQL::Schema::Mutation
538
- field_defn.mutation = @resolver_class
539
- end
540
- field_defn.metadata[:resolver] = @resolver_class
541
- end
542
-
543
- if !@trace.nil?
544
- field_defn.trace = @trace
545
- end
546
-
547
- if @relay_node_field
548
- field_defn.relay_node_field = @relay_node_field
549
- end
550
-
551
- if @relay_nodes_field
552
- field_defn.relay_nodes_field = @relay_nodes_field
553
- end
554
-
555
- if @legacy_edge_class
556
- field_defn.edge_class = @legacy_edge_class
557
- end
558
-
559
- field_defn.resolve = self.method(:resolve_field)
560
- field_defn.connection = connection?
561
- field_defn.connection_max_page_size = max_page_size
562
- field_defn.introspection = @introspection
563
- field_defn.complexity = @complexity
564
- field_defn.subscription_scope = @subscription_scope
565
- field_defn.ast_node = ast_node
566
-
567
- all_argument_definitions.each do |defn|
568
- arg_graphql = defn.deprecated_to_graphql
569
- field_defn.arguments[arg_graphql.name] = arg_graphql # rubocop:disable Development/ContextIsPassedCop -- legacy-related
570
- end
571
-
572
- # Support a passed-in proc, one way or another
573
- @resolve_proc = if @resolve
574
- @resolve
575
- elsif @function
576
- @function
577
- elsif @field
578
- @field.resolve_proc
579
- end
580
-
581
- # Ok, `self` isn't a class, but this is for consistency with the classes
582
- field_defn.metadata[:type_class] = self
583
- field_defn.arguments_class = GraphQL::Query::Arguments.construct_arguments_class(field_defn)
584
- field_defn
585
- end
586
-
587
494
  class MissingReturnTypeError < GraphQL::Error; end
588
495
  attr_writer :type
589
496
 
@@ -666,37 +573,6 @@ module GraphQL
666
573
  end
667
574
  end
668
575
 
669
- # Implement {GraphQL::Field}'s resolve API.
670
- #
671
- # Eventually, we might hook up field instances to execution in another way. TBD.
672
- # @see #resolve for how the interpreter hooks up to it
673
- def resolve_field(obj, args, ctx)
674
- ctx.schema.after_lazy(obj) do |after_obj|
675
- # First, apply auth ...
676
- query_ctx = ctx.query.context
677
- # Some legacy fields can have `nil` here, not exactly sure why.
678
- # @see https://github.com/rmosolgo/graphql-ruby/issues/1990 before removing
679
- inner_obj = after_obj && after_obj.object
680
- ctx.schema.after_lazy(to_ruby_args(after_obj, args, ctx)) do |ruby_args|
681
- if authorized?(inner_obj, ruby_args, query_ctx)
682
- # Then if it passed, resolve the field
683
- if @resolve_proc
684
- # Might be nil, still want to call the func in that case
685
- with_extensions(inner_obj, ruby_args, query_ctx) do |extended_obj, extended_args|
686
- # Pass the GraphQL args here for compatibility:
687
- @resolve_proc.call(extended_obj, args, ctx)
688
- end
689
- else
690
- public_send_field(after_obj, ruby_args, query_ctx)
691
- end
692
- else
693
- err = GraphQL::UnauthorizedFieldError.new(object: inner_obj, type: obj.class, context: ctx, field: self)
694
- query_ctx.schema.unauthorized_field(err)
695
- end
696
- end
697
- end
698
- end
699
-
700
576
  # This method is called by the interpreter for each field.
701
577
  # You can extend it in your base field classes.
702
578
  # @param object [GraphQL::Schema::Object] An instance of some type class, wrapping an application object
@@ -729,7 +605,7 @@ module GraphQL
729
605
  err
730
606
  end
731
607
 
732
- # @param ctx [GraphQL::Query::Context::FieldResolutionContext]
608
+ # @param ctx [GraphQL::Query::Context]
733
609
  def fetch_extra(extra_name, ctx)
734
610
  if extra_name != :path && extra_name != :ast_node && respond_to?(extra_name)
735
611
  self.public_send(extra_name)
@@ -742,63 +618,6 @@ module GraphQL
742
618
 
743
619
  private
744
620
 
745
- NO_ARGS = {}.freeze
746
-
747
- # Convert a GraphQL arguments instance into a Ruby-style hash.
748
- #
749
- # @param obj [GraphQL::Schema::Object] The object where this field is being resolved
750
- # @param graphql_args [GraphQL::Query::Arguments]
751
- # @param field_ctx [GraphQL::Query::Context::FieldResolutionContext]
752
- # @return [Hash<Symbol => Any>]
753
- def to_ruby_args(obj, graphql_args, field_ctx)
754
- if graphql_args.any? || @extras.any?
755
- # Splat the GraphQL::Arguments to Ruby keyword arguments
756
- ruby_kwargs = graphql_args.to_kwargs
757
- maybe_lazies = []
758
- # Apply any `prepare` methods. Not great code organization, can this go somewhere better?
759
- arguments(field_ctx).each do |name, arg_defn|
760
- ruby_kwargs_key = arg_defn.keyword
761
-
762
- if ruby_kwargs.key?(ruby_kwargs_key)
763
- loads = arg_defn.loads
764
- value = ruby_kwargs[ruby_kwargs_key]
765
- loaded_value = if loads && !arg_defn.from_resolver?
766
- if arg_defn.type.list?
767
- loaded_values = value.map { |val| load_application_object(arg_defn, loads, val, field_ctx.query.context) }
768
- field_ctx.schema.after_any_lazies(loaded_values) { |result| result }
769
- else
770
- load_application_object(arg_defn, loads, value, field_ctx.query.context)
771
- end
772
- elsif arg_defn.type.list? && value.is_a?(Array)
773
- field_ctx.schema.after_any_lazies(value, &:itself)
774
- else
775
- value
776
- end
777
-
778
- maybe_lazies << field_ctx.schema.after_lazy(loaded_value) do |loaded_value|
779
- prepared_value = if arg_defn.prepare
780
- arg_defn.prepare_value(obj, loaded_value)
781
- else
782
- loaded_value
783
- end
784
-
785
- ruby_kwargs[ruby_kwargs_key] = prepared_value
786
- end
787
- end
788
- end
789
-
790
- @extras.each do |extra_arg|
791
- ruby_kwargs[extra_arg] = fetch_extra(extra_arg, field_ctx)
792
- end
793
-
794
- field_ctx.schema.after_any_lazies(maybe_lazies) do
795
- ruby_kwargs
796
- end
797
- else
798
- NO_ARGS
799
- end
800
- end
801
-
802
621
  def public_send_field(unextended_obj, unextended_ruby_kwargs, query_ctx)
803
622
  with_extensions(unextended_obj, unextended_ruby_kwargs, query_ctx) do |obj, ruby_kwargs|
804
623
  begin
@@ -2,7 +2,6 @@
2
2
  module GraphQL
3
3
  class Schema
4
4
  class InputObject < GraphQL::Schema::Member
5
- extend GraphQL::Schema::Member::AcceptsDefinition
6
5
  extend Forwardable
7
6
  extend GraphQL::Schema::Member::HasArguments
8
7
  extend GraphQL::Schema::Member::HasArguments::ArgumentObjectLoader
@@ -13,49 +12,28 @@ module GraphQL
13
12
 
14
13
  # @return [GraphQL::Query::Context] The context for this query
15
14
  attr_reader :context
16
- # @return [GraphQL::Query::Arguments, GraphQL::Execution::Interpereter::Arguments] The underlying arguments instance
15
+ # @return [GraphQL::Execution::Interpereter::Arguments] The underlying arguments instance
17
16
  attr_reader :arguments
18
17
 
19
18
  # Ruby-like hash behaviors, read-only
20
19
  def_delegators :@ruby_style_hash, :keys, :values, :each, :map, :any?, :empty?
21
20
 
22
- def initialize(arguments = nil, ruby_kwargs: nil, context:, defaults_used:)
21
+ def initialize(arguments, ruby_kwargs:, context:, defaults_used:)
23
22
  @context = context
24
- if ruby_kwargs
25
- @ruby_style_hash = ruby_kwargs
26
- @arguments = arguments
27
- else
28
- @arguments = self.class.arguments_class.new(arguments, context: context, defaults_used: defaults_used)
29
- # Symbolized, underscored hash:
30
- @ruby_style_hash = @arguments.to_kwargs
31
- end
23
+ @ruby_style_hash = ruby_kwargs
24
+ @arguments = arguments
32
25
  # Apply prepares, not great to have it duplicated here.
33
- maybe_lazies = []
34
26
  self.class.arguments(context).each_value do |arg_defn|
35
27
  ruby_kwargs_key = arg_defn.keyword
36
-
37
28
  if @ruby_style_hash.key?(ruby_kwargs_key)
38
- loads = arg_defn.loads
39
- # Resolvers do this loading themselves;
40
- # With the interpreter, it's done during `coerce_arguments`
41
- if loads && !arg_defn.from_resolver? && !context.interpreter?
42
- value = @ruby_style_hash[ruby_kwargs_key]
43
- loaded_value = arg_defn.load_and_authorize_value(self, value, context)
44
- maybe_lazies << context.schema.after_lazy(loaded_value) do |loaded_value|
45
- overwrite_argument(ruby_kwargs_key, loaded_value)
46
- end
47
- end
48
-
49
29
  # Weirdly, procs are applied during coercion, but not methods.
50
30
  # Probably because these methods require a `self`.
51
- if arg_defn.prepare.is_a?(Symbol) || context.nil? || !context.interpreter?
31
+ if arg_defn.prepare.is_a?(Symbol) || context.nil?
52
32
  prepared_value = arg_defn.prepare_value(self, @ruby_style_hash[ruby_kwargs_key])
53
33
  overwrite_argument(ruby_kwargs_key, prepared_value)
54
34
  end
55
35
  end
56
36
  end
57
-
58
- @maybe_lazies = maybe_lazies
59
37
  end
60
38
 
61
39
  def to_h
@@ -68,12 +46,10 @@ module GraphQL
68
46
 
69
47
  def prepare
70
48
  if @context
71
- @context.schema.after_any_lazies(@maybe_lazies) do
72
- object = @context[:current_object]
73
- # Pass this object's class with `as` so that messages are rendered correctly from inherited validators
74
- Schema::Validator.validate!(self.class.validators, object, @context, @ruby_style_hash, as: self.class)
75
- self
76
- end
49
+ object = @context[:current_object]
50
+ # Pass this object's class with `as` so that messages are rendered correctly from inherited validators
51
+ Schema::Validator.validate!(self.class.validators, object, @context, @ruby_style_hash, as: self.class)
52
+ self
77
53
  else
78
54
  self
79
55
  end
@@ -83,7 +59,6 @@ module GraphQL
83
59
  # Authorize each argument (but this doesn't apply if `prepare` is implemented):
84
60
  if value.respond_to?(:key?)
85
61
  arguments(ctx).each do |_name, input_obj_arg|
86
- input_obj_arg = input_obj_arg.type_class
87
62
  if value.key?(input_obj_arg.keyword) &&
88
63
  !input_obj_arg.authorized?(obj, value[input_obj_arg.keyword], ctx)
89
64
  return false
@@ -132,9 +107,6 @@ module GraphQL
132
107
  end
133
108
 
134
109
  class << self
135
- # @return [Class<GraphQL::Arguments>]
136
- attr_accessor :arguments_class
137
-
138
110
  def argument(*args, **kwargs, &block)
139
111
  argument_defn = super(*args, **kwargs, &block)
140
112
  # Add a method access
@@ -147,25 +119,6 @@ module GraphQL
147
119
  argument_defn
148
120
  end
149
121
 
150
- prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
151
-
152
- def to_graphql
153
- type_defn = GraphQL::InputObjectType.new
154
- type_defn.name = graphql_name
155
- type_defn.description = description
156
- type_defn.metadata[:type_class] = self
157
- type_defn.mutation = mutation
158
- type_defn.ast_node = ast_node
159
- all_argument_definitions.each do |arg|
160
- type_defn.arguments[arg.graphql_definition(silence_deprecation_warning: true).name] = arg.graphql_definition(silence_deprecation_warning: true) # rubocop:disable Development/ContextIsPassedCop -- legacy-related
161
- end
162
- # Make a reference to a classic-style Arguments class
163
- self.arguments_class = GraphQL::Query::Arguments.construct_arguments_class(type_defn)
164
- # But use this InputObject class at runtime
165
- type_defn.arguments_class = self
166
- type_defn
167
- end
168
-
169
122
  def kind
170
123
  GraphQL::TypeKinds::INPUT_OBJECT
171
124
  end
@@ -4,8 +4,6 @@ module GraphQL
4
4
  module Interface
5
5
  include GraphQL::Schema::Member::GraphQLTypeNames
6
6
  module DefinitionMethods
7
- include GraphQL::Schema::Member::CachedGraphQLDefinition
8
- include GraphQL::Relay::TypeExtensions
9
7
  include GraphQL::Schema::Member::BaseDSLMethods
10
8
  # ConfigurationExtension's responsibilities are in `def included` below
11
9
  include GraphQL::Schema::Member::TypeSystemHelpers
@@ -100,34 +98,11 @@ module GraphQL
100
98
  end
101
99
  end
102
100
 
103
- prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
104
-
105
- def to_graphql
106
- type_defn = GraphQL::InterfaceType.new
107
- type_defn.name = graphql_name
108
- type_defn.description = description
109
- type_defn.orphan_types = orphan_types
110
- type_defn.type_membership_class = self.type_membership_class
111
- type_defn.ast_node = ast_node
112
- fields.each do |field_name, field_inst| # rubocop:disable Development/ContextIsPassedCop -- legacy-related
113
- field_defn = field_inst.graphql_definition(silence_deprecation_warning: true)
114
- type_defn.fields[field_defn.name] = field_defn # rubocop:disable Development/ContextIsPassedCop -- legacy-related
115
- end
116
- type_defn.metadata[:type_class] = self
117
- if respond_to?(:resolve_type)
118
- type_defn.resolve_type = method(:resolve_type)
119
- end
120
- type_defn
121
- end
122
-
123
101
  def kind
124
102
  GraphQL::TypeKinds::INTERFACE
125
103
  end
126
104
  end
127
105
 
128
- # Extend this _after_ `DefinitionMethods` is defined, so it will be used
129
- extend GraphQL::Schema::Member::AcceptsDefinition
130
-
131
106
  extend DefinitionMethods
132
107
 
133
108
  def unwrap
@@ -89,9 +89,9 @@ module GraphQL
89
89
  case late_bound_type
90
90
  when GraphQL::Schema::LateBoundType
91
91
  @schema.get_type(late_bound_type.name)
92
- when GraphQL::Schema::List, GraphQL::ListType
92
+ when GraphQL::Schema::List
93
93
  resolve_late_binding(late_bound_type.of_type).to_list_type
94
- when GraphQL::Schema::NonNull, GraphQL::NonNullType
94
+ when GraphQL::Schema::NonNull
95
95
  resolve_late_binding(late_bound_type.of_type).to_non_null_type
96
96
  when Module
97
97
  # It's a normal type -- no change required
@@ -103,12 +103,7 @@ module GraphQL
103
103
 
104
104
  def load_constant(class_name)
105
105
  const = @custom_namespace.const_get(class_name)
106
- if @class_based
107
- dup_type_class(const)
108
- else
109
- # Use `.to_graphql` to get a freshly-made version, not shared between schemas
110
- const.deprecated_to_graphql
111
- end
106
+ dup_type_class(const)
112
107
  rescue NameError
113
108
  # Dup the built-in so that the cached fields aren't shared
114
109
  dup_type_class(@built_in_namespace.const_get(class_name))
@@ -16,11 +16,11 @@ module GraphQL
16
16
  end
17
17
 
18
18
  def to_non_null_type
19
- @to_non_null_type ||= GraphQL::NonNullType.new(of_type: self)
19
+ @to_non_null_type ||= GraphQL::Schema::NonNull.new(self)
20
20
  end
21
21
 
22
22
  def to_list_type
23
- @to_list_type ||= GraphQL::ListType.new(of_type: self)
23
+ @to_list_type ||= GraphQL::Schema::List.new(self)
24
24
  end
25
25
 
26
26
  def inspect
@@ -8,12 +8,6 @@ module GraphQL
8
8
  class List < GraphQL::Schema::Wrapper
9
9
  include Schema::Member::ValidatesInput
10
10
 
11
- prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
12
-
13
- def to_graphql
14
- @of_type.graphql_definition(silence_deprecation_warning: true).to_list_type
15
- end
16
-
17
11
  # @return [GraphQL::TypeKinds::LIST]
18
12
  def kind
19
13
  GraphQL::TypeKinds::LIST
@@ -202,7 +202,6 @@ module GraphQL
202
202
  description: arg["description"],
203
203
  deprecation_reason: arg["deprecationReason"],
204
204
  required: false,
205
- method_access: false,
206
205
  camelize: false,
207
206
  }
208
207
 
@@ -94,11 +94,6 @@ module GraphQL
94
94
  end
95
95
  end
96
96
 
97
- # @return [GraphQL::BaseType] Convert this type to a legacy-style object.
98
- def to_graphql
99
- raise GraphQL::RequiredImplementationMissingError
100
- end
101
-
102
97
  alias :unwrap :itself
103
98
 
104
99
  # Creates the default name for a schema member.