summaryrefslogtreecommitdiff
path: root/app/graphql/types/issue_status_counts_type.rb
blob: 77429f9ea1216b2758dcd3e54fe4185c2f46c93b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

module Types
  class IssueStatusCountsType < BaseObject
    graphql_name 'IssueStatusCountsType'
    description 'Represents total number of issues for the represented statuses'

    authorize :read_issue

    def self.available_issue_states
      @available_issue_states ||= Issue.available_states.keys.push('all')
    end

    ::Gitlab::IssuablesCountForState::STATES.each do |state|
      next unless available_issue_states.include?(state.downcase)

      field state,
            GraphQL::INT_TYPE,
            null: true,
            description: "Number of issues with status #{state.upcase} for the project"
    end
  end
end