summaryrefslogtreecommitdiff
path: root/app/graphql/types/todo_type.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-22 11:31:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-22 11:31:16 +0000
commit905c1110b08f93a19661cf42a276c7ea90d0a0ff (patch)
tree756d138db422392c00471ab06acdff92c5a9b69c /app/graphql/types/todo_type.rb
parent50d93f8d1686950fc58dda4823c4835fd0d8c14b (diff)
downloadgitlab-ce-905c1110b08f93a19661cf42a276c7ea90d0a0ff.tar.gz
Add latest changes from gitlab-org/gitlab@12-4-stable-ee
Diffstat (limited to 'app/graphql/types/todo_type.rb')
-rw-r--r--app/graphql/types/todo_type.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/app/graphql/types/todo_type.rb b/app/graphql/types/todo_type.rb
new file mode 100644
index 00000000000..d36daaf7dec
--- /dev/null
+++ b/app/graphql/types/todo_type.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+module Types
+ class TodoType < BaseObject
+ graphql_name 'Todo'
+ description 'Representing a todo entry'
+
+ present_using TodoPresenter
+
+ authorize :read_todo
+
+ field :id, GraphQL::ID_TYPE,
+ description: 'Id of the todo',
+ null: false
+
+ field :project, Types::ProjectType,
+ description: 'The project this todo is associated with',
+ null: true,
+ authorize: :read_project,
+ resolve: -> (todo, args, context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, todo.project_id).find }
+
+ field :group, Types::GroupType,
+ description: 'Group this todo is associated with',
+ null: true,
+ authorize: :read_group,
+ resolve: -> (todo, args, context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, todo.group_id).find }
+
+ field :author, Types::UserType,
+ description: 'The owner of this todo',
+ null: false,
+ resolve: -> (todo, args, context) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, todo.author_id).find }
+
+ field :action, Types::TodoActionEnum,
+ description: 'Action of the todo',
+ null: false
+
+ field :target_type, Types::TodoTargetEnum,
+ description: 'Target type of the todo',
+ null: false
+
+ field :body, GraphQL::STRING_TYPE,
+ description: 'Body of the todo',
+ null: false
+
+ field :state, Types::TodoStateEnum,
+ description: 'State of the todo',
+ null: false
+
+ field :created_at, Types::TimeType,
+ description: 'Timestamp this todo was created',
+ null: false
+ end
+end