123456789_123456789_123456789_123456789_123456789_

Class: GraphQL::Client::Schema::ListType

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, BaseType
Inherits: Object
Defined in: lib/graphql/client/schema/list_type.rb

Class Method Summary

Instance Attribute Summary

BaseType - Included

#schema_module

Internal: Get owner schema Module container.

#type

Public: Get associated GraphQL::BaseType with for this class.

Instance Method Summary

BaseType - Included

#cast

Internal: Cast JSON value to wrapped value.

#to_list_type

Internal: Get list wrapper of this type class.

#to_non_null_type

Internal: Get non-nullable wrapper of this type class.

Constructor Details

.new(of_klass) ⇒ ListType

Internal: Construct list wrapper from other BaseType.

of_klass - BaseType instance

[ GitHub ]

  
# File 'lib/graphql/client/schema/list_type.rb', line 16

def initialize(of_klass)
  unless of_klass.is_a?(BaseType)
    raise TypeError, "expected #{of_klass.inspect} to be a #{BaseType}"
  end

  @of_klass = of_klass
end

Instance Attribute Details

#of_klass (readonly)

Internal: Get wrapped klass.

Returns BaseType instance.

[ GitHub ]

  
# File 'lib/graphql/client/schema/list_type.rb', line 27

attr_reader :of_klass

Instance Method Details

#cast(values, errors)

Internal: Cast JSON value to wrapped value.

values - JSON value errors - ::GraphQL::Client::Errors instance

Returns List instance or nil.

[ GitHub ]

  
# File 'lib/graphql/client/schema/list_type.rb', line 35

def cast(values, errors)
  case values
  when Array
    List.new(values.each_with_index.map { |e, idx|
      of_klass.cast(e, errors.filter_by_path(idx))
    }, errors)
  when NilClass
    nil
  else
    raise InvariantError, "expected value to be a list, but was #{values.class}"
  end
end

#to_list_type

Internal: Get list wrapper of this type class.

Returns ListType instance.

[ GitHub ]

  
# File 'lib/graphql/client/schema/list_type.rb', line 51

def to_list_type
  self
end