Class: GraphQL::Language::Nodes::InterfaceTypeExtension

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

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



1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
# File 'lib/graphql/language/nodes.rb', line 1932

def initialize(name: nil, interfaces: NO_CHILDREN, 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.freeze
  @directives = directives.freeze
  @fields = fields.freeze
end

Instance Attribute Details

#directives ⇒ Object (readonly)

: Array



1900
1901
1902
# File 'lib/graphql/language/nodes.rb', line 1900

def directives
  @directives
end

#fields ⇒ Object (readonly)

: Array



1902
1903
1904
# File 'lib/graphql/language/nodes.rb', line 1902

def fields
  @fields
end

#interfaces ⇒ Object (readonly)

: Array



1898
1899
1900
# File 'lib/graphql/language/nodes.rb', line 1898

def interfaces
  @interfaces
end

#name ⇒ Object (readonly)

: String



1891
1892
1893
# File 'lib/graphql/language/nodes.rb', line 1891

def name
  @name
end

Class Method Details

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

rubocop:disable Metrics/ParameterLists



1944
1945
1946
# File 'lib/graphql/language/nodes.rb', line 1944

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



1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
# File 'lib/graphql/language/nodes.rb', line 1916

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

#marshal_dump ⇒ Object



1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
# File 'lib/graphql/language/nodes.rb', line 1948

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

#marshal_load(values) ⇒ Object



1959
1960
1961
# File 'lib/graphql/language/nodes.rb', line 1959

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

#merge_directive(**node_opts) ⇒ Object



1908
1909
1910
# File 'lib/graphql/language/nodes.rb', line 1908

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

#merge_field(**node_opts) ⇒ Object



1912
1913
1914
# File 'lib/graphql/language/nodes.rb', line 1912

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

#merge_interface(**node_opts) ⇒ Object



1904
1905
1906
# File 'lib/graphql/language/nodes.rb', line 1904

def merge_interface(**node_opts)
  merge(interfaces: interfaces + [GraphQL::Language::Nodes::TypeName.new(**node_opts)])
end

#scalars ⇒ Object



1893
1894
1895
# File 'lib/graphql/language/nodes.rb', line 1893

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

#visit_method ⇒ Object



1886
1887
1888
# File 'lib/graphql/language/nodes.rb', line 1886

def visit_method
  :on_interface_type_extension
end