Class: GraphQL::Language::Nodes::InputObjectTypeDefinition

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

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



2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
# File 'lib/graphql/language/nodes.rb', line 2364

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

Instance Attribute Details

#comment ⇒ Object (readonly)

: String?



2328
2329
2330
# File 'lib/graphql/language/nodes.rb', line 2328

def comment
  @comment
end

#description ⇒ Object (readonly)

: String?



2326
2327
2328
# File 'lib/graphql/language/nodes.rb', line 2326

def description
  @description
end

#directives ⇒ Object (readonly)

: Array



2337
2338
2339
# File 'lib/graphql/language/nodes.rb', line 2337

def directives
  @directives
end

#fields ⇒ Object (readonly)

: Array



2339
2340
2341
# File 'lib/graphql/language/nodes.rb', line 2339

def fields
  @fields
end

#name ⇒ Object (readonly)

: String



2330
2331
2332
# File 'lib/graphql/language/nodes.rb', line 2330

def name
  @name
end

Class Method Details

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

rubocop:disable Metrics/ParameterLists



2378
2379
2380
# File 'lib/graphql/language/nodes.rb', line 2378

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

Instance Method Details

#children ⇒ Object



2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
# File 'lib/graphql/language/nodes.rb', line 2349

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



2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
# File 'lib/graphql/language/nodes.rb', line 2382

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

#marshal_load(values) ⇒ Object



2393
2394
2395
# File 'lib/graphql/language/nodes.rb', line 2393

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

#merge_directive(**node_opts) ⇒ Object



2341
2342
2343
# File 'lib/graphql/language/nodes.rb', line 2341

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

#merge_field(**node_opts) ⇒ Object



2345
2346
2347
# File 'lib/graphql/language/nodes.rb', line 2345

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

#scalars ⇒ Object



2332
2333
2334
# File 'lib/graphql/language/nodes.rb', line 2332

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

#visit_method ⇒ Object



2321
2322
2323
# File 'lib/graphql/language/nodes.rb', line 2321

def visit_method
  :on_input_object_type_definition
end