diff options
Diffstat (limited to 'app/graphql/types/ci/job_type.rb')
-rw-r--r-- | app/graphql/types/ci/job_type.rb | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/app/graphql/types/ci/job_type.rb b/app/graphql/types/ci/job_type.rb index feaff4e81d8..5b6e8fe8567 100644 --- a/app/graphql/types/ci/job_type.rb +++ b/app/graphql/types/ci/job_type.rb @@ -6,18 +6,32 @@ module Types class JobType < BaseObject graphql_name 'CiJob' - field :pipeline, Types::Ci::PipelineType, null: false, - description: 'Pipeline the job belongs to', - resolve: -> (build, _, _) { Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, build.pipeline_id).find } + field :pipeline, Types::Ci::PipelineType, null: true, + description: 'Pipeline the job belongs to' field :name, GraphQL::STRING_TYPE, null: true, - description: 'Name of the job' + description: 'Name of the job' field :needs, JobType.connection_type, null: true, - description: 'Builds that must complete before the jobs run' + description: 'Builds that must complete before the jobs run' field :detailed_status, Types::Ci::DetailedStatusType, null: true, - description: 'Detailed status of the job', - resolve: -> (obj, _args, ctx) { obj.detailed_status(ctx[:current_user]) } + description: 'Detailed status of the job' field :scheduled_at, Types::TimeType, null: true, - description: 'Schedule for the build' + description: 'Schedule for the build' + field :artifacts, Types::Ci::JobArtifactType.connection_type, null: true, + description: 'Artifacts generated by the job' + + def pipeline + Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find + end + + def detailed_status + object.detailed_status(context[:current_user]) + end + + def artifacts + if object.is_a?(::Ci::Build) + object.job_artifacts + end + end end end end |