summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/todos/mark_all_done.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-21 18:06:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-21 18:06:26 +0000
commit7aada820a908502f40080274fb181281afd44615 (patch)
treee82fbe264cb5d410fce7acea0a7fd74a962952ba /app/graphql/mutations/todos/mark_all_done.rb
parentb5ad06174bb1de39438c90847abb86ac6988e944 (diff)
downloadgitlab-ce-7aada820a908502f40080274fb181281afd44615.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/mutations/todos/mark_all_done.rb')
-rw-r--r--app/graphql/mutations/todos/mark_all_done.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/app/graphql/mutations/todos/mark_all_done.rb b/app/graphql/mutations/todos/mark_all_done.rb
new file mode 100644
index 00000000000..5694985717c
--- /dev/null
+++ b/app/graphql/mutations/todos/mark_all_done.rb
@@ -0,0 +1,35 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Todos
+ class MarkAllDone < ::Mutations::Todos::Base
+ graphql_name 'TodosMarkAllDone'
+
+ authorize :update_user
+
+ field :updated_ids,
+ [GraphQL::ID_TYPE],
+ null: false,
+ description: 'Ids of the updated todos'
+
+ def resolve
+ authorize!(current_user)
+
+ updated_ids = mark_all_todos_done
+
+ {
+ updated_ids: map_to_global_ids(updated_ids),
+ errors: []
+ }
+ end
+
+ private
+
+ def mark_all_todos_done
+ return [] unless current_user
+
+ TodoService.new.mark_all_todos_as_done_by_user(current_user)
+ end
+ end
+ end
+end