lib/graphql/schema/printer.rb in graphql-1.6.3 vs lib/graphql/schema/printer.rb in graphql-1.6.4
- old
+ new
@@ -184,11 +184,11 @@
if arguments.all?{ |arg| !arg.description }
return "(#{arguments.map{ |arg| print_input_value(arg) }.join(", ")})"
end
out = "(\n".dup
- out << arguments.map.with_index{ |arg, i|
+ out << arguments.sort_by(&:name).map.with_index{ |arg, i|
"#{print_description(arg, " #{indentation}", i == 0)} #{indentation}"\
"#{print_input_value(arg)}"
}.join("\n")
out << "\n#{indentation})"
end
@@ -242,11 +242,11 @@
include DeprecatedPrinter
include ArgsPrinter
include DescriptionPrinter
def print_fields(warden, type)
fields = warden.fields(type)
- fields.map.with_index { |field, i|
+ fields.sort_by(&:name).map.with_index { |field, i|
"#{print_description(field, ' ', i == 0)}"\
" #{field.name}#{print_args(warden, field, ' ')}: #{field.type}#{print_deprecated(field)}"
}.join("\n")
end
end
@@ -273,11 +273,11 @@
extend FieldPrinter
extend DescriptionPrinter
def self.print(warden, type)
interfaces = warden.interfaces(type)
if interfaces.any?
- implementations = " implements #{interfaces.map(&:to_s).join(", ")}"
+ implementations = " implements #{interfaces.sort_by(&:name).map(&:to_s).join(", ")}"
else
implementations = nil
end
"#{print_description(type)}"\
@@ -299,21 +299,21 @@
class UnionPrinter
extend DescriptionPrinter
def self.print(warden, type)
possible_types = warden.possible_types(type)
"#{print_description(type)}"\
- "union #{type.name} = #{possible_types.map(&:to_s).join(" | ")}"
+ "union #{type.name} = #{possible_types.sort_by(&:name).map(&:to_s).join(" | ")}"
end
end
class EnumPrinter
extend DeprecatedPrinter
extend DescriptionPrinter
def self.print(warden, type)
enum_values = warden.enum_values(type)
- values = enum_values.map.with_index { |v, i|
+ values = enum_values.sort_by(&:name).map.with_index { |v, i|
"#{print_description(v, ' ', i == 0)}"\
" #{v.name}#{print_deprecated(v)}"
}.join("\n")
"#{print_description(type)}"\
@@ -324,10 +324,10 @@
class InputObjectPrinter
extend FieldPrinter
extend DescriptionPrinter
def self.print(warden, type)
arguments = warden.arguments(type)
- fields = arguments.map.with_index{ |field, i|
+ fields = arguments.sort_by(&:name).map.with_index{ |field, i|
"#{print_description(field, " ", i == 0)}"\
" #{print_input_value(field)}"
}.join("\n")
"#{print_description(type)}"\
"input #{type.name} {\n#{fields}\n}"