summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/alert_management/base.rb
blob: 86908c1449c92cd51f5bdb058837813e99e86cb9 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true

module Mutations
  module AlertManagement
    class Base < BaseMutation
      include Gitlab::Utils::UsageData

      argument :project_path, GraphQL::ID_TYPE,
               required: true,
               description: "The project the alert to mutate is in."

      argument :iid, GraphQL::STRING_TYPE,
               required: true,
               description: "The IID of the alert to mutate."

      field :alert,
            Types::AlertManagement::AlertType,
            null: true,
            description: "The alert after mutation."

      field :todo,
            Types::TodoType,
            null: true,
            description: "The to-do item after mutation."

      field :issue,
            Types::IssueType,
            null: true,
            description: "The issue created after mutation."

      authorize :update_alert_management_alert

      private

      def find_object(project_path:, **args)
        project = Project.find_by_full_path(project_path)

        return unless project

        ::AlertManagement::AlertsFinder.new(current_user, project, args).execute.first
      end
    end
  end
end