blob: a169ec58a9afb62a7d3a3752662301abc9edbb2d (
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
|
# frozen_string_literal: true
module Mutations
module Todos
class Restore < ::Mutations::BaseMutation
graphql_name 'TodoRestore'
authorize :update_todo
argument :id,
::Types::GlobalIDType[::Todo],
required: true,
description: 'Global ID of the to-do item to restore.'
field :todo, Types::TodoType,
null: false,
description: 'Requested to-do item.'
def resolve(id:)
todo = authorized_find!(id: id)
restore(todo)
{
todo: todo.reset,
errors: errors_on_object(todo)
}
end
private
def restore(todo)
TodoService.new.restore_todo(todo, current_user)
end
end
end
end
|