Class: GraphQL::Schema::TypeMembership

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/schema/type_membership.rb

Overview

This class joins an object type to an abstract type (interface or union) of which it is a member.

TODO: Not yet implemented for interfaces.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(abstract_type, object_type, **options) ⇒ TypeMembership

Called when an object is hooked up to an abstract type, such as Union.possible_types or Object.implements (for interfaces).

Parameters:



22
23
24
25
26
# File 'lib/graphql/schema/type_membership.rb', line 22

def initialize(abstract_type, object_type, **options)
  @abstract_type = abstract_type
  @object_type = object_type
  @options = options
end

Instance Attribute Details

#abstract_typeClass<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface> (readonly)



14
15
16
# File 'lib/graphql/schema/type_membership.rb', line 14

def abstract_type
  @abstract_type
end

#object_typeClass<GraphQL::Schema::Object>

Returns:



11
12
13
# File 'lib/graphql/schema/type_membership.rb', line 11

def object_type
  @object_type
end

Instance Method Details

#visible?(_ctx) ⇒ Boolean

Returns if false, #object_type will be treated as not a member of #abstract_type.

Returns:



29
30
31
# File 'lib/graphql/schema/type_membership.rb', line 29

def visible?(_ctx)
  true
end