Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-21 15:06:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-21 15:06:40 +0300
commit0a6ffb540e569bd7a7c548d59b12bc55d4bf9cf1 (patch)
tree9ff7dd7b21a3f9642a8fbb45c922f71a433faf02 /app/graphql/mutations
parenta048261403ea7e12992ccffe704f0779235712d7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/mutations')
-rw-r--r--app/graphql/mutations/todos/restore.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/app/graphql/mutations/todos/restore.rb b/app/graphql/mutations/todos/restore.rb
new file mode 100644
index 00000000000..c4597bd84a2
--- /dev/null
+++ b/app/graphql/mutations/todos/restore.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Todos
+ class Restore < ::Mutations::Todos::Base
+ graphql_name 'TodoRestore'
+
+ authorize :update_todo
+
+ argument :id,
+ GraphQL::ID_TYPE,
+ required: true,
+ description: 'The global id of the todo to restore'
+
+ field :todo, Types::TodoType,
+ null: false,
+ description: 'The requested todo'
+
+ def resolve(id:)
+ todo = authorized_find!(id: id)
+ restore(todo.id) if todo.done?
+
+ {
+ todo: todo.reset,
+ errors: errors_on_object(todo)
+ }
+ end
+
+ private
+
+ def restore(id)
+ TodoService.new.mark_todos_as_pending_by_ids([id], current_user)
+ end
+ end
+ end
+end