2018-11-27 15:10:40 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Types
|
|
|
|
class IssueType < BaseObject
|
|
|
|
graphql_name 'Issue'
|
|
|
|
|
2020-10-21 12:08:47 +00:00
|
|
|
connection_type_class(Types::IssueConnectionType)
|
2020-07-16 06:09:33 +00:00
|
|
|
|
2019-06-07 17:13:26 +00:00
|
|
|
implements(Types::Notes::NoteableType)
|
2020-09-09 21:08:33 +00:00
|
|
|
implements(Types::CurrentUserTodos)
|
2019-06-07 17:13:26 +00:00
|
|
|
|
2019-03-04 02:30:32 +00:00
|
|
|
authorize :read_issue
|
|
|
|
|
|
|
|
expose_permissions Types::PermissionTypes::Issue
|
|
|
|
|
2018-11-27 15:10:40 +00:00
|
|
|
present_using IssuePresenter
|
|
|
|
|
2020-07-09 15:08:59 +00:00
|
|
|
field :id, GraphQL::ID_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: "ID of the issue."
|
2019-10-31 12:06:26 +00:00
|
|
|
field :iid, GraphQL::ID_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: "Internal ID of the issue."
|
2019-10-31 12:06:26 +00:00
|
|
|
field :title, GraphQL::STRING_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Title of the issue.'
|
2019-06-20 08:02:33 +00:00
|
|
|
markdown_field :title_html, null: true
|
2019-10-31 12:06:26 +00:00
|
|
|
field :description, GraphQL::STRING_TYPE, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Description of the issue.'
|
2019-06-20 08:02:33 +00:00
|
|
|
markdown_field :description_html, null: true
|
2019-10-31 12:06:26 +00:00
|
|
|
field :state, IssueStateEnum, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'State of the issue.'
|
2019-10-31 12:06:26 +00:00
|
|
|
|
|
|
|
field :reference, GraphQL::STRING_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Internal reference of the issue. Returned in shortened format by default.',
|
2019-10-31 12:06:26 +00:00
|
|
|
method: :to_reference do
|
|
|
|
argument :full, GraphQL::BOOLEAN_TYPE, required: false, default_value: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Boolean option specifying whether the reference should be returned in full.'
|
2019-05-31 16:46:16 +00:00
|
|
|
end
|
|
|
|
|
2019-10-31 12:06:26 +00:00
|
|
|
field :author, Types::UserType, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'User that created the issue.'
|
2018-11-27 15:10:40 +00:00
|
|
|
|
2020-09-08 00:08:20 +00:00
|
|
|
field :assignees, Types::UserType.connection_type, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Assignees of the issue.'
|
2018-11-27 15:10:40 +00:00
|
|
|
|
2020-10-28 09:08:37 +00:00
|
|
|
field :updated_by, Types::UserType, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'User that last updated the issue.'
|
2020-10-28 09:08:37 +00:00
|
|
|
|
2020-09-04 09:08:38 +00:00
|
|
|
field :labels, Types::LabelType.connection_type, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Labels of the issue.'
|
2019-10-31 12:06:26 +00:00
|
|
|
field :milestone, Types::MilestoneType, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Milestone of the issue.'
|
2018-11-27 15:10:40 +00:00
|
|
|
|
2019-10-31 12:06:26 +00:00
|
|
|
field :due_date, Types::TimeType, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Due date of the issue.'
|
2019-10-31 12:06:26 +00:00
|
|
|
field :confidential, GraphQL::BOOLEAN_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Indicates the issue is confidential.'
|
2019-10-31 12:06:26 +00:00
|
|
|
field :discussion_locked, GraphQL::BOOLEAN_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Indicates discussion is locked on the issue.'
|
2018-11-27 15:10:40 +00:00
|
|
|
|
2019-10-31 12:06:26 +00:00
|
|
|
field :upvotes, GraphQL::INT_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Number of upvotes the issue has received.'
|
2019-10-31 12:06:26 +00:00
|
|
|
field :downvotes, GraphQL::INT_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Number of downvotes the issue has received.'
|
2019-10-31 12:06:26 +00:00
|
|
|
field :user_notes_count, GraphQL::INT_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Number of user notes of the issue.',
|
2020-12-08 03:09:37 +00:00
|
|
|
resolver: Resolvers::UserNotesCountResolver
|
2020-11-04 18:08:42 +00:00
|
|
|
field :user_discussions_count, GraphQL::INT_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Number of user discussions in the issue.',
|
2020-12-08 03:09:37 +00:00
|
|
|
resolver: Resolvers::UserDiscussionsCountResolver
|
2019-10-31 12:06:26 +00:00
|
|
|
field :web_path, GraphQL::STRING_TYPE, null: false, method: :issue_path,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Web path of the issue.'
|
2019-10-31 12:06:26 +00:00
|
|
|
field :web_url, GraphQL::STRING_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Web URL of the issue.'
|
2019-10-31 12:06:26 +00:00
|
|
|
field :relative_position, GraphQL::INT_TYPE, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Relative position of the issue (used for positioning in epic tree and issue boards).'
|
2019-10-31 12:06:26 +00:00
|
|
|
|
|
|
|
field :participants, Types::UserType.connection_type, null: true, complexity: 5,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'List of participants in the issue.'
|
2020-11-09 03:09:03 +00:00
|
|
|
field :emails_disabled, GraphQL::BOOLEAN_TYPE, null: false,
|
|
|
|
method: :project_emails_disabled?,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Indicates if a project has email notifications disabled: `true` if email notifications are disabled.'
|
2019-11-18 15:06:27 +00:00
|
|
|
field :subscribed, GraphQL::BOOLEAN_TYPE, method: :subscribed?, null: false, complexity: 5,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Indicates the currently logged in user is subscribed to the issue.'
|
2019-10-31 12:06:26 +00:00
|
|
|
field :time_estimate, GraphQL::INT_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Time estimate of the issue.'
|
2019-10-31 12:06:26 +00:00
|
|
|
field :total_time_spent, GraphQL::INT_TYPE, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Total time reported as spent on the issue.'
|
2020-10-22 12:08:41 +00:00
|
|
|
field :human_time_estimate, GraphQL::STRING_TYPE, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Human-readable time estimate of the issue.'
|
2020-10-22 12:08:41 +00:00
|
|
|
field :human_total_time_spent, GraphQL::STRING_TYPE, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Human-readable total time reported as spent on the issue.'
|
2019-10-31 12:06:26 +00:00
|
|
|
|
|
|
|
field :closed_at, Types::TimeType, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Timestamp of when the issue was closed.'
|
2019-10-31 12:06:26 +00:00
|
|
|
|
|
|
|
field :created_at, Types::TimeType, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Timestamp of when the issue was created.'
|
2019-10-31 12:06:26 +00:00
|
|
|
field :updated_at, Types::TimeType, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Timestamp of when the issue was last updated.'
|
2019-10-31 12:06:26 +00:00
|
|
|
|
|
|
|
field :task_completion_status, Types::TaskCompletionStatus, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Task completion status of the issue.'
|
2020-05-13 15:08:23 +00:00
|
|
|
|
|
|
|
field :design_collection, Types::DesignManagement::DesignCollectionType, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Collection of design images associated with this issue.'
|
2020-08-05 00:09:52 +00:00
|
|
|
|
|
|
|
field :type, Types::IssueTypeEnum, null: true,
|
|
|
|
method: :issue_type,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Type of the issue.'
|
2020-08-25 18:10:49 +00:00
|
|
|
|
|
|
|
field :alert_management_alert,
|
|
|
|
Types::AlertManagement::AlertType,
|
|
|
|
null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Alert associated to this issue.'
|
2020-09-07 12:08:27 +00:00
|
|
|
|
|
|
|
field :severity, Types::IssuableSeverityEnum, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Severity level of the incident.'
|
2020-09-25 09:09:40 +00:00
|
|
|
|
2020-11-11 12:09:06 +00:00
|
|
|
field :moved, GraphQL::BOOLEAN_TYPE, method: :moved?, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Indicates if issue got moved from other project.'
|
2020-11-11 12:09:06 +00:00
|
|
|
|
|
|
|
field :moved_to, Types::IssueType, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Updated Issue after it got moved to another project.'
|
2020-11-11 12:09:06 +00:00
|
|
|
|
2021-01-05 03:10:19 +00:00
|
|
|
field :create_note_email, GraphQL::STRING_TYPE, null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'User specific email address for the issue.'
|
2021-01-05 03:10:19 +00:00
|
|
|
|
2020-09-25 09:09:40 +00:00
|
|
|
def author
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.author_id).find
|
|
|
|
end
|
|
|
|
|
2020-10-28 09:08:37 +00:00
|
|
|
def updated_by
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.updated_by_id).find
|
|
|
|
end
|
|
|
|
|
2020-09-25 09:09:40 +00:00
|
|
|
def milestone
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(Milestone, object.milestone_id).find
|
|
|
|
end
|
|
|
|
|
2020-11-11 12:09:06 +00:00
|
|
|
def moved_to
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(Issue, object.moved_to_id).find
|
|
|
|
end
|
|
|
|
|
2020-09-25 09:09:40 +00:00
|
|
|
def discussion_locked
|
|
|
|
!!object.discussion_locked
|
|
|
|
end
|
2021-01-05 03:10:19 +00:00
|
|
|
|
|
|
|
def create_note_email
|
|
|
|
object.creatable_note_email_address(context[:current_user])
|
|
|
|
end
|
2018-11-27 15:10:40 +00:00
|
|
|
end
|
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
|
|
|
Types::IssueType.prepend_if_ee('::EE::Types::IssueType')
|