Skip to content

Commit 2865409

Browse files
committed
Use the passed-in owner for Argument checks
1 parent 68f1a51 commit 2865409

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

Diff for: lib/graphql/schema/visibility/profile.rb

+17-16
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,21 @@ def initialize(name: nil, context:, schema:)
4747
end.compare_by_identity
4848
}.compare_by_identity
4949

50-
@cached_visible_arguments = Hash.new do |h, arg|
51-
h[arg] = if @cached_visible[arg] && (arg_type = arg.type.unwrap) && @cached_visible[arg_type]
52-
owner = arg.owner
53-
case owner
54-
when GraphQL::Schema::Field
55-
@cached_visible_fields[owner.owner][owner]
56-
when Class
57-
@cached_visible[owner]
50+
@cached_visible_arguments = Hash.new do |h, owner|
51+
h[owner] = Hash.new do |h2, arg|
52+
h2[arg] = if @cached_visible[arg] && (arg_type = arg.type.unwrap) && @cached_visible[arg_type]
53+
case owner
54+
when GraphQL::Schema::Field
55+
@cached_visible_fields[owner.owner][owner]
56+
when Class
57+
@cached_visible[owner]
58+
else
59+
raise "Unexpected argument owner for `#{arg.path}`: #{owner.inspect}"
60+
end
5861
else
59-
raise "Unexpected argument owner for `#{arg.path}`: #{owner.inspect}"
62+
false
6063
end
61-
else
62-
false
63-
end
64+
end.compare_by_identity
6465
end.compare_by_identity
6566

6667
@cached_parent_fields = Hash.new do |h, type|
@@ -90,7 +91,7 @@ def initialize(name: nil, context:, schema:)
9091
end.compare_by_identity
9192

9293
@cached_arguments = Hash.new do |h, owner|
93-
h[owner] = non_duplicate_items(owner.all_argument_definitions, @cached_visible_arguments)
94+
h[owner] = non_duplicate_items(owner.all_argument_definitions, @cached_visible_arguments[owner])
9495
end.compare_by_identity
9596

9697
@loadable_possible_types = Hash.new { |h, union_type| h[union_type] = union_type.possible_types }.compare_by_identity
@@ -188,7 +189,7 @@ def argument(owner, arg_name)
188189
if arg.is_a?(Array)
189190
visible_arg = nil
190191
arg.each do |arg_defn|
191-
if @cached_visible_arguments[arg_defn]
192+
if @cached_visible_arguments[owner][arg_defn]
192193
if visible_arg.nil?
193194
visible_arg = arg_defn
194195
else
@@ -198,7 +199,7 @@ def argument(owner, arg_name)
198199
end
199200
visible_arg
200201
else
201-
if arg && @cached_visible_arguments[arg]
202+
if arg && @cached_visible_arguments[owner][arg]
202203
arg
203204
else
204205
nil
@@ -323,7 +324,7 @@ def referenced?(type_defn)
323324
@schema.visibility.all_references[type_defn].any? do |ref|
324325
case ref
325326
when GraphQL::Schema::Argument
326-
@cached_visible_arguments[ref]
327+
@cached_visible_arguments[ref.owner][ref]
327328
when GraphQL::Schema::Field
328329
@cached_visible_fields[ref.owner][ref]
329330
when Module

0 commit comments

Comments
 (0)