Class: GraphQL::Language::Nodes::Document

Inherits:
AbstractNode show all
Defined in:
lib/graphql/language/nodes.rb

Overview

This is the AST root for normal queries

Examples:

Deriving a document by parsing a string

document = GraphQL.parse(query_string)

Creating a string from a document

document.to_query_string
# { ... }

Creating a custom string from a document

class VariableScrubber < GraphQL::Language::Printer
  def print_argument(arg)
    print_string("#{arg.name}: <HIDDEN>")
  end
end

document.to_query_string(printer: VariableScrubber.new)

Constant Summary

Constants inherited from AbstractNode

AbstractNode::NO_CHILDREN

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#filename

Instance Method Summary collapse

Methods inherited from AbstractNode

#==, #children, #children_method_name, children_of_type, #col, #definition_line, #delete_child, inherited, #initialize_copy, #line, #merge, #position, #replace_child, #scalars, #to_query_string

Instance Attribute Details

#definitionsArray<OperationDefinition, FragmentDefinition>

Returns top-level GraphQL units: operations or fragments.

Returns:



612
613
614
# File 'lib/graphql/language/nodes.rb', line 612

def slice_definition(name)
  GraphQL::Language::DefinitionSlice.slice(self, name)
end

Instance Method Details

#slice_definition(name) ⇒ Object



612
613
614
# File 'lib/graphql/language/nodes.rb', line 612

def slice_definition(name)
  GraphQL::Language::DefinitionSlice.slice(self, name)
end