class GraphQL::Schema::TypeMembership
This class joins an object type to an abstract type (interface or union) of which it is a member.
Attributes
Returns
-
Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface>
Returns
-
Class<GraphQL::Schema::Object>
Returns
-
Hash
Public Class Methods
# File lib/graphql/schema/type_membership.rb, line 35 def initialize(abstract_type, object_type, **options) @abstract_type = abstract_type @object_type = object_type @options = options end
Called when an object is hooked up to an abstract type, such as Schema::Union.possible_types or Schema::Object.implements (for interfaces).
Parameters
-
abstract_type(Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface>) -
object_type(Class<GraphQL::Schema::Object>) -
options(Hash) — Any options passed to.possible_typesor.implements
Public Instance Methods
Source
# File lib/graphql/schema/type_membership.rb, line 53 def graphql_name "#{@object_type.graphql_name}.#{@abstract_type.kind.interface? ? "implements" : "belongsTo" }.#{@abstract_type.graphql_name}" end
Source
# File lib/graphql/schema/type_membership.rb, line 61 def inspect "#<#{self.class} #{@object_type.inspect} => #{@abstract_type.inspect}>" end
Source
# File lib/graphql/schema/type_membership.rb, line 47 def visible?(ctx) warden = Warden.from_context(ctx) (@object_type.respond_to?(:visible?) ? warden.visible_type?(@object_type, ctx) : true) && (@abstract_type.respond_to?(:visible?) ? warden.visible_type?(@abstract_type, ctx) : true) end
Returns
-
Boolean— if false, object type will be treated as not a member of abstract type