graphql 1.13.23 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) 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 +6 -13
  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/directive_type.rb +2 -2
  19. data/lib/graphql/introspection/dynamic_fields.rb +3 -8
  20. data/lib/graphql/introspection/entry_points.rb +2 -15
  21. data/lib/graphql/introspection/field_type.rb +1 -1
  22. data/lib/graphql/introspection/schema_type.rb +2 -2
  23. data/lib/graphql/introspection/type_type.rb +5 -5
  24. data/lib/graphql/language/document_from_schema_definition.rb +0 -17
  25. data/lib/graphql/pagination/connections.rb +2 -28
  26. data/lib/graphql/query/context.rb +1 -185
  27. data/lib/graphql/query/input_validation_result.rb +0 -9
  28. data/lib/graphql/query/literal_input.rb +8 -13
  29. data/lib/graphql/query/validation_pipeline.rb +6 -34
  30. data/lib/graphql/query/variable_validation_error.rb +2 -2
  31. data/lib/graphql/query/variables.rb +8 -31
  32. data/lib/graphql/query.rb +5 -34
  33. data/lib/graphql/railtie.rb +0 -104
  34. data/lib/graphql/relay/range_add.rb +0 -4
  35. data/lib/graphql/relay.rb +0 -15
  36. data/lib/graphql/schema/addition.rb +1 -8
  37. data/lib/graphql/schema/argument.rb +1 -25
  38. data/lib/graphql/schema/build_from_definition.rb +0 -1
  39. data/lib/graphql/schema/directive.rb +1 -22
  40. data/lib/graphql/schema/enum.rb +3 -19
  41. data/lib/graphql/schema/enum_value.rb +0 -22
  42. data/lib/graphql/schema/field.rb +22 -220
  43. data/lib/graphql/schema/input_object.rb +11 -57
  44. data/lib/graphql/schema/interface.rb +1 -30
  45. data/lib/graphql/schema/introspection_system.rb +3 -8
  46. data/lib/graphql/schema/late_bound_type.rb +2 -2
  47. data/lib/graphql/schema/list.rb +3 -24
  48. data/lib/graphql/schema/loader.rb +0 -1
  49. data/lib/graphql/schema/member/base_dsl_methods.rb +1 -6
  50. data/lib/graphql/schema/member/build_type.rb +4 -6
  51. data/lib/graphql/schema/member/has_arguments.rb +16 -20
  52. data/lib/graphql/schema/member/has_fields.rb +3 -3
  53. data/lib/graphql/schema/member/has_interfaces.rb +1 -13
  54. data/lib/graphql/schema/member/validates_input.rb +2 -2
  55. data/lib/graphql/schema/member.rb +0 -6
  56. data/lib/graphql/schema/mutation.rb +0 -9
  57. data/lib/graphql/schema/non_null.rb +3 -9
  58. data/lib/graphql/schema/object.rb +0 -40
  59. data/lib/graphql/schema/relay_classic_mutation.rb +17 -28
  60. data/lib/graphql/schema/scalar.rb +1 -16
  61. data/lib/graphql/schema/union.rb +0 -16
  62. data/lib/graphql/schema/warden.rb +3 -12
  63. data/lib/graphql/schema/wrapper.rb +0 -5
  64. data/lib/graphql/schema.rb +106 -945
  65. data/lib/graphql/static_validation/base_visitor.rb +4 -21
  66. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +12 -12
  67. data/lib/graphql/static_validation/validator.rb +2 -24
  68. data/lib/graphql/static_validation.rb +0 -2
  69. data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +38 -1
  70. data/lib/graphql/subscriptions/event.rb +1 -1
  71. data/lib/graphql/subscriptions/instrumentation.rb +0 -51
  72. data/lib/graphql/subscriptions.rb +4 -13
  73. data/lib/graphql/tracing/data_dog_tracing.rb +16 -20
  74. data/lib/graphql/tracing/platform_tracing.rb +4 -32
  75. data/lib/graphql/tracing.rb +0 -1
  76. data/lib/graphql/types/relay/connection_behaviors.rb +2 -6
  77. data/lib/graphql/types/relay/default_relay.rb +0 -10
  78. data/lib/graphql/types/relay/node_behaviors.rb +5 -1
  79. data/lib/graphql/types/relay.rb +0 -2
  80. data/lib/graphql/types/string.rb +1 -1
  81. data/lib/graphql/version.rb +1 -1
  82. data/lib/graphql.rb +1 -66
  83. metadata +28 -167
  84. data/lib/graphql/analysis/analyze_query.rb +0 -98
  85. data/lib/graphql/analysis/field_usage.rb +0 -45
  86. data/lib/graphql/analysis/max_query_complexity.rb +0 -26
  87. data/lib/graphql/analysis/max_query_depth.rb +0 -26
  88. data/lib/graphql/analysis/query_complexity.rb +0 -88
  89. data/lib/graphql/analysis/query_depth.rb +0 -43
  90. data/lib/graphql/analysis/reducer_state.rb +0 -48
  91. data/lib/graphql/argument.rb +0 -131
  92. data/lib/graphql/authorization.rb +0 -82
  93. data/lib/graphql/backtrace/legacy_tracer.rb +0 -56
  94. data/lib/graphql/backwards_compatibility.rb +0 -61
  95. data/lib/graphql/base_type.rb +0 -232
  96. data/lib/graphql/boolean_type.rb +0 -2
  97. data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
  98. data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
  99. data/lib/graphql/compatibility/execution_specification.rb +0 -436
  100. data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
  101. data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -215
  102. data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -87
  103. data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
  104. data/lib/graphql/compatibility/query_parser_specification.rb +0 -266
  105. data/lib/graphql/compatibility/schema_parser_specification.rb +0 -682
  106. data/lib/graphql/compatibility.rb +0 -5
  107. data/lib/graphql/define/assign_argument.rb +0 -12
  108. data/lib/graphql/define/assign_connection.rb +0 -13
  109. data/lib/graphql/define/assign_enum_value.rb +0 -18
  110. data/lib/graphql/define/assign_global_id_field.rb +0 -11
  111. data/lib/graphql/define/assign_mutation_function.rb +0 -34
  112. data/lib/graphql/define/assign_object_field.rb +0 -42
  113. data/lib/graphql/define/defined_object_proxy.rb +0 -53
  114. data/lib/graphql/define/instance_definable.rb +0 -255
  115. data/lib/graphql/define/no_definition_error.rb +0 -7
  116. data/lib/graphql/define/non_null_with_bang.rb +0 -16
  117. data/lib/graphql/define/type_definer.rb +0 -31
  118. data/lib/graphql/define.rb +0 -31
  119. data/lib/graphql/deprecated_dsl.rb +0 -55
  120. data/lib/graphql/directive/deprecated_directive.rb +0 -2
  121. data/lib/graphql/directive/include_directive.rb +0 -2
  122. data/lib/graphql/directive/skip_directive.rb +0 -2
  123. data/lib/graphql/directive.rb +0 -107
  124. data/lib/graphql/enum_type.rb +0 -133
  125. data/lib/graphql/execution/execute.rb +0 -333
  126. data/lib/graphql/execution/flatten.rb +0 -40
  127. data/lib/graphql/execution/typecast.rb +0 -50
  128. data/lib/graphql/field/resolve.rb +0 -59
  129. data/lib/graphql/field.rb +0 -226
  130. data/lib/graphql/float_type.rb +0 -2
  131. data/lib/graphql/function.rb +0 -128
  132. data/lib/graphql/id_type.rb +0 -2
  133. data/lib/graphql/input_object_type.rb +0 -138
  134. data/lib/graphql/int_type.rb +0 -2
  135. data/lib/graphql/interface_type.rb +0 -72
  136. data/lib/graphql/internal_representation/document.rb +0 -27
  137. data/lib/graphql/internal_representation/node.rb +0 -206
  138. data/lib/graphql/internal_representation/print.rb +0 -51
  139. data/lib/graphql/internal_representation/rewrite.rb +0 -184
  140. data/lib/graphql/internal_representation/scope.rb +0 -88
  141. data/lib/graphql/internal_representation/visit.rb +0 -36
  142. data/lib/graphql/internal_representation.rb +0 -7
  143. data/lib/graphql/list_type.rb +0 -80
  144. data/lib/graphql/non_null_type.rb +0 -71
  145. data/lib/graphql/object_type.rb +0 -130
  146. data/lib/graphql/query/arguments.rb +0 -189
  147. data/lib/graphql/query/arguments_cache.rb +0 -24
  148. data/lib/graphql/query/executor.rb +0 -52
  149. data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
  150. data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
  151. data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
  152. data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
  153. data/lib/graphql/query/serial_execution.rb +0 -40
  154. data/lib/graphql/relay/array_connection.rb +0 -83
  155. data/lib/graphql/relay/base_connection.rb +0 -189
  156. data/lib/graphql/relay/connection_instrumentation.rb +0 -54
  157. data/lib/graphql/relay/connection_resolve.rb +0 -43
  158. data/lib/graphql/relay/connection_type.rb +0 -54
  159. data/lib/graphql/relay/edge.rb +0 -27
  160. data/lib/graphql/relay/edge_type.rb +0 -19
  161. data/lib/graphql/relay/edges_instrumentation.rb +0 -39
  162. data/lib/graphql/relay/global_id_resolve.rb +0 -17
  163. data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
  164. data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
  165. data/lib/graphql/relay/mutation/resolve.rb +0 -56
  166. data/lib/graphql/relay/mutation/result.rb +0 -38
  167. data/lib/graphql/relay/mutation.rb +0 -106
  168. data/lib/graphql/relay/node.rb +0 -39
  169. data/lib/graphql/relay/page_info.rb +0 -7
  170. data/lib/graphql/relay/relation_connection.rb +0 -188
  171. data/lib/graphql/relay/type_extensions.rb +0 -32
  172. data/lib/graphql/scalar_type.rb +0 -91
  173. data/lib/graphql/schema/catchall_middleware.rb +0 -35
  174. data/lib/graphql/schema/default_parse_error.rb +0 -10
  175. data/lib/graphql/schema/default_type_error.rb +0 -17
  176. data/lib/graphql/schema/member/accepts_definition.rb +0 -164
  177. data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -58
  178. data/lib/graphql/schema/member/instrumentation.rb +0 -131
  179. data/lib/graphql/schema/middleware_chain.rb +0 -82
  180. data/lib/graphql/schema/possible_types.rb +0 -44
  181. data/lib/graphql/schema/rescue_middleware.rb +0 -60
  182. data/lib/graphql/schema/timeout_middleware.rb +0 -88
  183. data/lib/graphql/schema/traversal.rb +0 -228
  184. data/lib/graphql/schema/validation.rb +0 -313
  185. data/lib/graphql/static_validation/default_visitor.rb +0 -15
  186. data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
  187. data/lib/graphql/string_type.rb +0 -2
  188. data/lib/graphql/subscriptions/subscription_root.rb +0 -76
  189. data/lib/graphql/tracing/skylight_tracing.rb +0 -70
  190. data/lib/graphql/types/relay/node_field.rb +0 -24
  191. data/lib/graphql/types/relay/nodes_field.rb +0 -43
  192. data/lib/graphql/union_type.rb +0 -115
  193. data/lib/graphql/upgrader/member.rb +0 -937
  194. data/lib/graphql/upgrader/schema.rb +0 -38
