Class: GraphQL::ListType

Inherits:
BaseType show all
Includes:
BaseType::ModifiesAnotherType
Defined in:
lib/graphql/list_type.rb

Overview

A list type wraps another type.

Get the underlying type with BaseType::ModifiesAnotherType#unwrap

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseType::ModifiesAnotherType

#unwrap

Methods inherited from BaseType

#==, #coerce_input!, #resolve_type, #to_list_type, #to_non_null_type, #unwrap

Methods included from DefinitionHelpers::DefinedByConfig

included

Methods included from DefinitionHelpers::NonNullWithBang

#!

Constructor Details

#initialize(of_type:) ⇒ ListType

Returns a new instance of ListType.



7
8
9
10
# File 'lib/graphql/list_type.rb', line 7

def initialize(of_type:)
  @name = "List"
  @of_type = of_type
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/graphql/list_type.rb', line 6

def name
  @name
end

#of_typeObject (readonly)

Returns the value of attribute of_type.



6
7
8
# File 'lib/graphql/list_type.rb', line 6

def of_type
  @of_type
end

Instance Method Details

#coerce_input(value) ⇒ Object



20
21
22
23
# File 'lib/graphql/list_type.rb', line 20

def coerce_input(value)
  inner_type = of_type
  value.map { |item| inner_type.coerce_input!(item) }
end

#kindObject



12
13
14
# File 'lib/graphql/list_type.rb', line 12

def kind
  GraphQL::TypeKinds::LIST
end

#to_sObject



16
17
18
# File 'lib/graphql/list_type.rb', line 16

def to_s
  "[#{of_type.to_s}]"
end