Class: GraphQL::ListType
- 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
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#of_type ⇒ Object
readonly
Returns the value of attribute of_type.
Instance Method Summary collapse
- #coerce_non_null_input(value) ⇒ Object
-
#initialize(of_type:) ⇒ ListType
constructor
A new instance of ListType.
- #kind ⇒ Object
- #to_s ⇒ Object
- #valid_non_null_input?(value) ⇒ Boolean
Methods included from BaseType::ModifiesAnotherType
Methods inherited from BaseType
#==, #coerce_input, #resolve_type, #to_list_type, #to_non_null_type, #unwrap, #valid_input?
Methods included from DefinitionHelpers::DefinedByConfig
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/graphql/list_type.rb', line 6 def name @name end |
#of_type ⇒ Object (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_non_null_input(value) ⇒ Object
25 26 27 |
# File 'lib/graphql/list_type.rb', line 25 def coerce_non_null_input(value) value.map{ |item| of_type.coerce_input(item) } end |
#kind ⇒ Object
12 13 14 |
# File 'lib/graphql/list_type.rb', line 12 def kind GraphQL::TypeKinds::LIST end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/graphql/list_type.rb', line 16 def to_s "[#{of_type.to_s}]" end |
#valid_non_null_input?(value) ⇒ Boolean
20 21 22 23 |
# File 'lib/graphql/list_type.rb', line 20 def valid_non_null_input?(value) return false unless value.is_a?(Array) value.all?{ |item| of_type.valid_input?(item) } end |