Class: GraphQL::Language::Nodes::ScalarTypeDefinition

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, line: nil, col: nil, pos: nil, filename: nil, source: nil, definition_pos: nil) ⇒ ScalarTypeDefinition

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



1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
# File 'lib/graphql/language/nodes.rb', line 1362

def initialize(name: nil, description: nil, comment: nil, directives: 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
  @definition_pos = definition_pos
end

Instance Attribute Details

#comment ⇒ Object (readonly)

: String?



1344
1345
1346
# File 'lib/graphql/language/nodes.rb', line 1344

def comment
  @comment
end

#description ⇒ Object (readonly)

: String?



1342
1343
1344
# File 'lib/graphql/language/nodes.rb', line 1342

def description
  @description
end

#directives ⇒ Object (readonly) Also known as: children

: Array



1353
1354
1355
# File 'lib/graphql/language/nodes.rb', line 1353

def directives
  @directives
end

#name ⇒ Object (readonly)

: String



1346
1347
1348
# File 'lib/graphql/language/nodes.rb', line 1346

def name
  @name
end

Class Method Details

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



1375
1376
1377
# File 'lib/graphql/language/nodes.rb', line 1375

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

Instance Method Details

#marshal_dump ⇒ Object



1379
1380
1381
1382
1383
1384
1385
1386
1387
# File 'lib/graphql/language/nodes.rb', line 1379

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

#marshal_load(values) ⇒ Object



1389
1390
1391
# File 'lib/graphql/language/nodes.rb', line 1389

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

#merge_directive(**node_opts) ⇒ Object



1355
1356
1357
# File 'lib/graphql/language/nodes.rb', line 1355

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

#scalars ⇒ Object



1348
1349
1350
# File 'lib/graphql/language/nodes.rb', line 1348

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

#visit_method ⇒ Object



1337
1338
1339
# File 'lib/graphql/language/nodes.rb', line 1337

def visit_method
  :on_scalar_type_definition
end