2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module Boards
|
|
|
|
class Destroy < ::Mutations::BaseMutation
|
|
|
|
graphql_name 'DestroyBoard'
|
|
|
|
|
|
|
|
field :board,
|
|
|
|
Types::BoardType,
|
|
|
|
null: true,
|
2021-10-27 15:23:28 +05:30
|
|
|
description: 'Board after mutation.'
|
2020-11-24 15:15:51 +05:30
|
|
|
argument :id,
|
|
|
|
::Types::GlobalIDType[::Board],
|
|
|
|
required: true,
|
2021-10-27 15:23:28 +05:30
|
|
|
description: 'Global ID of the board to destroy.'
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
authorize :admin_issue_board
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
def resolve(id:)
|
|
|
|
board = authorized_find!(id: id)
|
|
|
|
|
|
|
|
response = ::Boards::DestroyService.new(board.resource_parent, current_user).execute(board)
|
|
|
|
|
|
|
|
{
|
|
|
|
board: response.success? ? nil : board,
|
|
|
|
errors: response.errors
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def find_object(id:)
|
|
|
|
GitlabSchema.object_from_id(id, expected_type: ::Board)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|