summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/issues/link_alerts.rb
blob: c45e90c598f4435c230a0b953e5a718e1b982d39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

module Mutations
  module Issues
    class LinkAlerts < Base
      graphql_name 'IssueLinkAlerts'

      argument :alert_references, [GraphQL::Types::String],
        required: true,
        description: 'Alerts references to be linked to the incident.'

      authorize :admin_issue

      def resolve(project_path:, iid:, alert_references:)
        issue = authorized_find!(project_path: project_path, iid: iid)

        ::IncidentManagement::LinkAlerts::CreateService.new(issue, current_user, alert_references).execute

        {
          issue: issue,
          errors: errors_on_object(issue)
        }
      end
    end
  end
end