Commit b0edafe7 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '210452-cablett-blocking-issues-details' into 'master'

Expose details of issues blocking issue

See merge request gitlab-org/gitlab!54152
parents f8a813ab dcc5dabc
......@@ -1913,6 +1913,7 @@ Relationship between an epic and an issue.
| `author` | User! | User that created the issue. |
| `blocked` | Boolean! | Indicates the issue is blocked. |
| `blockedByCount` | Int | Count of issues blocking this issue. |
| `blockedByIssues` | IssueConnection | Issues blocking this issue. |
| `closedAt` | Time | Timestamp of when the issue was closed. |
| `confidential` | Boolean! | Indicates the issue is confidential. |
| `createNoteEmail` | String | User specific email address for the issue. |
......@@ -2294,6 +2295,7 @@ A block of time for which a participant is on-call.
| `author` | User! | User that created the issue. |
| `blocked` | Boolean! | Indicates the issue is blocked. |
| `blockedByCount` | Int | Count of issues blocking this issue. |
| `blockedByIssues` | IssueConnection | Issues blocking this issue. |
| `closedAt` | Time | Timestamp of when the issue was closed. |
| `confidential` | Boolean! | Indicates the issue is confidential. |
| `createNoteEmail` | String | User specific email address for the issue. |
......
......@@ -21,6 +21,10 @@ module EE
field :blocked_by_count, GraphQL::INT_TYPE, null: true,
description: 'Count of issues blocking this issue.'
field :blocked_by_issues, ::Types::IssueType.connection_type, null: true,
description: 'Issues blocking this issue.',
complexity: 5
field :health_status, ::Types::HealthStatusEnum, null: true,
description: 'Current health status.'
......@@ -53,6 +57,10 @@ module EE
end
end
def blocked_by_issues
object.blocked_by_issues_for(current_user)
end
def health_status
object.supports_health_status? ? object.health_status : nil
end
......
---
title: Expose details of blocking issues via GraphQL
merge_request: 54152
author:
type: added
......@@ -9,6 +9,7 @@ RSpec.describe GitlabSchema.types['Issue'] do
it { expect(described_class).to have_graphql_field(:health_status) }
it { expect(described_class).to have_graphql_field(:blocked) }
it { expect(described_class).to have_graphql_field(:blocked_by_count) }
it { expect(described_class).to have_graphql_field(:blocked_by_issues) }
it { expect(described_class).to have_graphql_field(:sla_due_at) }
it { expect(described_class).to have_graphql_field(:metric_images) }
......
......@@ -72,6 +72,9 @@ RSpec.describe 'getting an issue list for a project' do
id
blocked
blockedByCount
blockedByIssues {
nodes { id }
}
}
QUERY
end
......@@ -94,16 +97,37 @@ RSpec.describe 'getting an issue list for a project' do
post_graphql(single_issue_query, current_user: current_user)
end
it 'returns the correct result', :aggregate_failures do
check_result(blocked_issue1, true, 1)
check_result(blocked_issue2, true, 2)
check_result(blocking_issue1, false, 0)
check_result(blocking_issue2, false, 0)
context 'correct result' do
before do
post_graphql(query, current_user: current_user)
end
def check_result(issue, expected_blocked, expected_blocked_count)
post_graphql(query, current_user: current_user)
it 'returns the correct blocked count result', :aggregate_failures do
expect_blocked_count(blocked_issue1, true, 1)
expect_blocked_count(blocked_issue2, true, 2)
expect_blocked_count(blocking_issue1, false, 0)
expect_blocked_count(blocking_issue2, false, 0)
expect_blocked_count(blocking_issue3, false, 0)
end
it 'returns the correct blocked issue detail result', :aggregate_failures do
expect_blocking_issues(blocked_issue1, [blocking_issue1])
expect_blocking_issues(blocked_issue2, [blocking_issue2, blocking_issue3])
expect_blocking_issues(blocking_issue1, [])
expect_blocking_issues(blocking_issue2, [])
expect_blocking_issues(blocking_issue3, [])
expect_blocking_issues(unrelated_issue, [])
end
end
def expect_blocking_issues(issue, expected_blocking_issues)
nodes = graphql_data.dig('project', 'issues', 'nodes')
node = nodes.find { |r| r['id'] == issue.to_global_id.to_s }
expect(node['blockedByIssues']['nodes']).to match_array expected_blocking_issues.map { |i| { "id" => i.to_global_id.to_s }}
end
def expect_blocked_count(issue, expected_blocked, expected_blocked_count)
nodes = graphql_data.dig('project', 'issues', 'nodes')
node = nodes.find { |r| r['id'] == issue.to_global_id.to_s }
......
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