Skip to content

Commit bddf759

Browse files
committed
don't implement same interface twice in SDL output
1 parent fca03eb commit bddf759

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

lib/graphql/language/printer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def print_object_type_definition(object_type)
170170
end
171171

172172
def print_implements(type)
173-
" implements #{type.interfaces.map(&:name).join(" & ")}"
173+
" implements #{type.interfaces.map(&:name).uniq.join(" & ")}"
174174
end
175175

176176
def print_input_value_definition(input_value)

spec/graphql/schema/build_from_definition_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,36 @@ def assert_schema_and_compare_output(definition)
556556
assert_schema_and_compare_output(schema)
557557
end
558558

559+
it "only adds the interface to the type once" do
560+
schema = <<-SCHEMA
561+
interface Named implements Node {
562+
id: ID
563+
name: String
564+
}
565+
566+
interface Node {
567+
id: ID
568+
}
569+
570+
type Query {
571+
thing: Thing
572+
}
573+
574+
type Thing implements Named & Node & Timestamped {
575+
id: ID
576+
name: String
577+
timestamp: String
578+
}
579+
580+
interface Timestamped implements Node {
581+
id: ID
582+
timestamp: String
583+
}
584+
SCHEMA
585+
586+
assert_schema_and_compare_output(schema)
587+
end
588+
559589
it 'supports simple output enum' do
560590
schema = <<-SCHEMA
561591
schema {

0 commit comments

Comments
 (0)