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
# { ... }

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#col, #line

Instance Method Summary collapse

Methods inherited from AbstractNode

child_attributes, #children, #eql?, inherited, #initialize, #position, scalar_attributes, #scalars, #to_query_string

Constructor Details

This class inherits a constructor from GraphQL::Language::Nodes::AbstractNode

Instance Attribute Details

#definitionsArray<OperationDefinition, FragmentDefinition>

Returns top-level GraphQL units: operations or fragments.

Returns:



160
161
162
# File 'lib/graphql/language/nodes.rb', line 160

def definitions
  @definitions
end

Instance Method Details

#initialize_node(definitions: []) ⇒ Object



160
161
162
# File 'lib/graphql/language/nodes.rb', line 160

def initialize_node(definitions: [])
  @definitions = definitions
end

#slice_definition(name) ⇒ Object



164
165
166
# File 'lib/graphql/language/nodes.rb', line 164

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