Class: GraphQL::Language::Nodes::ObjectTypeDefinition

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

Constant Summary

Constants inherited from AbstractNode

AbstractNode::NO_CHILDREN

Instance Attribute Summary collapse

Attributes inherited from AbstractNode

#filename

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractNode

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

Constructor Details

#initialize(name: nil, interfaces: nil, description: nil, comment: nil, directives: NO_CHILDREN, fields: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil, definition_pos: nil) ⇒ ObjectTypeDefinition

: (?name: untyped, ?interfaces: untyped, ?description: untyped, ?comment: untyped, ?directives: Array, ?fields: Array, ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped, ?definition_pos: Integer?) -> void



1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
# File 'lib/graphql/language/nodes.rb', line 1669

def initialize(name: nil, interfaces: nil, description: nil, comment: nil, directives: NO_CHILDREN, fields: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil, definition_pos: nil)
  @line = line
  @col = col
  @pos = pos
  @filename = filename
  @source = source
  @name = name
  @interfaces = interfaces
  @description = description && -description
  @comment = comment
  @directives = directives.freeze
  @fields = fields.freeze
  @definition_pos = definition_pos
end

Instance Attribute Details

#comment ⇒ Object (readonly)

: String?



1631
1632
1633
# File 'lib/graphql/language/nodes.rb', line 1631

def comment
  @comment
end

#description ⇒ Object (readonly)

: String?



1629
1630
1631
# File 'lib/graphql/language/nodes.rb', line 1629

def description
  @description
end

#directives ⇒ Object (readonly)

: Array



1642
1643
1644
# File 'lib/graphql/language/nodes.rb', line 1642

def directives
  @directives
end

#fields ⇒ Object (readonly)

: Array



1644
1645
1646
# File 'lib/graphql/language/nodes.rb', line 1644

def fields
  @fields
end

#interfaces ⇒ Object (readonly)

: Array



1635
1636
1637
# File 'lib/graphql/language/nodes.rb', line 1635

def interfaces
  @interfaces
end

#name ⇒ Object (readonly)

: String



1633
1634
1635
# File 'lib/graphql/language/nodes.rb', line 1633

def name
  @name
end

Class Method Details

.from_a(filename, line, col, name, interfaces, description, directives, fields, comment: nil) ⇒ Object

rubocop:disable Metrics/ParameterLists



1684
1685
1686
# File 'lib/graphql/language/nodes.rb', line 1684

def self.from_a(filename, line, col, name, interfaces, description, directives, fields, comment: nil) # rubocop:disable Metrics/ParameterLists
  self.new(filename: filename, line: line, col: col, name: name, interfaces: interfaces, description: description, comment: comment, directives: directives, fields: fields)
end

Instance Method Details

#children ⇒ Object



1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
# File 'lib/graphql/language/nodes.rb', line 1654

def children
  @children ||= begin
    if !@directives.empty? || !@fields.empty?
      new_children = []
      new_children.concat(@directives)
      new_children.concat(@fields)
      new_children.freeze
      new_children
    else
      NO_CHILDREN
    end
  end
end

#marshal_dump ⇒ Object



1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
# File 'lib/graphql/language/nodes.rb', line 1688

def marshal_dump
  [
    line, col, # use methods here to force them to be calculated
    @filename,
    @name,
    @interfaces,
    @description,
    @directives,
    @fields,
  ]
end

#marshal_load(values) ⇒ Object



1700
1701
1702
# File 'lib/graphql/language/nodes.rb', line 1700

def marshal_load(values)
  @line, @col, @filename, @name, @interfaces, @description, @directives, @fields = values
end

#merge_directive(**node_opts) ⇒ Object



1646
1647
1648
# File 'lib/graphql/language/nodes.rb', line 1646

def merge_directive(**node_opts)
  merge(directives: directives + [GraphQL::Language::Nodes::Directive.new(**node_opts)])
end

#merge_field(**node_opts) ⇒ Object



1650
1651
1652
# File 'lib/graphql/language/nodes.rb', line 1650

def merge_field(**node_opts)
  merge(fields: fields + [GraphQL::Language::Nodes::FieldDefinition.new(**node_opts)])
end

#scalars ⇒ Object



1637
1638
1639
# File 'lib/graphql/language/nodes.rb', line 1637

def scalars
  @scalars ||= [@name, @interfaces].freeze
end

#visit_method ⇒ Object



1624
1625
1626
# File 'lib/graphql/language/nodes.rb', line 1624

def visit_method
  :on_object_type_definition
end