summaryrefslogtreecommitdiff
path: root/app/graphql
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-11-03 12:10:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-11-03 12:10:26 +0000
commit94822e35f8bfbca6f7b161e22f61b086efb51b2a (patch)
tree54cd209bc30fe9e7ff84c18a7ecbb1f5c7d0b52d /app/graphql
parentf3189d2a01f0b44915b5d7a2301af1445f759c9f (diff)
downloadgitlab-ce-94822e35f8bfbca6f7b161e22f61b086efb51b2a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql')
-rw-r--r--app/graphql/resolvers/ci/pipeline_job_artifacts_resolver.rb25
-rw-r--r--app/graphql/types/ci/job_artifact_type.rb4
-rw-r--r--app/graphql/types/ci/pipeline_type.rb5
3 files changed, 34 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
diff --git a/app/graphql/types/ci/job_artifact_type.rb b/app/graphql/types/ci/job_artifact_type.rb
index f80681bcf36..69bb5325dba 100644
--- a/app/graphql/types/ci/job_artifact_type.rb
+++ b/app/graphql/types/ci/job_artifact_type.rb
@@ -12,6 +12,10 @@ module Types
field :file_type, ::Types::Ci::JobArtifactFileTypeEnum, null: true,
description: 'File type of the artifact.'
+ field :name, GraphQL::Types::String, null: true,
+ description: 'File name of the artifact.',
+ method: :filename
+
def download_path
::Gitlab::Routing.url_helpers.download_project_job_artifacts_path(
object.project,
diff --git a/app/graphql/types/ci/pipeline_type.rb b/app/graphql/types/ci/pipeline_type.rb
index 94e70e02209..da2f11be9e2 100644
--- a/app/graphql/types/ci/pipeline_type.rb
+++ b/app/graphql/types/ci/pipeline_type.rb
@@ -108,6 +108,11 @@ module Types
description: 'Name of the job.'
end
+ field :job_artifacts,
+ null: true,
+ description: 'Job artifacts of the pipeline.',
+ resolver: ::Resolvers::Ci::PipelineJobArtifactsResolver
+
field :source_job,
type: Types::Ci::JobType,
null: true,