debian-mirror-gitlab/app/graphql/mutations/todos/restore.rb

37 lines
761 B
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
module Mutations
module Todos
class Restore < ::Mutations::Todos::Base
graphql_name 'TodoRestore'
authorize :update_todo
argument :id,
2021-01-03 14:25:43 +05:30
::Types::GlobalIDType[::Todo],
2020-01-01 13:55:28 +05:30
required: true,
2021-10-27 15:23:28 +05:30
description: 'Global ID of the to-do item to restore.'
2020-01-01 13:55:28 +05:30
field :todo, Types::TodoType,
null: false,
2021-10-27 15:23:28 +05:30
description: 'Requested to-do item.'
2020-01-01 13:55:28 +05:30
def resolve(id:)
todo = authorized_find!(id: id)
2020-06-23 00:09:42 +05:30
restore(todo)
2020-01-01 13:55:28 +05:30
{
todo: todo.reset,
errors: errors_on_object(todo)
}
end
private
2020-06-23 00:09:42 +05:30
def restore(todo)
TodoService.new.restore_todo(todo, current_user)
2020-01-01 13:55:28 +05:30
end
end
end
end