Class: GraphQL::Schema::TypeMembership
- Inherits:
- 
      Object
      
        - Object
- GraphQL::Schema::TypeMembership
 
- 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.
Instance Attribute Summary collapse
- 
  
    
      #abstract_type  ⇒ Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface> 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
- 
  
    
      #object_type  ⇒ Class<GraphQL::Schema::Object> 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
- 
  
    
      #options  ⇒ Hash 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Instance Method Summary collapse
- 
  
    
      #graphql_name  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
- 
  
    
      #initialize(abstract_type, object_type, **options)  ⇒ TypeMembership 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Called when an object is hooked up to an abstract type, such as Union.possible_types or Schema::Object.implements (for interfaces). 
- 
  
    
      #inspect  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
- 
  
    
      #path  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
- 
  
    
      #visible?(ctx)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    If false, #object_type will be treated as not a member of #abstract_type. 
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 Schema::Object.implements (for interfaces).
| 23 24 25 26 27 | # File 'lib/graphql/schema/type_membership.rb', line 23 def initialize(abstract_type, object_type, **) @abstract_type = abstract_type @object_type = object_type @options = end | 
Instance Attribute Details
#abstract_type ⇒ Class<GraphQL::Schema::Union>, Module<GraphQL::Schema::Interface> (readonly)
| 12 13 14 | # File 'lib/graphql/schema/type_membership.rb', line 12 def abstract_type @abstract_type end | 
#object_type ⇒ Class<GraphQL::Schema::Object>
| 9 10 11 | # File 'lib/graphql/schema/type_membership.rb', line 9 def object_type @object_type end | 
#options ⇒ Hash (readonly)
| 15 16 17 | # File 'lib/graphql/schema/type_membership.rb', line 15 def @options end | 
Instance Method Details
#graphql_name ⇒ Object
| 36 37 38 | # File 'lib/graphql/schema/type_membership.rb', line 36 def graphql_name "#{@object_type.graphql_name}.#{@abstract_type.kind.interface? ? "implements" : "belongsTo" }.#{@abstract_type.graphql_name}" end | 
#inspect ⇒ Object
| 44 45 46 | # File 'lib/graphql/schema/type_membership.rb', line 44 def inspect "#<#{self.class} #{@object_type.inspect} => #{@abstract_type.inspect}>" end | 
#path ⇒ Object
| 40 41 42 | # File 'lib/graphql/schema/type_membership.rb', line 40 def path graphql_name end | 
#visible?(ctx) ⇒ Boolean
Returns if false, #object_type will be treated as not a member of #abstract_type.
| 30 31 32 33 34 | # File 'lib/graphql/schema/type_membership.rb', line 30 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 |