Class: GraphQL::DSL::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/dsl/formatter/field.rb,
lib/graphql/dsl/formatter/values.rb,
lib/graphql/dsl/formatter/arguments.rb,
lib/graphql/dsl/formatter/formatter.rb,
lib/graphql/dsl/formatter/operation.rb,
lib/graphql/dsl/formatter/directives.rb,
lib/graphql/dsl/formatter/fragment_spread.rb,
lib/graphql/dsl/formatter/inline_fragment.rb,
lib/graphql/dsl/formatter/fragment_operation.rb,
lib/graphql/dsl/formatter/executable_document.rb,
lib/graphql/dsl/formatter/variable_definitions.rb

Overview

rubocop:disable Style/Documentation

Instance Method Summary collapse

Instance Method Details

#format_node(node, level) ⇒ String

Format node to GraphQL

Parameters:

  • node (Node)

    node

  • level (Integer)

    indent level

Returns:

  • (String)

    representation of node as GraphQL string



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/graphql/dsl/formatter/formatter.rb', line 15

def format_node(node, level)
  case node
  when ExecutableDocument then format_executable_document(node, level)
  when Operation then format_operation(node, level)
  when FragmentOperation then format_fragment_operation(node, level)
  when Field then format_field(node, level)
  when FragmentSpread then format_fragment_spread(node, level)
  when InlineFragment then format_inline_fragment(node, level)
  else
    raise Error.new('Unknown node', class: node.class.name, node: node)
  end
end