@@ -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})"
@@ -176,8 +161,6 @@ module GraphQL
176
161
 
177
162
  # @return Boolean
178
163
  attr_reader :relay_node_field
179
- # @return Boolean
180
- attr_reader :relay_nodes_field
181
164
 
182
165
  # @return [Boolean] Should we warn if this field's name conflicts with a built-in method?
183
166
  def method_conflict_warning?
@@ -214,8 +197,7 @@ module GraphQL
214
197
  # @param ast_node [Language::Nodes::FieldDefinition, nil] If this schema was parsed from definition, this AST node defined the field
215
198
  # @param method_conflict_warning [Boolean] If false, skip the warning if this field's method conflicts with a built-in method
216
199
  # @param validates [Array<Hash>] Configurations for validating this field
217
- # @param legacy_edge_class [Class, nil] (DEPRECATED) If present, pass this along to the legacy field definition
218
- 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)
219
201
  if name.nil?
220
202
  raise ArgumentError, "missing first `name` argument or keyword `name:`"
221
203
  end
@@ -229,7 +211,6 @@ module GraphQL
229
211
  end
230
212
  @original_name = name
231
213
  name_s = -name.to_s
232
-
233
214
  @underscored_name = -Member::BuildType.underscore(name_s)
234
215
  @name = -(camelize ? Member::BuildType.camelize(name_s) : name_s)
