Class: GraphQL::Schema::Union

Inherits:
Member
  • Object
show all
Extended by:
Member::AcceptsDefinition
Defined in:
lib/graphql/schema/union.rb

Constant Summary

Constants included from Member::GraphQLTypeNames

Member::GraphQLTypeNames::Boolean, Member::GraphQLTypeNames::ID, Member::GraphQLTypeNames::Int

Class Method Summary collapse

Methods included from Member::HasPath

#path

Methods included from Member::RelayShortcuts

#connection_type, #connection_type_class, #edge_type, #edge_type_class

Methods included from Member::Scoped

#scope_items

Methods included from Member::TypeSystemHelpers

#kind, #list?, #non_null?, #to_list_type, #to_non_null_type, #to_type_signature

Methods included from Member::BaseDSLMethods

#accessible?, #authorized?, #default_graphql_name, #description, #graphql_name, #introspection, #introspection?, #mutation, #name, #overridden_graphql_name, #to_graphql, #visible?

Methods included from Relay::TypeExtensions

#connection_type, #define_connection, #define_edge, #edge_type

Methods included from Member::CachedGraphQLDefinition

#graphql_definition, #initialize_copy

Class Method Details

.kindObject



30
31
32
# File 'lib/graphql/schema/union.rb', line 30

def kind
  GraphQL::TypeKinds::UNION
end

.possible_types(*types) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/graphql/schema/union.rb', line 8

def possible_types(*types)
  if types.any?
    @possible_types = types
  else
    all_possible_types = @possible_types || []
    all_possible_types += super if defined?(super)
    all_possible_types.uniq
  end
end

.to_graphqlObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/graphql/schema/union.rb', line 18

def to_graphql
  type_defn = GraphQL::UnionType.new
  type_defn.name = graphql_name
  type_defn.description = description
  type_defn.possible_types = possible_types
  if respond_to?(:resolve_type)
    type_defn.resolve_type = method(:resolve_type)
  end
  type_defn.[:type_class] = self
  type_defn
end