Class: GraphQL::Schema::Printer::TypeKindPrinters::EnumPrinter

Inherits:
Object
  • Object
show all
Extended by:
DeprecatedPrinter, DescriptionPrinter
Defined in:
lib/graphql/schema/printer.rb

Class Method Summary collapse

Methods included from DeprecatedPrinter

print_deprecated

Methods included from DescriptionPrinter

print_description

Class Method Details



311
312
313
314
315
316
317
318
319
320
321
# File 'lib/graphql/schema/printer.rb', line 311

def self.print(warden, type)
  enum_values = warden.enum_values(type)

  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)}"\
  "enum #{type.name} {\n#{values}\n}"
end