graphql 1.13.18 → 1.13.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 06b422e884c0286eca2020124a83dbc02a1ac4dbf905b48f9d125fb4c2569eff
4
- data.tar.gz: a4985d6e8e3cd0358f3afac1bd1d8023e24d4ed63e2be8f05557ec2822e69447
3
+ metadata.gz: c21327429549138738debab2d522197133548eb4b275a5f67086154e08469149
4
+ data.tar.gz: ec61107f4f45aaf1de25c6674d7fcf3b8e19b1245fdbf2a1bd1b0f7f1dd9b0aa
5
5
  SHA512:
6
- metadata.gz: e7f61649fd57f66798a84eb713058add79cdff52bb49ad7dfbdaa328111d0288fc5154b2ee991ddbd77914fb80e9d0bced518ffdc21d92f801ab1b68bbf4add2
7
- data.tar.gz: abb11a3b18e52544af8726152fab0f145e214f88521121ac775ba2e0fb0e0f22c9988406548cfde267df314ca58063a4d4130d29f53b236170312e0b806c28d0
6
+ metadata.gz: 5b56c3aaa86b6d758b53d49a7906de483375c54f40db9126b96d791f41c7bba6407d9b59205a4d47215cef1391cd5ebbc03d5eb76825747cbfc1d0f6baf1f0ef
7
+ data.tar.gz: 7f7cb3b2e4fa8c26b355ea4adf01803ab32e2d97036475469071e2cf67d06431ab0486f0daf8ab28433deb95bb8642ea0a2b52739abe6d0ad06bb22b4fdcb2cc
@@ -400,6 +400,7 @@ module GraphQL
400
400
  raise "Invariant: no field for #{owner_type}.#{field_name}"
401
401
  end
402
402
  end
403
+
403
404
  return_type = field_defn.type
404
405
 
405
406
  next_path = path.dup
@@ -425,18 +426,17 @@ module GraphQL
425
426
  total_args_count = field_defn.arguments(context).size
426
427
  if total_args_count == 0
427
428
  resolved_arguments = GraphQL::Execution::Interpreter::Arguments::EMPTY
428
- evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selections_result, parent_object)
429
+ evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selections_result, parent_object, return_type)
429
430
  else
430
431
  # TODO remove all arguments(...) usages?
431
432
  @query.arguments_cache.dataload_for(ast_node, field_defn, object) do |resolved_arguments|
432
- evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selections_result, parent_object)
433
+ evaluate_selection_with_args(resolved_arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selections_result, parent_object, return_type)
433
434
  end
434
435
  end
435
436
  end
436
437
 
437
- def evaluate_selection_with_args(arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selection_result, parent_object) # rubocop:disable Metrics/ParameterLists
438
+ def evaluate_selection_with_args(arguments, field_defn, next_path, ast_node, field_ast_nodes, scoped_context, owner_type, object, is_eager_field, result_name, selection_result, parent_object, return_type) # rubocop:disable Metrics/ParameterLists
438
439
  context.scoped_context = scoped_context
439
- return_type = field_defn.type
440
440
  after_lazy(arguments, owner: owner_type, field: field_defn, path: next_path, ast_node: ast_node, scoped_context: context.scoped_context, owner_object: object, arguments: arguments, result_name: result_name, result: selection_result) do |resolved_arguments|
441
441
  if resolved_arguments.is_a?(GraphQL::ExecutionError) || resolved_arguments.is_a?(GraphQL::UnauthorizedError)
442
442
  continue_value(next_path, resolved_arguments, owner_type, field_defn, return_type.non_null?, ast_node, result_name, selection_result)
@@ -11,8 +11,8 @@ module GraphQL
11
11
  "to the executor."
12
12
  field :name, String, null: false, method: :graphql_name
13
13
  field :description, String
14
- field :locations, [GraphQL::Schema::LateBoundType.new("__DirectiveLocation")], null: false
15
- field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false do
14
+ field :locations, [GraphQL::Schema::LateBoundType.new("__DirectiveLocation")], null: false, scope: false
15
+ field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false, scope: false do
16
16
  argument :include_deprecated, Boolean, required: false, default_value: false
17
17
  end
18
18
  field :on_operation, Boolean, null: false, deprecation_reason: "Use `locations`.", method: :on_operation?
@@ -7,7 +7,7 @@ module GraphQL
7
7
  "a name, potentially a list of arguments, and a return type."
8
8
  field :name, String, null: false
9
9
  field :description, String
10
- field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false do
10
+ field :args, [GraphQL::Schema::LateBoundType.new("__InputValue")], null: false, scope: false do
11
11
  argument :include_deprecated, Boolean, required: false, default_value: false
12
12
  end
13
13
  field :type, GraphQL::Schema::LateBoundType.new("__Type"), null: false
@@ -8,11 +8,11 @@ module GraphQL
8
8
  "available types and directives on the server, as well as the entry points for "\
