Module: GraphQL::Language::Generation

Extended by:
Generation
Included in:
Generation
Defined in:
lib/graphql/language/generation.rb

Overview

Exposes #generate, which turns AST nodes back into query strings.

Instance Method Summary collapse

Instance Method Details

#generate(node, indent: "", printer: GraphQL::Language::Printer.new) ⇒ String

Turn an AST node back into a string.

Examples:

Turning a document into a query

document = GraphQL.parse(query_string)
GraphQL::Language::Generation.generate(document)
# => "{ ... }"

Parameters:

Returns:

  • (String)

    Valid GraphQL for node



19
20
21
# File 'lib/graphql/language/generation.rb', line 19

def generate(node, indent: "", printer: GraphQL::Language::Printer.new)
  printer.print(node, indent: indent)
end