Class: GraphQL::DSL::Node Abstract
- Inherits:
-
Object
- Object
- GraphQL::DSL::Node
- Defined in:
- lib/graphql/dsl/nodes/node.rb
Overview
This class is abstract.
Base class for all GraphQL DSL nodes
Direct Known Subclasses
ExecutableDocument, Field, FragmentOperation, FragmentSpread, InlineFragment, Operation
Instance Attribute Summary collapse
-
#__name ⇒ String, ...
readonly
Node name.
-
#__nodes ⇒ Array<Node>
readonly
List of sub-nodes.
Instance Method Summary collapse
-
#initialize(name = nil, &block) ⇒ Node
constructor
Create node.
-
#to_gql(level = 0, formatter = Formatter.new) ⇒ String
Generate GraphQL query.
Constructor Details
#initialize(name = nil, &block) ⇒ Node
Create node
20 21 22 23 24 25 |
# File 'lib/graphql/dsl/nodes/node.rb', line 20 def initialize(name = nil, &block) @__name = name @__nodes = [] instance_eval(&block) if block end |
Instance Attribute Details
#__name ⇒ String, ... (readonly)
Returns node name.
10 11 12 |
# File 'lib/graphql/dsl/nodes/node.rb', line 10 def __name @__name end |
#__nodes ⇒ Array<Node> (readonly)
Returns list of sub-nodes.
13 14 15 |
# File 'lib/graphql/dsl/nodes/node.rb', line 13 def __nodes @__nodes end |
Instance Method Details
#to_gql(level = 0, formatter = Formatter.new) ⇒ String
Generate GraphQL query
34 35 36 |
# File 'lib/graphql/dsl/nodes/node.rb', line 34 def to_gql(level = 0, formatter = Formatter.new) formatter.format_node(self, level) end |