Skip to content

Commit fed3cf6

Browse files
committed
dedupe interfaces as late as possible
1 parent dbe2113 commit fed3cf6

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

lib/graphql/schema/member/has_interfaces.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def implements(*new_interfaces, **options)
3333
end
3434
end
3535

36+
# Remove any String or late-bound interfaces which are being replaced
3637
own_interface_type_memberships.reject! { |old_i_m|
3738
if !(old_i_m.respond_to?(:abstract_type) && old_i_m.abstract_type.is_a?(Module))
38-
# Remove any String or late-bound interfaces which are being replaced
3939
old_int_type = old_i_m.respond_to?(:abstract_type) ? old_i_m.abstract_type : old_i_m
4040
old_name = Schema::Member::BuildType.to_type_name(old_int_type)
4141

@@ -45,11 +45,6 @@ def implements(*new_interfaces, **options)
4545

4646
new_name == old_name
4747
}
48-
elsif old_i_m.respond_to?(:abstract_type)
49-
# Remove any existing implementations of the same interface
50-
new_memberships.any? { |new_i_m|
51-
new_i_m.respond_to?(:abstract_type) && new_i_m.abstract_type == old_i_m.abstract_type
52-
}
5348
end
5449
}
5550
own_interface_type_memberships.concat(new_memberships)
@@ -82,13 +77,10 @@ def interfaces(context = GraphQL::Query::NullContext)
8277
end
8378

8479
if self.is_a?(Class) && superclass <= GraphQL::Schema::Object
85-
# add interfaces from superclass if not already present
86-
superclass.interfaces(context).each do |sc_int|
87-
visible_interfaces << sc_int unless visible_interfaces.include?(sc_int)
88-
end
80+
visible_interfaces.concat(superclass.interfaces(context))
8981
end
9082

91-
visible_interfaces
83+
visible_interfaces.uniq
9284
end
9385
end
9486
end

0 commit comments

Comments
 (0)