summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/issues/update.rb
blob: 7f6d9b0f988f4d1927df82b80808a3b58edb79bd (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
# frozen_string_literal: true

module Mutations
  module Issues
    class Update < Base
      graphql_name 'UpdateIssue'

      argument :title,
                GraphQL::STRING_TYPE,
                required: false,
                description: copy_field_description(Types::IssueType, :title)

      argument :description,
                GraphQL::STRING_TYPE,
                required: false,
                description: copy_field_description(Types::IssueType, :description)

      argument :due_date,
               Types::TimeType,
               required: false,
               description: copy_field_description(Types::IssueType, :due_date)

      argument :confidential,
               GraphQL::BOOLEAN_TYPE,
               required: false,
               description: copy_field_description(Types::IssueType, :confidential)

      def resolve(project_path:, iid:, **args)
        issue = authorized_find!(project_path: project_path, iid: iid)
        project = issue.project

        ::Issues::UpdateService.new(project, current_user, args).execute(issue)

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

Mutations::Issues::Update.prepend_if_ee('::EE::Mutations::Issues::Update')