Class: GraphQL::Client::Schema::UnionType
- Inherits:
-
Module
- Object
- Module
- GraphQL::Client::Schema::UnionType
- Includes:
- BaseType
- Defined in:
- lib/graphql/client/schema/union_type.rb
Instance Attribute Summary
Attributes included from BaseType
Instance Method Summary collapse
- #define_class(definition, ast_nodes) ⇒ Object
-
#initialize(type) ⇒ UnionType
constructor
A new instance of UnionType.
- #new(types) ⇒ Object
Methods included from BaseType
#cast, #to_list_type, #to_non_null_type
Constructor Details
#initialize(type) ⇒ UnionType
Returns a new instance of UnionType.
11 12 13 14 15 16 17 |
# 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) ⇒ Object
23 24 25 26 27 28 29 |
# 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) ⇒ Object
19 20 21 |
# File 'lib/graphql/client/schema/union_type.rb', line 19 def new(types) PossibleTypes.new(type, types) end |