Skip to content

Commit 5b86a49

Browse files
author
Robert Mosolgo
authored
Merge pull request rmosolgo#1902 from swalkinshaw/fix-print-type
Fix type printing in Schema printer
2 parents 0c567be + 99fd3ec commit 5b86a49

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/graphql/schema/printer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def print_schema
8989
end
9090

9191
def print_type(type)
92-
node = @document_from_schema.build_object_type_node(type)
92+
node = @document_from_schema.build_type_definition_node(type)
9393
print(node)
9494
end
9595

spec/graphql/schema/printer_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,20 @@ def foobar
630630
assert_equal expected.chomp, GraphQL::Schema::Printer.new(schema).print_type(schema.types['Post'])
631631
end
632632

633+
it "can print non-object types" do
634+
expected = <<SCHEMA
635+
# Test
636+
input Sub {
637+
# Something
638+
int: Int
639+
640+
# Something
641+
string: String
642+
}
643+
SCHEMA
644+
assert_equal expected.chomp, GraphQL::Schema::Printer.new(schema).print_type(schema.types['Sub'])
645+
end
646+
633647
it "can print arguments that use non-standard Ruby objects as default values" do
634648
backing_object = Struct.new(:value)
635649

0 commit comments

Comments
 (0)