Commit 454afb79 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'lm-add-downstream-pipeline-to-job-type' into 'master'

Add downstream_pipeline field to JobType

See merge request gitlab-org/gitlab!77133
parents 32dd97c8 f810e67c
......@@ -50,6 +50,8 @@ module Types
null: true,
description: 'How long the job was enqueued before starting.'
field :downstream_pipeline, Types::Ci::PipelineType, null: true,
description: 'Downstream pipeline for a bridge.'
field :previous_stage_jobs_or_needs, Types::Ci::JobNeedUnion.connection_type, null: true,
description: 'Jobs that must complete before the job runs. Returns `BuildNeed`, which is the needed jobs if the job uses the `needs` keyword, or the previous stage jobs otherwise.'
field :detailed_status, Types::Ci::DetailedStatusType, null: true,
......@@ -89,6 +91,10 @@ module Types
Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find
end
def downstream_pipeline
object.downstream_pipeline if object.respond_to?(:downstream_pipeline)
end
def tags
object.tags.map(&:name) if object.is_a?(::Ci::Build)
end
......
......@@ -8813,6 +8813,7 @@ Represents the total number of issues and their weights for a particular day.
| <a id="cijobcreatedat"></a>`createdAt` | [`Time!`](#time) | When the job was created. |
| <a id="cijobcreatedbytag"></a>`createdByTag` | [`Boolean!`](#boolean) | Whether the job was created by a tag. |
| <a id="cijobdetailedstatus"></a>`detailedStatus` | [`DetailedStatus`](#detailedstatus) | Detailed status of the job. |
| <a id="cijobdownstreampipeline"></a>`downstreamPipeline` | [`Pipeline`](#pipeline) | Downstream pipeline for a bridge. |
| <a id="cijobduration"></a>`duration` | [`Int`](#int) | Duration of the job in seconds. |
| <a id="cijobfinishedat"></a>`finishedAt` | [`Time`](#time) | When a job has finished running. |
| <a id="cijobid"></a>`id` | [`JobID`](#jobid) | ID of the job. |
......@@ -18,6 +18,7 @@ RSpec.describe Types::Ci::JobType do
created_by_tag
detailedStatus
duration
downstreamPipeline
finished_at
id
manual_job
......
......@@ -44,6 +44,10 @@ RSpec.describe 'Query.project.pipeline' do
name
jobs {
nodes {
downstreamPipeline {
id
path
}
name
needs {
nodes { #{all_graphql_fields_for('CiBuildNeed')} }
......@@ -131,6 +135,8 @@ RSpec.describe 'Query.project.pipeline' do
end
it 'does not generate N+1 queries', :request_store, :use_sql_query_cache do
create(:ci_bridge, name: 'bridge-1', pipeline: pipeline, downstream_pipeline: create(:ci_pipeline))
post_graphql(query, current_user: user)
control = ActiveRecord::QueryRecorder.new(skip_cached: false) do
......@@ -139,6 +145,8 @@ RSpec.describe 'Query.project.pipeline' do
create(:ci_build, name: 'test-a', pipeline: pipeline)
create(:ci_build, name: 'test-b', pipeline: pipeline)
create(:ci_bridge, name: 'bridge-2', pipeline: pipeline, downstream_pipeline: create(:ci_pipeline))
create(:ci_bridge, name: 'bridge-3', pipeline: pipeline, downstream_pipeline: create(:ci_pipeline))
expect do
post_graphql(query, current_user: user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment