123456789_123456789_123456789_123456789_123456789_

Class: GraphQL::Client::Schema::NonNullType

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, BaseType
Inherits: Object
Defined in: lib/graphql/client/schema/non_null_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) ⇒ NonNullType

Internal: Construct non-nullable wrapper from other BaseType.

of_klass - BaseType instance

[ GitHub ]

  
# File 'lib/graphql/client/schema/non_null_type.rb', line 15

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/non_null_type.rb', line 26

attr_reader :of_klass

Instance Method Details

#cast(value, errors)

Internal: Cast JSON value to wrapped value.

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

Returns BaseType instance.

[ GitHub ]

  
# File 'lib/graphql/client/schema/non_null_type.rb', line 34

def cast(value, errors)
  case value
  when NilClass
    raise InvariantError, "expected value to be non-nullable, but was nil"
  else
    of_klass.cast(value, errors)
  end
end

#to_non_null_type

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

Returns NonNullType instance.

[ GitHub ]

  
# File 'lib/graphql/client/schema/non_null_type.rb', line 46

def to_non_null_type
  self
end