235
216
  @description = description
@@ -259,10 +240,6 @@ module GraphQL
259
240
  # TODO: I think non-string/symbol hash keys are wrongly normalized (eg `1` will not work)
260
241
  method_name = method || hash_key || name_s
261
242
  @dig_keys = dig
262
- if hash_key
263
- @hash_key = hash_key
264
- end
265
-
266
243
  resolver_method ||= name_s.to_sym
267
244
 
268
245
  @method_str = -method_name.to_s
@@ -284,7 +261,6 @@ module GraphQL
284
261
  @relay_nodes_field = relay_nodes_field
285
262
  @ast_node = ast_node
286
263
  @method_conflict_warning = method_conflict_warning
287
- @legacy_edge_class = legacy_edge_class
288
264
 
289
265
  arguments.each do |name, arg|
290
266
  case arg
@@ -478,13 +454,7 @@ module GraphQL
478
454
  case defined_complexity
479
455
  when Proc
480
456
  arguments = query.arguments_for(nodes.first, self)
481
- if arguments.is_a?(GraphQL::ExecutionError)
482
- return child_complexity
483
- elsif arguments.respond_to?(:keyword_arguments)
484
- arguments = arguments.keyword_arguments
485
- end
486
-
487
- defined_complexity.call(query.context, arguments, child_complexity)
457
+ defined_complexity.call(query.context, arguments.keyword_arguments, child_complexity)
488
458
  when Numeric
