2020-09-11 08:08:50 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module Boards
|
|
|
|
class Destroy < ::Mutations::BaseMutation
|
|
|
|
graphql_name 'DestroyBoard'
|
|
|
|
|
|
|
|
field :board,
|
|
|
|
Types::BoardType,
|
|
|
|
null: true,
|
2021-01-07 07:10:24 -05:00
|
|
|
description: 'The board after mutation.'
|
2020-09-11 08:08:50 -04:00
|
|
|
argument :id,
|
|
|
|
::Types::GlobalIDType[::Board],
|
|
|
|
required: true,
|
2021-01-07 07:10:24 -05:00
|
|
|
description: 'The global ID of the board to destroy.'
|
2020-09-11 08:08:50 -04:00
|
|
|
|
2021-03-02 19:10:50 -05:00
|
|
|
authorize :admin_issue_board
|
2020-09-11 08:08:50 -04:00
|
|
|
|
|
|
|
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
|