diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 12:06:40 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 12:06:40 +0000 |
commit | 0a6ffb540e569bd7a7c548d59b12bc55d4bf9cf1 (patch) | |
tree | 9ff7dd7b21a3f9642a8fbb45c922f71a433faf02 /app/graphql/mutations/todos | |
parent | a048261403ea7e12992ccffe704f0779235712d7 (diff) | |
download | gitlab-ce-0a6ffb540e569bd7a7c548d59b12bc55d4bf9cf1.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/mutations/todos')
-rw-r--r-- | app/graphql/mutations/todos/restore.rb | 36 |
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 |