489
459
  defined_complexity + child_complexity
490
460
  else
@@ -521,82 +491,6 @@ module GraphQL
521
491
  # @return [Integer, nil] Applied to connections if {#has_max_page_size?}
522
492
  attr_reader :max_page_size
523
493
 
524
- prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
525
-
526
- # @return [GraphQL::Field]
527
- def to_graphql
528
- field_defn = if @field
529
- @field.dup
530
- elsif @function
531
- GraphQL::Function.build_field(@function)
532
- else
533
- GraphQL::Field.new
534
- end
535
-
536
- field_defn.name = @name
537
- if @return_type_expr
538
- field_defn.type = -> { type }
539
- end
540
-
541
- if @description
542
- field_defn.description = @description
543
- end
544
-
545
- if self.deprecation_reason
546
- field_defn.deprecation_reason = self.deprecation_reason
547
- end
548
-
549
- if @resolver_class
550
- if @resolver_class < GraphQL::Schema::Mutation
551
- field_defn.mutation = @resolver_class
552
- end
553
- field_defn.metadata[:resolver] = @resolver_class
554
- end
555
-
556
- if !@trace.nil?
557
- field_defn.trace = @trace
558
- end
559
-
560
- if @relay_node_field
561
- field_defn.relay_node_field = @relay_node_field
562
- end
563
-
564
- if @relay_nodes_field
565
- field_defn.relay_nodes_field = @relay_nodes_field
566
- end
567
-
568
- if @legacy_edge_class
569
- field_defn.edge_class = @legacy_edge_class
570
- end
571
-
572
- field_defn.resolve = self.method(:resolve_field)
573
- field_defn.connection = connection?
574
- field_defn.connection_max_page_size = max_page_size
575
- field_defn.introspection = @introspection
576
- field_defn.complexity = @complexity
577
- field_defn.subscription_scope = @subscription_scope
578
- field_defn.ast_node = ast_node
579
-
580
- all_argument_definitions.each do |defn|
581
- arg_graphql = defn.deprecated_to_graphql
582
- field_defn.arguments[arg_graphql.name] = arg_graphql # rubocop:disable Development/ContextIsPassedCop -- legacy-related
583
- end
584
-
585
- # Support a passed-in proc, one way or another
586
- @resolve_proc = if @resolve
587
- @resolve
588
- elsif @function
589
- @function
590
- elsif @field
591
- @field.resolve_proc
592
- end
593
-
594
- # Ok, `self` isn't a class, but this is for consistency with the classes
595
- field_defn.metadata[:type_class] = self
596
- field_defn.arguments_class = GraphQL::Query::Arguments.construct_arguments_class(field_defn)
597
- field_defn
598
- end
599
-
600
494
  class MissingReturnTypeError < GraphQL::Error; end
