lib/graphql/language/printer.rb in graphql-2.0.6 vs lib/graphql/language/printer.rb in graphql-2.0.7
- old
+ new
@@ -265,15 +265,19 @@
description = indent != '' && !first_in_block ? "\n".dup : "".dup
description << GraphQL::Language::BlockString.print(node.description, indent: indent)
end
def print_field_definitions(fields)
- out = " {\n".dup
- fields.each.with_index do |field, i|
- out << print_description(field, indent: ' ', first_in_block: i == 0)
- out << " #{print_field_definition(field)}\n"
+ if fields.empty?
+ ""
+ else
+ out = " {\n".dup
+ fields.each.with_index do |field, i|
+ out << print_description(field, indent: ' ', first_in_block: i == 0)
+ out << " #{print_field_definition(field)}\n"
+ end
+ out << "}"
end
- out << "}"
end
def print_directives(directives)
if directives.any?
directives.map { |d| " #{print_directive(d)}" }.join