Sha256: da614d3f46bd112dc9bb3812c14783618a73f21a5c1214e49b181e2e187a7747
Contents?: true
Size: 876 Bytes
Versions: 3
Compression:
Stored size: 876 Bytes
Contents
# A list type wraps another type. # # Get the underlying type with {#unwrap} class GraphQL::ListType < GraphQL::BaseType include GraphQL::BaseType::ModifiesAnotherType attr_reader :of_type, :name def initialize(of_type:) @name = "List" @of_type = of_type end def kind GraphQL::TypeKinds::LIST end def to_s "[#{of_type.to_s}]" end def validate_non_null_input(value) result = GraphQL::Query::InputValidationResult.new ensure_array(value).each_with_index do |item, index| item_result = of_type.validate_input(item) if !item_result.valid? result.merge_result!(index, item_result) end end result end def coerce_non_null_input(value) ensure_array(value).map{ |item| of_type.coerce_input(item) } end private def ensure_array(value) value.is_a?(Array) ? value : [value] end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
graphql-0.12.1 | lib/graphql/list_type.rb |
graphql-0.12.0 | lib/graphql/list_type.rb |
graphql-0.11.1 | lib/graphql/list_type.rb |