601
495
  attr_writer :type
602
496
 
@@ -651,64 +545,31 @@ module GraphQL
651
545
  arg_values = args
652
546
  using_arg_values = false
653
547
  end
654
- if args.size > 0
655
- args = context.warden.arguments(self)
656
- args.each do |arg|
657
- arg_key = arg.keyword
658
- if arg_values.key?(arg_key)
659
- arg_value = arg_values[arg_key]
660
- if using_arg_values
661
- if arg_value.default_used?
662
- # pass -- no auth required for default used
663
- next
664
- else
665
- application_arg_value = arg_value.value
666
- if application_arg_value.is_a?(GraphQL::Execution::Interpreter::Arguments)
667
- application_arg_value.keyword_arguments
668
- end
669
- end
548
+ # Faster than `.any?`
549
+ arguments(context).each_value do |arg|
550
+ arg_key = arg.keyword
551
+ if arg_values.key?(arg_key)
552
+ arg_value = arg_values[arg_key]
553
+ if using_arg_values
554
+ if arg_value.default_used?
555
+ # pass -- no auth required for default used
556
+ next
670
557
  else
671
- application_arg_value = arg_value
672
- end
673
-
674
- if !arg.authorized?(object, application_arg_value, context)
675
- return false
558
+ application_arg_value = arg_value.value
559
+ if application_arg_value.is_a?(GraphQL::Execution::Interpreter::Arguments)
560
+ application_arg_value.keyword_arguments
561
+ end
676
562
  end
563
+ else
564
+ application_arg_value = arg_value
677
565
  end
678
- end
679
- end
680
- true
681
- end
682
- end
683
566
 
684
- # Implement {GraphQL::Field}'s resolve API.
685
- #
686
- # Eventually, we might hook up field instances to execution in another way. TBD.
687
- # @see #resolve for how the interpreter hooks up to it
688
- def resolve_field(obj, args, ctx)
689
- ctx.schema.after_lazy(obj) do |after_obj|
690
- # First, apply auth ...
691
- query_ctx = ctx.query.context
692
- # Some legacy fields can have `nil` here, not exactly sure why.
693
- # @see https://github.com/rmosolgo/graphql-ruby/issues/1990 before removing
694
- inner_obj = after_obj && after_obj.object
695
- ctx.schema.after_lazy(to_ruby_args(after_obj, args, ctx)) do |ruby_args|
696
- if authorized?(inner_obj, ruby_args, query_ctx)
697
- # Then if it passed, resolve the field
698
- if @resolve_proc
699
- # Might be nil, still want to call the func in that case
700
- with_extensions(inner_obj, ruby_args, query_ctx) do |extended_obj, extended_args|
701
- # Pass the GraphQL args here for compatibility:
702
- @resolve_proc.call(extended_obj, args, ctx)
703
- end
704
- else
705
- public_send_field(after_obj, ruby_args, query_ctx)
567
+ if !arg.authorized?(object, application_arg_value, context)
568
+ return false
706
569
  end
707
- else
708
- err = GraphQL::UnauthorizedFieldError.new(object: inner_obj, type: obj.class, context: ctx, field: self)
709
- query_ctx.schema.unauthorized_field(err)
710
570
  end
711
571
  end
572
+ true
712
573
  end
713
574
  end
714
575
 
@@ -744,7 +605,7 @@ module GraphQL
744
605
  err
745
606
  end
746
607
 
747
- # @param ctx [GraphQL::Query::Context::FieldResolutionContext]
608
+ # @param ctx [GraphQL::Query::Context]
748
609
  def fetch_extra(extra_name, ctx)
