Commit f7df08df authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'expose-issue-iid-in-alert-management-alert-graphql' into 'master'

Expose issue iid in alert management alert graphql

See merge request gitlab-org/gitlab!31313
parents 5898f3c6 70a65182
......@@ -13,6 +13,11 @@ module Types
null: false,
description: 'Internal ID of the alert'
field :issue_iid,
GraphQL::ID_TYPE,
null: true,
description: 'Internal ID of the GitLab issue attached to the alert'
field :title,
GraphQL::STRING_TYPE,
null: true,
......
......@@ -92,6 +92,8 @@ module AlertManagement
end
end
delegate :iid, to: :issue, prefix: true, allow_nil: true
scope :for_iid, -> (iid) { where(iid: iid) }
scope :for_status, -> (status) { where(status: status) }
scope :for_fingerprint, -> (project, fingerprint) { where(project: project, fingerprint: fingerprint) }
......
---
title: Exposes issue IID in Alert Management Alert's GraphQL endpoint
merge_request: 31313
author:
type: added
......@@ -177,6 +177,11 @@ type AlertManagementAlert {
"""
iid: ID!
"""
Internal ID of the GitLab issue attached to the alert
"""
issueIid: ID
"""
Monitoring tool the alert came from
"""
......
......@@ -504,6 +504,20 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "issueIid",
"description": "Internal ID of the GitLab issue attached to the alert",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "monitoringTool",
"description": "Monitoring tool the alert came from",
......
......@@ -59,6 +59,7 @@ Describes an alert from the project's Alert Management
| `eventCount` | Int | Number of events of this alert |
| `hosts` | String! => Array | List of hosts the alert came from |
| `iid` | ID! | Internal ID of the alert |
| `issueIid` | ID | Internal ID of the GitLab issue attached to the alert |
| `monitoringTool` | String | Monitoring tool the alert came from |
| `service` | String | Service the alert came from |
| `severity` | AlertManagementSeverity | Severity of the alert |
......
......@@ -10,6 +10,7 @@ describe GitlabSchema.types['AlertManagementAlert'] do
it 'exposes the expected fields' do
expected_fields = %i[
iid
issue_iid
title
description
severity
......
......@@ -7,7 +7,7 @@ describe 'getting Alert Management Alerts' do
let_it_be(:payload) { { 'custom' => { 'alert' => 'payload' } } }
let_it_be(:project) { create(:project, :repository) }
let_it_be(:current_user) { create(:user) }
let_it_be(:alert_1) { create(:alert_management_alert, :all_fields, :resolved, project: project, severity: :low) }
let_it_be(:alert_1) { create(:alert_management_alert, :all_fields, :resolved, project: project, issue: nil, severity: :low) }
let_it_be(:alert_2) { create(:alert_management_alert, :all_fields, project: project, severity: :critical, payload: payload) }
let_it_be(:other_project_alert) { create(:alert_management_alert, :all_fields) }
......@@ -58,6 +58,7 @@ describe 'getting Alert Management Alerts' do
it 'returns the correct properties of the alerts' do
expect(first_alert).to include(
'iid' => alert_2.iid.to_s,
'issueIid' => alert_2.issue_iid.to_s,
'title' => alert_2.title,
'description' => alert_2.description,
'severity' => alert_2.severity.upcase,
......@@ -74,6 +75,8 @@ describe 'getting Alert Management Alerts' do
)
expect(second_alert).to include(
'iid' => alert_1.iid.to_s,
'issueIid' => nil,
'status' => 'RESOLVED',
'endedAt' => alert_1.ended_at.strftime('%Y-%m-%dT%H:%M:%SZ')
)
......
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