Class: Gitlab::Graphql::Loaders::LazyRelationLoader
- Inherits:
 - 
      Object
      
        
- Object
 - Gitlab::Graphql::Loaders::LazyRelationLoader
 
 
- Defined in:
 - lib/gitlab/graphql/loaders/lazy_relation_loader.rb,
lib/gitlab/graphql/loaders/lazy_relation_loader/registry.rb,
lib/gitlab/graphql/loaders/lazy_relation_loader/top_n_loader.rb,
lib/gitlab/graphql/loaders/lazy_relation_loader/relation_proxy.rb 
Defined Under Namespace
Classes: Registry, RelationProxy, TopNLoader
Class Attribute Summary collapse
- 
  
    
      .association  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute association.
 - 
  
    
      .model  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute model.
 
Class Method Summary collapse
- 
  
    
      .inherited(klass)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Automatically register the inheriting classes to GitlabSchema as lazy objects.
 
Instance Method Summary collapse
- 
  
    
      #initialize(query_ctx, object, **kwargs)  ⇒ LazyRelationLoader 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of LazyRelationLoader.
 - 
  
    
      #load  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns an instance of ‘RelationProxy` for the object (parent model).
 
Constructor Details
#initialize(query_ctx, object, **kwargs) ⇒ LazyRelationLoader
Returns a new instance of LazyRelationLoader.
      17 18 19 20 21 22 23 24  | 
    
      # File 'lib/gitlab/graphql/loaders/lazy_relation_loader.rb', line 17 def initialize(query_ctx, object, **kwargs) @query_ctx = query_ctx @object = object @kwargs = kwargs query_ctx[loader_cache_key] ||= Registry.new(relation(**kwargs)) query_ctx[loader_cache_key].register(object) end  | 
  
Class Attribute Details
.association ⇒ Object
Returns the value of attribute association.
      8 9 10  | 
    
      # File 'lib/gitlab/graphql/loaders/lazy_relation_loader.rb', line 8 def association @association end  | 
  
.model ⇒ Object
Returns the value of attribute model.
      8 9 10  | 
    
      # File 'lib/gitlab/graphql/loaders/lazy_relation_loader.rb', line 8 def model @model end  | 
  
Class Method Details
.inherited(klass) ⇒ Object
Automatically register the inheriting classes to GitlabSchema as lazy objects.
      12 13 14  | 
    
      # File 'lib/gitlab/graphql/loaders/lazy_relation_loader.rb', line 12 def inherited(klass) GitlabSchema.lazy_resolve(klass, :load) end  | 
  
Instance Method Details
#load ⇒ Object
Returns an instance of ‘RelationProxy` for the object (parent model). The returned object behaves like an Active Record relation to support keyset pagination.
      29 30 31 32 33 34 35 36 37 38  | 
    
      # File 'lib/gitlab/graphql/loaders/lazy_relation_loader.rb', line 29 def load case reflection.macro when :has_many relation_proxy when :has_one relation_proxy.last else raise 'Not supported association type!' end end  |