749
610
  if extra_name != :path && extra_name != :ast_node && respond_to?(extra_name)
750
611
  self.public_send(extra_name)
@@ -757,63 +618,6 @@ module GraphQL
757
618
 
758
619
  private
759
620
 
760
- NO_ARGS = {}.freeze
761
-
762
- # Convert a GraphQL arguments instance into a Ruby-style hash.
763
- #
764
- # @param obj [GraphQL::Schema::Object] The object where this field is being resolved
765
- # @param graphql_args [GraphQL::Query::Arguments]
766
- # @param field_ctx [GraphQL::Query::Context::FieldResolutionContext]
767
- # @return [Hash<Symbol => Any>]
768
- def to_ruby_args(obj, graphql_args, field_ctx)
769
- if graphql_args.any? || @extras.any?
770
- # Splat the GraphQL::Arguments to Ruby keyword arguments
771
- ruby_kwargs = graphql_args.to_kwargs
772
- maybe_lazies = []
773
- # Apply any `prepare` methods. Not great code organization, can this go somewhere better?
774
- arguments(field_ctx).each do |name, arg_defn|
775
- ruby_kwargs_key = arg_defn.keyword
776
-
777
- if ruby_kwargs.key?(ruby_kwargs_key)
778
- loads = arg_defn.loads
779
- value = ruby_kwargs[ruby_kwargs_key]
780
- loaded_value = if loads && !arg_defn.from_resolver?
781
- if arg_defn.type.list?
782
- loaded_values = value.map { |val| load_application_object(arg_defn, loads, val, field_ctx.query.context) }
783
- field_ctx.schema.after_any_lazies(loaded_values) { |result| result }
784
- else
785
- load_application_object(arg_defn, loads, value, field_ctx.query.context)
786
- end
787
- elsif arg_defn.type.list? && value.is_a?(Array)
788
- field_ctx.schema.after_any_lazies(value, &:itself)
789
- else
790
- value
791
- end
792
-
793
- maybe_lazies << field_ctx.schema.after_lazy(loaded_value) do |loaded_value|
794
- prepared_value = if arg_defn.prepare
795
- arg_defn.prepare_value(obj, loaded_value)
796
- else
797
- loaded_value
798
- end
799
-
800
- ruby_kwargs[ruby_kwargs_key] = prepared_value
801
- end
802
- end
803
- end
804
-
805
- @extras.each do |extra_arg|
806
- ruby_kwargs[extra_arg] = fetch_extra(extra_arg, field_ctx)
807
- end
808
-
809
- field_ctx.schema.after_any_lazies(maybe_lazies) do
810
- ruby_kwargs
811
- end
812
- else
813
- NO_ARGS
814
- end
815
- end
816
-
817
621
  def public_send_field(unextended_obj, unextended_ruby_kwargs, query_ctx)
818
622
  with_extensions(unextended_obj, unextended_ruby_kwargs, query_ctx) do |obj, ruby_kwargs|
819
623
  begin
@@ -829,7 +633,7 @@ module GraphQL
829
633
  # Find a way to resolve this field, checking:
830
634
  #
831
635
  # - A method on the type instance;
832
- # - Hash keys, if the wrapped object is a hash or responds to `#[]`
636
+ # - Hash keys, if the wrapped object is a hash;
833
637
  # - A method on the wrapped object;
834
638
  # - Or, raise not implemented.
835
639
  #
@@ -851,8 +655,6 @@ module GraphQL
851
655
  else
852
656
  inner_object[@method_str]
853
657
  end
854
- elsif defined?(@hash_key) && obj.object.respond_to?(:[])
855
- obj.object[@hash_key]
856
658
  elsif obj.object.respond_to?(@method_sym)
857
659
  method_to_call = @method_sym
858
660
  method_receiver = obj.object
@@ -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
@@ -173,8 +126,9 @@ module GraphQL
173
126
  # @api private
174
127
  INVALID_OBJECT_MESSAGE = "Expected %{object} to be a key-value object responding to `to_h` or `to_unsafe_h`."
175
128
 
