class GraphQL::Schema::TypeMembership
This class joins an object type to an abstract type (interface or union) of which it is a member.
Attributes
abstract_type[R]
@return [Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface>]
object_type[RW]
@return [Class<GraphQL::Schema::Object>]
Public Class Methods
new(abstract_type, object_type, **options)
click to toggle source
Called when an object is hooked up to an abstract type, such as {Schema::Union.possible_types} or {Schema::Object.implements} (for interfaces).
@param abstract_type
[Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface>] @param object_type
[Class<GraphQL::Schema::Object>] @param options [Hash] Any options passed to `.possible_types` or `.implements`
# File lib/graphql/schema/type_membership.rb, line 20 def initialize(abstract_type, object_type, **options) @abstract_type = abstract_type @object_type = object_type @options = options end
Public Instance Methods
graphql_name()
click to toggle source
# File lib/graphql/schema/type_membership.rb, line 33 def graphql_name "#{@object_type.graphql_name}.#{@abstract_type.kind.interface? ? "implements" : "belongsTo" }.#{@abstract_type.graphql_name}" end
inspect()
click to toggle source
# File lib/graphql/schema/type_membership.rb, line 41 def inspect "#<#{self.class} #{@object_type.inspect} => #{@abstract_type.inspect}>" end
path()
click to toggle source
# File lib/graphql/schema/type_membership.rb, line 37 def path graphql_name end
visible?(ctx)
click to toggle source
@return [Boolean] if false, {#object_type} will be treated as not a member of {#abstract_type}
# File lib/graphql/schema/type_membership.rb, line 27 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