summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/notes/destroy.rb
blob: a81322bc9b7f064830ebd35f275dd5dca1437b93 (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
# frozen_string_literal: true

module Mutations
  module Notes
    class Destroy < Base
      graphql_name 'DestroyNote'

      authorize :admin_note

      argument :id,
                GraphQL::ID_TYPE,
                required: true,
                description: 'The global id of the note to destroy'

      def resolve(id:)
        note = authorized_find!(id: id)

        check_object_is_note!(note)

        ::Notes::DestroyService.new(note.project, current_user).execute(note)

        {
          errors: []
        }
      end
    end
  end
end