176
- def validate_non_null_input(input, ctx, max_errors: nil)
129
+ def validate_non_null_input(input, ctx)
177
130
  result = GraphQL::Query::InputValidationResult.new
131
+
178
132
  warden = ctx.warden
179
133
 
180
134
  if input.is_a?(Array)
@@ -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
@@ -81,11 +79,7 @@ module GraphQL
81
79
  end
82
80
  elsif child_class < GraphQL::Schema::Object
83
81
  # This is being included into an object type, make sure it's using `implements(...)`
84
- backtrace_line = caller_locations(0, 10).find do |location|
85
- location.base_label == "implements" &&
86
- location.path.end_with?("schema/member/has_interfaces.rb")
87
- end
88
-
82
+ backtrace_line = caller(0, 10).find { |line| line.include?("schema/member/has_interfaces.rb") && line.include?("in `implements'")}
89
83
  if !backtrace_line
90
84
  raise "Attach interfaces using `implements(#{self})`, not `include(#{self})`"
91
85
  end
@@ -104,34 +98,11 @@ module GraphQL
104
98
  end
105
99
  end
106
100
 
107
- prepend Schema::Member::CachedGraphQLDefinition::DeprecatedToGraphQL
108
-
109
- def to_graphql
110
- type_defn = GraphQL::InterfaceType.new
111
- type_defn.name = graphql_name
112
- type_defn.description = description
113
- type_defn.orphan_types = orphan_types
114
- type_defn.type_membership_class = self.type_membership_class
115
- type_defn.ast_node = ast_node
116
- fields.each do |field_name, field_inst| # rubocop:disable Development/ContextIsPassedCop -- legacy-related
117
- field_defn = field_inst.graphql_definition(silence_deprecation_warning: true)
118
- type_defn.fields[field_defn.name] = field_defn # rubocop:disable Development/ContextIsPassedCop -- legacy-related
119
- end
120
- type_defn.metadata[:type_class] = self
121
- if respond_to?(:resolve_type)
122
- type_defn.resolve_type = method(:resolve_type)
123
- end
124
- type_defn
125
- end
126
-
127
101
  def kind
128
102
  GraphQL::TypeKinds::INTERFACE
129
103
  end
130
104
  end
131
105
 
132
- # Extend this _after_ `DefinitionMethods` is defined, so it will be used
133
- extend GraphQL::Schema::Member::AcceptsDefinition
134
-
135
106
  extend DefinitionMethods
136
107
 
137
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
@@ -51,24 +45,15 @@ module GraphQL
51
45
  end
52
46
  end
53
47
 
54
- def validate_non_null_input(value, ctx, max_errors: nil)
48
+ def validate_non_null_input(value, ctx)
55
49
  result = GraphQL::Query::InputValidationResult.new
56
50
  ensure_array(value).each_with_index do |item, index|
57
51
  item_result = of_type.validate_input(item, ctx)
58
- unless item_result.valid?
59
- if max_errors
60
- if max_errors == 0
61
- add_max_errros_reached_message(result)
62
- break
63
- end
64
-
65
- max_errors -= 1
66
- end
67
-
52
+ if !item_result.valid?
68
53
  result.merge_result!(index, item_result)
69
54
  end
70
55
  end
71
- result.valid? ? nil : result
56
+ result
72
57
  end
73
58
 
74
59
  private
@@ -81,12 +66,6 @@ module GraphQL
81
66
  [value]
82
67
  end
83
68
  end
84
-
85
- def add_max_errros_reached_message(result)
86
- message = "Too many errors processing list variable, max validation error limit reached. Execution aborted"
87
- item_result = GraphQL::Query::InputValidationResult.from_problem(message)
88
- result.merge_result!(nil, item_result)
89
- end
90
69
  end
91
70
  end
92
71
  end
@@ -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.
@@ -108,7 +103,7 @@ module GraphQL
108
103
  @default_graphql_name ||= begin
109
104
  raise GraphQL::RequiredImplementationMissingError, 'Anonymous class should declare a `graphql_name`' if name.nil?
110
105
 
111
- -name.split("::").last.sub(/Type\Z/, "")
106
+ name.split("::").last.sub(/Type\Z/, "")
112
107
  end
113
108
  end
114
109