2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Types
|
|
|
|
class TodoType < BaseObject
|
|
|
|
graphql_name 'Todo'
|
2021-03-11 19:13:27 +05:30
|
|
|
description 'Representing a to-do entry'
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
present_using TodoPresenter
|
|
|
|
|
|
|
|
authorize :read_todo
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
field :id, GraphQL::Types::ID,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'ID of the to-do item.',
|
2019-12-21 20:55:43 +05:30
|
|
|
null: false
|
|
|
|
|
|
|
|
field :project, Types::ProjectType,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'The project this to-do item is associated with.',
|
2019-12-21 20:55:43 +05:30
|
|
|
null: true,
|
2021-02-22 17:27:13 +05:30
|
|
|
authorize: :read_project
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
field :group, Types::GroupType,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'Group this to-do item is associated with.',
|
2019-12-21 20:55:43 +05:30
|
|
|
null: true,
|
2021-02-22 17:27:13 +05:30
|
|
|
authorize: :read_group
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
field :author, Types::UserType,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'The author of this to-do item.',
|
2021-02-22 17:27:13 +05:30
|
|
|
null: false
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
field :action, Types::TodoActionEnum,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'Action of the to-do item.',
|
2019-12-21 20:55:43 +05:30
|
|
|
null: false
|
|
|
|
|
|
|
|
field :target_type, Types::TodoTargetEnum,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'Target type of the to-do item.',
|
2019-12-21 20:55:43 +05:30
|
|
|
null: false
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
field :body, GraphQL::Types::String,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'Body of the to-do item.',
|
2019-12-26 22:10:19 +05:30
|
|
|
null: false,
|
|
|
|
calls_gitaly: true # TODO This is only true when `target_type` is `Commit`. See https://gitlab.com/gitlab-org/gitlab/issues/34757#note_234752665
|
2019-12-21 20:55:43 +05:30
|
|
|
|
|
|
|
field :state, Types::TodoStateEnum,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'State of the to-do item.',
|
2019-12-21 20:55:43 +05:30
|
|
|
null: false
|
|
|
|
|
|
|
|
field :created_at, Types::TimeType,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'Timestamp this to-do item was created.',
|
2019-12-21 20:55:43 +05:30
|
|
|
null: false
|
2021-02-22 17:27:13 +05:30
|
|
|
|
|
|
|
def project
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
|
|
|
|
end
|
|
|
|
|
|
|
|
def group
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, object.group_id).find
|
|
|
|
end
|
|
|
|
|
|
|
|
def author
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.author_id).find
|
|
|
|
end
|
2019-12-21 20:55:43 +05:30
|
|
|
end
|
|
|
|
end
|