diff options
Diffstat (limited to 'app/graphql/resolvers/branch_commit_resolver.rb')
-rw-r--r-- | app/graphql/resolvers/branch_commit_resolver.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/app/graphql/resolvers/branch_commit_resolver.rb b/app/graphql/resolvers/branch_commit_resolver.rb index 11c49e17bc5..ba235251950 100644 --- a/app/graphql/resolvers/branch_commit_resolver.rb +++ b/app/graphql/resolvers/branch_commit_resolver.rb @@ -7,11 +7,16 @@ module Resolvers alias_method :branch, :object def resolve(**args) - return unless branch + commit = branch&.dereferenced_target + return unless commit - commit = branch.dereferenced_target + lazy_project = BatchLoader::GraphQL.for(commit.repository.gl_project_path).batch do |paths, loader| + paths.each { |path| loader.call(path, Project.find_by_full_path(path)) } + end - ::Commit.new(commit, context[:branch_project]) if commit + ::Gitlab::Graphql::Lazy.with_value(lazy_project) do |project| + ::Commit.new(commit, project) if project + end end end end |