123456789_123456789_123456789_123456789_123456789_

Class: GraphQL::Client::Schema::UnionType

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Module
Instance Chain:
self, BaseType, Module
Inherits: Module
  • Object
Defined in: lib/graphql/client/schema/union_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(type) ⇒ UnionType

[ GitHub ]

  
# File 'lib/graphql/client/schema/union_type.rb', line 11

def initialize(type)
  unless type.kind.union?
    raise "expected type to be a Union, but was #{type.class}"
  end

  @type = type
end

Instance Method Details

#define_class(definition, ast_nodes)

[ GitHub ]

  
# File 'lib/graphql/client/schema/union_type.rb', line 23

def define_class(definition, ast_nodes)
  possible_type_names = definition.client.possible_types(type).map(&:graphql_name)
  possible_types = possible_type_names.map { |concrete_type_name|
    schema_module.get_class(concrete_type_name).define_class(definition, ast_nodes)
  }
  new(possible_types)
end

#new(types)

[ GitHub ]

  
# File 'lib/graphql/client/schema/union_type.rb', line 19

def new(types)
  PossibleTypes.new(type, types)
end