Method: GraphQL::Schema::Union.possible_types

Defined in:
lib/graphql/schema/union.rb

.possible_types(*types, context: GraphQL::Query::NullContext, **options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/graphql/schema/union.rb', line 13

def possible_types(*types, context: GraphQL::Query::NullContext, **options)
  if types.any?
    types.each do |t|
      assert_valid_union_member(t)
      type_memberships << type_membership_class.new(self, t, **options)
    end
  else
    visible_types = []
    warden = Warden.from_context(context)
    type_memberships.each do |type_membership|
      if warden.visible_type_membership?(type_membership, context)
        visible_types << type_membership.object_type
      end
    end
    visible_types
  end
end