Commit f810e67c authored by lauraMon's avatar lauraMon

Add downstream_pipeline field to JobType

parent 3b081dce
...@@ -50,6 +50,8 @@ module Types ...@@ -50,6 +50,8 @@ module Types
null: true, null: true,
description: 'How long the job was enqueued before starting.' 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, 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.' 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, field :detailed_status, Types::Ci::DetailedStatusType, null: true,
...@@ -89,6 +91,10 @@ module Types ...@@ -89,6 +91,10 @@ module Types
Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Pipeline, object.pipeline_id).find
end end
def downstream_pipeline
object.downstream_pipeline if object.respond_to?(:downstream_pipeline)
end
def tags def tags
object.tags.map(&:name) if object.is_a?(::Ci::Build) object.tags.map(&:name) if object.is_a?(::Ci::Build)
end end
......
...@@ -8813,6 +8813,7 @@ Represents the total number of issues and their weights for a particular day. ...@@ -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="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="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="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="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="cijobfinishedat"></a>`finishedAt` | [`Time`](#time) | When a job has finished running. |
| <a id="cijobid"></a>`id` | [`JobID`](#jobid) | ID of the job. | | <a id="cijobid"></a>`id` | [`JobID`](#jobid) | ID of the job. |
...@@ -18,6 +18,7 @@ RSpec.describe Types::Ci::JobType do ...@@ -18,6 +18,7 @@ RSpec.describe Types::Ci::JobType do
created_by_tag created_by_tag
detailedStatus detailedStatus
duration duration
downstreamPipeline
finished_at finished_at
id id
manual_job manual_job
......
...@@ -44,6 +44,10 @@ RSpec.describe 'Query.project.pipeline' do ...@@ -44,6 +44,10 @@ RSpec.describe 'Query.project.pipeline' do
name name
jobs { jobs {
nodes { nodes {
downstreamPipeline {
id
path
}
name name
needs { needs {
nodes { #{all_graphql_fields_for('CiBuildNeed')} } nodes { #{all_graphql_fields_for('CiBuildNeed')} }
...@@ -131,6 +135,8 @@ RSpec.describe 'Query.project.pipeline' do ...@@ -131,6 +135,8 @@ RSpec.describe 'Query.project.pipeline' do
end end
it 'does not generate N+1 queries', :request_store, :use_sql_query_cache do 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) post_graphql(query, current_user: user)
control = ActiveRecord::QueryRecorder.new(skip_cached: false) do control = ActiveRecord::QueryRecorder.new(skip_cached: false) do
...@@ -139,6 +145,8 @@ RSpec.describe 'Query.project.pipeline' do ...@@ -139,6 +145,8 @@ RSpec.describe 'Query.project.pipeline' do
create(:ci_build, name: 'test-a', pipeline: pipeline) create(:ci_build, name: 'test-a', pipeline: pipeline)
create(:ci_build, name: 'test-b', 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 expect do
post_graphql(query, current_user: user) 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