diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-03 12:10:26 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-03 12:10:26 +0000 |
commit | 94822e35f8bfbca6f7b161e22f61b086efb51b2a (patch) | |
tree | 54cd209bc30fe9e7ff84c18a7ecbb1f5c7d0b52d /app/graphql/resolvers/ci | |
parent | f3189d2a01f0b44915b5d7a2301af1445f759c9f (diff) | |
download | gitlab-ce-94822e35f8bfbca6f7b161e22f61b086efb51b2a.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/resolvers/ci')
-rw-r--r-- | app/graphql/resolvers/ci/pipeline_job_artifacts_resolver.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/graphql/resolvers/ci/pipeline_job_artifacts_resolver.rb b/app/graphql/resolvers/ci/pipeline_job_artifacts_resolver.rb new file mode 100644 index 00000000000..35d30827561 --- /dev/null +++ b/app/graphql/resolvers/ci/pipeline_job_artifacts_resolver.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Resolvers + module Ci + class PipelineJobArtifactsResolver < BaseResolver + type [Types::Ci::JobArtifactType], null: false + + alias_method :pipeline, :object + + def resolve + find_job_artifacts + end + + private + + def find_job_artifacts + BatchLoader::GraphQL.for(pipeline).batch do |pipelines, loader| + ActiveRecord::Associations::Preloader.new.preload(pipelines, :job_artifacts) # rubocop: disable CodeReuse/ActiveRecord + + pipelines.each { |pl| loader.call(pl, pl.job_artifacts) } + end + end + end + end +end |