Class: GraphQL::ListType
- Includes:
- BaseType::ModifiesAnotherType
- Defined in:
- lib/graphql/list_type.rb
Overview
A list type modifies another type.
List types can be created with the type helper (types[InnerType]
)
or BaseType#to_list_type (InnerType.to_list_type
)
For return types, it says that the returned value will be a list of the modified.
For input types, it says that the incoming value will be a list of the modified type.
Given a list type, you can always get the underlying type with BaseType::ModifiesAnotherType#unwrap.
Instance Attribute Summary collapse
-
#of_type ⇒ Object
readonly
Returns the value of attribute of_type.
Attributes inherited from BaseType
#ast_node, #default_relay, #default_scalar, #description, #introspection, #name
Instance Method Summary collapse
-
#coerce_result(value, ctx = nil) ⇒ Object
-
#initialize(of_type:) ⇒ ListType
constructor
A new instance of ListType.
-
#kind ⇒ Object
-
#list? ⇒ Boolean
-
#to_s ⇒ Object
(also: #inspect)
Methods included from BaseType::ModifiesAnotherType
Methods inherited from BaseType
#==, #coerce_input, #coerce_isolated_input, #coerce_isolated_result, #default_relay?, #default_scalar?, #get_field, #initialize_copy, #introspection?, #non_null?, resolve_related_type, #resolve_type, #to_definition, #to_list_type, #to_non_null_type, #unwrap, #valid_input?, #valid_isolated_input?, #validate_input, #validate_isolated_input
Methods included from Relay::TypeExtensions
#connection_type, #define_connection, #define_edge, #edge_type
Methods included from Define::InstanceDefinable
#define, #initialize_copy, #metadata, #redefine
Methods included from Define::NonNullWithBang
Constructor Details
#initialize(of_type:) ⇒ ListType
Returns a new instance of ListType
30 31 32 33 |
# File 'lib/graphql/list_type.rb', line 30 def initialize(of_type:) super() @of_type = of_type end |
Instance Attribute Details
#of_type ⇒ Object (readonly)
Returns the value of attribute of_type
29 30 31 |
# File 'lib/graphql/list_type.rb', line 29 def of_type @of_type end |
Instance Method Details
#coerce_result(value, ctx = nil) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/graphql/list_type.rb', line 44 def coerce_result(value, ctx = nil) if ctx.nil? warn_deprecated_coerce("coerce_isolated_result") ctx = GraphQL::Query::NullContext end ensure_array(value).map { |item| item.nil? ? nil : of_type.coerce_result(item, ctx) } end |
#kind ⇒ Object
35 36 37 |
# File 'lib/graphql/list_type.rb', line 35 def kind GraphQL::TypeKinds::LIST end |
#list? ⇒ Boolean
52 53 54 |
# File 'lib/graphql/list_type.rb', line 52 def list? true end |
#to_s ⇒ Object Also known as: inspect
39 40 41 |
# File 'lib/graphql/list_type.rb', line 39 def to_s "[#{of_type.to_s}]" end |