9
9
  "query, mutation, and subscription operations."
10
10
 
11
- field :types, [GraphQL::Schema::LateBoundType.new("__Type")], "A list of all types supported by this server.", null: false
11
+ field :types, [GraphQL::Schema::LateBoundType.new("__Type")], "A list of all types supported by this server.", null: false, scope: false
12
12
  field :query_type, GraphQL::Schema::LateBoundType.new("__Type"), "The type that query operations will be rooted at.", null: false
13
13
  field :mutation_type, GraphQL::Schema::LateBoundType.new("__Type"), "If this server supports mutation, the type that mutation operations will be rooted at."
14
14
  field :subscription_type, GraphQL::Schema::LateBoundType.new("__Type"), "If this server support subscription, the type that subscription operations will be rooted at."
15
- field :directives, [GraphQL::Schema::LateBoundType.new("__Directive")], "A list of all directives supported by this server.", null: false
15
+ field :directives, [GraphQL::Schema::LateBoundType.new("__Directive")], "A list of all directives supported by this server.", null: false, scope: false
16
16
  field :description, String, resolver_method: :schema_description
17
17
 
18
18
  def schema_description
@@ -14,15 +14,15 @@ module GraphQL
14
14
  field :kind, GraphQL::Schema::LateBoundType.new("__TypeKind"), null: false
15
15
  field :name, String, method: :graphql_name
16
16
  field :description, String
17
- field :fields, [GraphQL::Schema::LateBoundType.new("__Field")] do
17
+ field :fields, [GraphQL::Schema::LateBoundType.new("__Field")], scope: false do
18
18
  argument :include_deprecated, Boolean, required: false, default_value: false
19
19
  end
20
- field :interfaces, [GraphQL::Schema::LateBoundType.new("__Type")]
21
- field :possible_types, [GraphQL::Schema::LateBoundType.new("__Type")]
22
- field :enum_values, [GraphQL::Schema::LateBoundType.new("__EnumValue")] do
20
+ field :interfaces, [GraphQL::Schema::LateBoundType.new("__Type")], scope: false
21
+ field :possible_types, [GraphQL::Schema::LateBoundType.new("__Type")], scope: false
22
+ field :enum_values, [GraphQL::Schema::LateBoundType.new("__EnumValue")], scope: false do
23
23
  argument :include_deprecated, Boolean, required: false, default_value: false
24
24
  end
25
- field :input_fields, [GraphQL::Schema::LateBoundType.new("__InputValue")] do
25
+ field :input_fields, [GraphQL::Schema::LateBoundType.new("__InputValue")], scope: false do
26
26
  argument :include_deprecated, Boolean, required: false, default_value: false
27
27
  end
28
28
  field :of_type, GraphQL::Schema::LateBoundType.new("__Type")
@@ -22,7 +22,7 @@ module GraphQL
22
22
  # but downcase the first letter.
23
23
  def default_graphql_name
24
24
  @default_graphql_name ||= begin
25
- camelized_name = super
25
+ camelized_name = super.dup
26
26
  camelized_name[0] = camelized_name[0].downcase
27
27
  camelized_name
28
28
  end
@@ -229,6 +229,7 @@ module GraphQL
229
229
  end
230
230
  @original_name = name
231
231
  name_s = -name.to_s
232
+
232
233
  @underscored_name = -Member::BuildType.underscore(name_s)
233
234
  @name = -(camelize ? Member::BuildType.camelize(name_s) : name_s)
234
235
  @description = description
@@ -650,27 +651,29 @@ module GraphQL
650
651
  arg_values = args
651
652
  using_arg_values = false
652
653
  end
653
- # Faster than `.any?`
654
- arguments(context).each_value do |arg|
655
- arg_key = arg.keyword
656
- if arg_values.key?(arg_key)
657
- arg_value = arg_values[arg_key]
658
- if using_arg_values
659
- if arg_value.default_used?
660
- # pass -- no auth required for default used
661
- next
662
- else
663
- application_arg_value = arg_value.value
664
- if application_arg_value.is_a?(GraphQL::Execution::Interpreter::Arguments)
665
- application_arg_value.keyword_arguments
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
666
669
  end
670
+ else
671
+ application_arg_value = arg_value
667
672
  end
668
- else
669
- application_arg_value = arg_value
670
- end
671
673
 
672
- if !arg.authorized?(object, application_arg_value, context)
673
- return false
674
+ if !arg.authorized?(object, application_arg_value, context)
675
+ return false
676
+ end
674
677
  end
675
678
  end
676
679
  end
@@ -108,7 +108,7 @@ module GraphQL
108
108
  @default_graphql_name ||= begin
109
109
  raise GraphQL::RequiredImplementationMissingError, 'Anonymous class should declare a `graphql_name`' if name.nil?
110
110
 
111
- name.split("::").last.sub(/Type\Z/, "")
111
+ -name.split("::").last.sub(/Type\Z/, "")
112
112
  end
