Class: GraphQL::Language::Nodes::InputObjectTypeExtension

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

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



2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
# File 'lib/graphql/language/nodes.rb', line 2444

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

Instance Attribute Details

#directives ⇒ Object (readonly)

: Array



2417
2418
2419
# File 'lib/graphql/language/nodes.rb', line 2417

def directives
  @directives
end

#fields ⇒ Object (readonly)

: Array



2419
2420
2421
# File 'lib/graphql/language/nodes.rb', line 2419

def fields
  @fields
end

#name ⇒ Object (readonly)

: String



2410
2411
2412
# File 'lib/graphql/language/nodes.rb', line 2410

def name
  @name
end

Class Method Details

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



2455
2456
2457
# File 'lib/graphql/language/nodes.rb', line 2455

def self.from_a(filename, line, col, name, directives, fields, comment: nil)
  self.new(filename: filename, line: line, col: col, name: name, directives: directives, fields: fields)
end

Instance Method Details

#children ⇒ Object



2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
# File 'lib/graphql/language/nodes.rb', line 2429

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



2459
2460
2461
2462
2463
2464
2465
2466
2467
# File 'lib/graphql/language/nodes.rb', line 2459

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

#marshal_load(values) ⇒ Object



2469
2470
2471
# File 'lib/graphql/language/nodes.rb', line 2469

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

#merge_directive(**node_opts) ⇒ Object



2421
2422
2423
# File 'lib/graphql/language/nodes.rb', line 2421

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

#merge_field(**node_opts) ⇒ Object



2425
2426
2427
# File 'lib/graphql/language/nodes.rb', line 2425

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

#scalars ⇒ Object



2412
2413
2414
# File 'lib/graphql/language/nodes.rb', line 2412

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

#visit_method ⇒ Object



2405
2406
2407
# File 'lib/graphql/language/nodes.rb', line 2405

def visit_method
  :on_input_object_type_extension
end