2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Types
|
|
|
|
class IssueType < BaseObject
|
2019-05-30 16:15:17 +05:30
|
|
|
graphql_name 'Issue'
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
implements(Types::Notes::NoteableType)
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
authorize :read_issue
|
|
|
|
|
|
|
|
expose_permissions Types::PermissionTypes::Issue
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
present_using IssuePresenter
|
|
|
|
|
|
|
|
field :iid, GraphQL::ID_TYPE, null: false
|
|
|
|
field :title, GraphQL::STRING_TYPE, null: false
|
2019-09-30 21:07:59 +05:30
|
|
|
markdown_field :title_html, null: true
|
2019-02-15 15:39:39 +05:30
|
|
|
field :description, GraphQL::STRING_TYPE, null: true
|
2019-09-30 21:07:59 +05:30
|
|
|
markdown_field :description_html, null: true
|
2019-07-07 11:18:12 +05:30
|
|
|
field :state, IssueStateEnum, null: false
|
2019-02-15 15:39:39 +05:30
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
field :reference, GraphQL::STRING_TYPE, null: false, method: :to_reference do
|
|
|
|
argument :full, GraphQL::BOOLEAN_TYPE, required: false, default_value: false
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
field :author, Types::UserType,
|
|
|
|
null: false,
|
2019-07-07 11:18:12 +05:30
|
|
|
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, obj.author_id).find }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
# Remove complexity when BatchLoader is used
|
|
|
|
field :assignees, Types::UserType.connection_type, null: true, complexity: 5
|
2019-02-15 15:39:39 +05:30
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
# Remove complexity when BatchLoader is used
|
|
|
|
field :labels, Types::LabelType.connection_type, null: true, complexity: 5
|
2019-02-15 15:39:39 +05:30
|
|
|
field :milestone, Types::MilestoneType,
|
|
|
|
null: true,
|
2019-07-07 11:18:12 +05:30
|
|
|
resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Milestone, obj.milestone_id).find }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
field :due_date, Types::TimeType, null: true
|
|
|
|
field :confidential, GraphQL::BOOLEAN_TYPE, null: false
|
|
|
|
field :discussion_locked, GraphQL::BOOLEAN_TYPE,
|
|
|
|
null: false,
|
|
|
|
resolve: -> (obj, _args, _ctx) { !!obj.discussion_locked }
|
|
|
|
|
|
|
|
field :upvotes, GraphQL::INT_TYPE, null: false
|
|
|
|
field :downvotes, GraphQL::INT_TYPE, null: false
|
|
|
|
field :user_notes_count, GraphQL::INT_TYPE, null: false
|
2019-09-04 21:01:54 +05:30
|
|
|
field :web_path, GraphQL::STRING_TYPE, null: false, method: :issue_path
|
2019-02-15 15:39:39 +05:30
|
|
|
field :web_url, GraphQL::STRING_TYPE, null: false
|
2019-09-04 21:01:54 +05:30
|
|
|
field :relative_position, GraphQL::INT_TYPE, null: true
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
field :closed_at, Types::TimeType, null: true
|
|
|
|
|
|
|
|
field :created_at, Types::TimeType, null: false
|
|
|
|
field :updated_at, Types::TimeType, null: false
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
field :task_completion_status, Types::TaskCompletionStatus, null: false
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
end
|