Skip to content

Commit 0f6aead

Browse files
committed
deduplicate interfaces higher up
1 parent 0f3cd9f commit 0f6aead

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/graphql/schema/member/has_interfaces.rb

Lines changed: 7 additions & 2 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
3736
own_interface_type_memberships.reject! { |old_i_m|
3837
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,6 +45,11 @@ 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+
}
4853
end
4954
}
5055
own_interface_type_memberships.concat(new_memberships)
@@ -80,7 +85,7 @@ def interfaces(context = GraphQL::Query::NullContext)
8085
visible_interfaces.concat(superclass.interfaces(context))
8186
end
8287

83-
visible_interfaces.uniq
88+
visible_interfaces
8489
end
8590
end
8691
end

0 commit comments

Comments
 (0)