Sha256: ef1e48120efa22611b4861022b464f854c62bfd5cb0eb203bd54d55eb8377d30

Contents?: true

Size: 598 Bytes

Versions: 6

Compression:

Stored size: 598 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 valid_non_null_input?(value)
    return false unless value.is_a?(Array)
    value.all?{ |item| of_type.valid_input?(item) }
  end

  def coerce_non_null_input(value)
    value.map{ |item| of_type.coerce_input(item) }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
graphql-0.10.6 lib/graphql/list_type.rb
graphql-0.10.5 lib/graphql/list_type.rb
graphql-0.10.4 lib/graphql/list_type.rb
graphql-0.10.3 lib/graphql/list_type.rb
graphql-0.10.2 lib/graphql/list_type.rb
graphql-0.10.1 lib/graphql/list_type.rb