Welcome to mirror list, hosted at ThFree Co, Russian Federation.

contact_state_counts_type.rb « customer_relations « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 96230f8a95228cababd661e830d53cbab418b203 (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
  module CustomerRelations
    class ContactStateCountsType < Types::BaseObject
      graphql_name 'ContactStateCounts'
      description 'Represents the total number of contacts for the represented states.'

      authorize :read_crm_contact

      def self.available_contact_states
        @available_contact_states ||= ::CustomerRelations::Contact.states.keys.push('all')
      end

      available_contact_states.each do |state|
        field state,
              GraphQL::Types::Int,
              null: true,
              description: "Number of contacts with state `#{state.upcase}`"
      end
    end
  end
end