class GraphQL::Schema::Printer

Used to convert your GraphQL::Schema to a GraphQL schema string

Examples

Example: print your schema to standard output (via helper)

puts GraphQL::Schema::Printer.print_schema(MySchema)

Example: print your schema to standard output

puts GraphQL::Schema::Printer.new(MySchema).print_schema

Example: print a single type to standard output

class Types::Query < GraphQL::Schema::Object
  description "The query root of this schema"

  field :post, Types::Post, null: true
end

class Types::Post < GraphQL::Schema::Object
  description "A blog post"

  field :id, ID, null: false
  field :title, String, null: false
  field :body, String, null: false
end

class MySchema < GraphQL::Schema
  query(Types::Query)
end

printer = GraphQL::Schema::Printer.new(MySchema)
puts printer.print_type(Types::Post)