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-12 18:06:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-12 18:06:26 +0300
commit69944ffb68788d190e81ff7e33db5dcb6c903184 (patch)
tree4112a1285f186c140749e8410a8a2788b6812500 /app/graphql
parent1b7381e998ff4b33ec8f633766030082e95f10c8 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql')
-rw-r--r--app/graphql/mutations/todos/base.rb17
-rw-r--r--app/graphql/mutations/todos/mark_done.rb38
-rw-r--r--app/graphql/types/mutation_type.rb1
3 files changed, 56 insertions, 0 deletions
diff --git a/app/graphql/mutations/todos/base.rb b/app/graphql/mutations/todos/base.rb
new file mode 100644
index 00000000000..b6c7b320be1
--- /dev/null
+++ b/app/graphql/mutations/todos/base.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Todos
+ class Base < ::Mutations::BaseMutation
+ private
+
+ def find_object(id:)
+ GitlabSchema.object_from_id(id)
+ end
+
+ def to_global_id(id)
+ ::URI::GID.build(app: GlobalID.app, model_name: Todo.name, model_id: id, params: nil).to_s
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/todos/mark_done.rb b/app/graphql/mutations/todos/mark_done.rb
new file mode 100644
index 00000000000..5483708b5c6
--- /dev/null
+++ b/app/graphql/mutations/todos/mark_done.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Todos
+ class MarkDone < ::Mutations::Todos::Base
+ graphql_name 'TodoMarkDone'
+
+ authorize :update_todo
+
+ argument :id,
+ GraphQL::ID_TYPE,
+ required: true,
+ description: 'The global id of the todo to mark as done'
+
+ field :todo, Types::TodoType,
+ null: false,
+ description: 'The requested todo'
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def resolve(id:)
+ todo = authorized_find!(id: id)
+ mark_done(Todo.where(id: todo.id)) unless todo.done?
+
+ {
+ todo: todo.reset,
+ errors: errors_on_object(todo)
+ }
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
+
+ private
+
+ def mark_done(todo)
+ TodoService.new.mark_todos_as_done(todo, current_user)
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb
index c636bf0e31f..632e1fdc2df 100644
--- a/app/graphql/types/mutation_type.rb
+++ b/app/graphql/types/mutation_type.rb
@@ -16,6 +16,7 @@ module Types
mount_mutation Mutations::Notes::Create::ImageDiffNote, calls_gitaly: true
mount_mutation Mutations::Notes::Update
mount_mutation Mutations::Notes::Destroy
+ mount_mutation Mutations::Todos::MarkDone
end
end