113
113
  end
114
114
 
@@ -167,7 +167,7 @@ module GraphQL
167
167
  # @return [Interpreter::Arguments, Execution::Lazy<Interpeter::Arguments>]
168
168
  def coerce_arguments(parent_object, values, context, &block)
169
169
  # Cache this hash to avoid re-merging it
170
- arg_defns = self.arguments(context)
170
+ arg_defns = context.warden.arguments(self)
171
171
  total_args_count = arg_defns.size
172
172
 
173
173
  finished_args = nil
@@ -181,7 +181,7 @@ module GraphQL
181
181
  argument_values = {}
182
182
  resolved_args_count = 0
183
183
  raised_error = false
184
- arg_defns.each do |arg_name, arg_defn|
184
+ arg_defns.each do |arg_defn|
185
185
  context.dataloader.append_job do
186
186
  begin
187
187
  arg_defn.coerce_into_values(parent_object, values, context, argument_values)
@@ -134,7 +134,7 @@ module GraphQL
134
134
  if type.respond_to?(:kind) && type.kind.interface?
135
135
  implements_this_interface = false
136
136
  implementation_is_visible = false
137
- interface_type_memberships.each do |tm|
137
+ warden.interface_type_memberships(self, context).each do |tm|
138
138
  if tm.abstract_type == type
139
139
  implements_this_interface ||= true
140
140
  if warden.visible_type_membership?(tm, context)
@@ -57,7 +57,17 @@ module GraphQL
57
57
  end
58
58
 
59
59
  def interface_type_memberships
60
- own_interface_type_memberships + ((self.is_a?(Class) && superclass.respond_to?(:interface_type_memberships)) ? superclass.interface_type_memberships : [])
60
+ own_tms = own_interface_type_memberships
61
+ if (self.is_a?(Class) && superclass.respond_to?(:interface_type_memberships))
62
+ inherited_tms = superclass.interface_type_memberships
63
+ if inherited_tms.size > 0
64
+ own_tms + inherited_tms
65
+ else
66
+ own_tms
67
+ end
68
+ else
69
+ own_tms
70
+ end
61
71
  end
62
72
 
63
73
  # param context [Query::Context] If omitted, skip filtering.
@@ -78,6 +78,8 @@ module GraphQL
78
78
  def visible_type?(type, ctx); type.visible?(ctx); end
79
79
  def visible_enum_value?(ev, ctx); ev.visible?(ctx); end
80
80
  def visible_type_membership?(tm, ctx); tm.visible?(ctx); end
81
+ def interface_type_memberships(obj_t, ctx); obj_t.interface_type_memberships; end
82
+ def arguments(owner, ctx); owner.arguments(ctx); end
81
83
  end
82
84
  end
83
85
 
@@ -172,8 +174,8 @@ module GraphQL
172
174
 
173
175
  # @param argument_owner [GraphQL::Field, GraphQL::InputObjectType]
174
176
  # @return [Array<GraphQL::Argument>] Visible arguments on `argument_owner`
175
- def arguments(argument_owner)
176
- @visible_arguments ||= read_through { |o| o.arguments(@context).each_value.select { |a| visible_argument?(a) } }
177
+ def arguments(argument_owner, ctx = nil)
178
+ @visible_arguments ||= read_through { |o| o.arguments(@context).each_value.select { |a| visible_argument?(a, @context) } }
177
179
  @visible_arguments[argument_owner]
178
180
  end
179
181
 
@@ -231,6 +233,13 @@ module GraphQL
231
233
  visible?(type_membership)
232
234
  end
233
235
 
236
+ def interface_type_memberships(obj_type, _ctx = nil)
237
+ @type_memberships ||= read_through do |obj_t|
238
+ obj_t.interface_type_memberships
239
+ end
240
+ @type_memberships[obj_type]
241
+ end
242
+
234
243
  private
235
244
 
236
245
  def visible_and_reachable_type?(type_defn)
@@ -36,6 +36,7 @@ module GraphQL
36
36
  trace_field = true # implemented with instrumenter
37
37
  else
38
38
  field = data[:field]
39
+ # HERE
39
40
  return_type = field.type.unwrap
40
41
  trace_field = if return_type.kind.scalar? || return_type.kind.enum?
41
42
  (field.trace.nil? && @trace_scalars) || field.trace
@@ -7,7 +7,7 @@ module GraphQL
7
7
 
8
8
  def self.coerce_result(value, ctx)
9
9
  str = value.to_s
10
- if str.encoding == Encoding::UTF_8
10
+ if str.ascii_only? || str.encoding == Encoding::UTF_8
11
11
  str
12
12
  elsif str.frozen?
13
13
  str.encode(Encoding::UTF_8)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.13.18"
3
+ VERSION = "1.13.19"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.18
4
+ version: 1.13.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-10 00:00:00.000000000 Z
11
+ date: 2023-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips