Class: Gitlab::Graphql::Loaders::BatchCommitLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/graphql/loaders/batch_commit_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(container_class:, container_id:, oid:) ⇒ BatchCommitLoader

Returns a new instance of BatchCommitLoader.


7
8
9
10
11
# File 'lib/gitlab/graphql/loaders/batch_commit_loader.rb', line 7

def initialize(container_class:, container_id:, oid:)
  @container_class = container_class
  @container_id = container_id
  @oid = oid
end

Instance Method Details

#findObject


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/graphql/loaders/batch_commit_loader.rb', line 13

def find
  Gitlab::Graphql::Lazy.with_value(find_containers) do |container|
    BatchLoader::GraphQL.for(oid).batch(key: container) do |oids, loader, args|
      container = args[:key]

      container.repository.commits_by(oids: oids).each do |commit|
        loader.call(commit.id, commit) if commit
      end
    end
  end
end