Class: GraphQL::Language::Nodes::ObjectTypeExtension

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, directives: NO_CHILDREN, fields: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil) ⇒ ObjectTypeExtension

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



1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
# File 'lib/graphql/language/nodes.rb', line 1753

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

Instance Attribute Details

#directives ⇒ Object (readonly)

: Array



1726
1727
1728
# File 'lib/graphql/language/nodes.rb', line 1726

def directives
  @directives
end

#fields ⇒ Object (readonly)

: Array



1728
1729
1730
# File 'lib/graphql/language/nodes.rb', line 1728

def fields
  @fields
end

#interfaces ⇒ Object (readonly)

: Array



1719
1720
1721
# File 'lib/graphql/language/nodes.rb', line 1719

def interfaces
  @interfaces
end

#name ⇒ Object (readonly)

: String



1717
1718
1719
# File 'lib/graphql/language/nodes.rb', line 1717

def name
  @name
end

Class Method Details

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

rubocop:disable Metrics/ParameterLists



1765
1766
1767
# File 'lib/graphql/language/nodes.rb', line 1765

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

Instance Method Details

#children ⇒ Object



1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
# File 'lib/graphql/language/nodes.rb', line 1738

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



1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
# File 'lib/graphql/language/nodes.rb', line 1769

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

#marshal_load(values) ⇒ Object



1780
1781
1782
# File 'lib/graphql/language/nodes.rb', line 1780

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

#merge_directive(**node_opts) ⇒ Object



1730
1731
1732
# File 'lib/graphql/language/nodes.rb', line 1730

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

#merge_field(**node_opts) ⇒ Object



1734
1735
1736
# File 'lib/graphql/language/nodes.rb', line 1734

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

#scalars ⇒ Object



1721
1722
1723
# File 'lib/graphql/language/nodes.rb', line 1721

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

#visit_method ⇒ Object



1712
1713
1714
# File 'lib/graphql/language/nodes.rb', line 1712

def visit_method
  :on_object_type_extension
end