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
|
|
|
|
2021-07-05 15:07:38 +00:00
|
|
|
implements(Types::Notes::NoteableInterface)
|
2020-09-09 21:08:33 +00:00
|
|
|
implements(Types::CurrentUserTodos)
|
2022-03-02 00:13:45 +00:00
|
|
|
implements(Types::TodoableInterface)
|
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
|
|
|
|
|
2022-02-28 18:14:03 +00:00
|
|
|
field :description, GraphQL::Types::String, null: true,
|
|
|
|
description: 'Description of the issue.'
|
2021-07-22 09:08:22 +00:00
|
|
|
field :id, GraphQL::Types::ID, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: "ID of the issue."
|
2021-07-22 09:08:22 +00:00
|
|
|
field :iid, GraphQL::Types::ID, 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 :state, IssueStateEnum, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'State of the issue.'
|
2022-02-28 18:14:03 +00:00
|
|
|
field :title, GraphQL::Types::String, null: false,
|
|
|
|
description: 'Title of the issue.'
|
2019-10-31 12:06:26 +00:00
|
|
|
|
2021-07-22 09:08:22 +00:00
|
|
|
field :reference, GraphQL::Types::String, 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
|
2021-07-22 09:08:22 +00:00
|
|
|
argument :full, GraphQL::Types::Boolean, 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
|
|
|
|
2021-07-22 09:08:22 +00:00
|
|
|
field :confidential, GraphQL::Types::Boolean, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Indicates the issue is confidential.'
|
2022-02-28 18:14:03 +00:00
|
|
|
field :discussion_locked, GraphQL::Types::Boolean, null: false,
|
|
|
|
description: 'Indicates discussion is locked on the issue.'
|
|
|
|
field :due_date, Types::TimeType, null: true,
|
|
|
|
description: 'Due date of the issue.'
|
2021-09-07 15:11:06 +00:00
|
|
|
field :hidden, GraphQL::Types::Boolean, null: true, resolver_method: :hidden?,
|
|
|
|
description: 'Indicates the issue is hidden because the author has been banned. ' \
|
|
|
|
'Will always return `null` if `ban_user_feature_flag` feature flag is disabled.'
|
2018-11-27 15:10:40 +00:00
|
|
|
|
2021-07-22 09:08:22 +00:00
|
|
|
field :downvotes, GraphQL::Types::Int, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Number of downvotes the issue has received.'
|
2021-07-29 15:09:48 +00:00
|
|
|
field :merge_requests_count, GraphQL::Types::Int, null: false,
|
|
|
|
description: 'Number of merge requests that close the issue on merge.',
|
|
|
|
resolver: Resolvers::MergeRequestsCountResolver
|
2022-02-28 18:14:03 +00:00
|
|
|
field :relative_position, GraphQL::Types::Int, null: true,
|
|
|
|
description: 'Relative position of the issue (used for positioning in epic tree and issue boards).'
|
|
|
|
field :upvotes, GraphQL::Types::Int, null: false,
|
|
|
|
description: 'Number of upvotes the issue has received.'
|
2021-07-22 09:08:22 +00:00
|
|
|
field :user_discussions_count, GraphQL::Types::Int, 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
|
2022-02-28 18:14:03 +00:00
|
|
|
field :user_notes_count, GraphQL::Types::Int, null: false,
|
|
|
|
description: 'Number of user notes of the issue.',
|
|
|
|
resolver: Resolvers::UserNotesCountResolver
|
2021-07-22 09:08:22 +00:00
|
|
|
field :web_path, GraphQL::Types::String, null: false, method: :issue_path,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Web path of the issue.'
|
2021-07-22 09:08:22 +00:00
|
|
|
field :web_url, GraphQL::Types::String, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Web URL of the issue.'
|
2019-10-31 12:06:26 +00:00
|
|
|
|
2021-07-22 09:08:22 +00:00
|
|
|
field :emails_disabled, GraphQL::Types::Boolean, null: false,
|
2020-11-09 03:09:03 +00:00
|
|
|
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.'
|
2022-02-28 18:14:03 +00:00
|
|
|
field :human_time_estimate, GraphQL::Types::String, null: true,
|
|
|
|
description: 'Human-readable time estimate of the issue.'
|
|
|
|
field :human_total_time_spent, GraphQL::Types::String, null: true,
|
|
|
|
description: 'Human-readable total time reported as spent on the issue.'
|
|
|
|
field :participants, Types::UserType.connection_type, null: true, complexity: 5,
|
|
|
|
description: 'List of participants in the issue.',
|
|
|
|
resolver: Resolvers::Users::ParticipantsResolver
|
2021-07-22 09:08:22 +00:00
|
|
|
field :subscribed, GraphQL::Types::Boolean, 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.'
|
2021-07-22 09:08:22 +00:00
|
|
|
field :time_estimate, GraphQL::Types::Int, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Time estimate of the issue.'
|
2021-07-22 09:08:22 +00:00
|
|
|
field :total_time_spent, GraphQL::Types::Int, null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: '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
|
|
|
|
2021-07-22 09:08:22 +00:00
|
|
|
field :moved, GraphQL::Types::Boolean, 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
|
|
|
|
2022-06-02 18:09:18 +00:00
|
|
|
field :closed_as_duplicate_of, Types::IssueType, null: true,
|
|
|
|
description: 'Issue this issue was closed as a duplicate of.'
|
|
|
|
|
2021-07-22 09:08:22 +00:00
|
|
|
field :create_note_email, GraphQL::Types::String, 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
|
|
|
|
2021-04-12 12:09:15 +00:00
|
|
|
field :timelogs, Types::TimelogType.connection_type, null: false,
|
|
|
|
description: 'Timelogs on the issue.'
|
|
|
|
|
2021-07-22 09:08:22 +00:00
|
|
|
field :project_id, GraphQL::Types::Int, null: false, method: :project_id,
|
2021-06-29 12:08:48 +00:00
|
|
|
description: 'ID of the issue project.'
|
|
|
|
|
2021-10-12 15:12:08 +00:00
|
|
|
field :customer_relations_contacts, Types::CustomerRelations::ContactType.connection_type, null: true,
|
|
|
|
description: 'Customer relations contacts of the issue.'
|
|
|
|
|
2022-01-14 12:18:55 +00:00
|
|
|
field :escalation_status, Types::IncidentManagement::EscalationStatusEnum, null: true,
|
|
|
|
description: 'Escalation status of the issue.'
|
|
|
|
|
2022-01-24 12:10:54 +00:00
|
|
|
markdown_field :title_html, null: true
|
|
|
|
markdown_field :description_html, null: true
|
|
|
|
|
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
|
|
|
|
|
2022-06-02 18:09:18 +00:00
|
|
|
def closed_as_duplicate_of
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(Issue, object.duplicated_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
|
2021-09-07 15:11:06 +00:00
|
|
|
|
|
|
|
def hidden?
|
2022-05-06 15:09:03 +00:00
|
|
|
object.hidden? if Feature.enabled?(:ban_user_feature_flag)
|
2021-09-07 15:11:06 +00:00
|
|
|
end
|
2022-01-14 12:18:55 +00:00
|
|
|
|
|
|
|
def escalation_status
|
2022-01-26 09:14:20 +00:00
|
|
|
object.supports_escalation? ? object.escalation_status&.status_name : nil
|
2022-01-14 12:18:55 +00:00
|
|
|
end
|
2018-11-27 15:10:40 +00:00
|
|
|
end
|
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
2021-05-11 21:10:21 +00:00
|
|
|
Types::IssueType.prepend_mod_with('Types::IssueType')
|