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

service_type.rb « projects « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 88b7b95aa57b9b62ac57c31eef18c0665a4da785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true

module Types
  module Projects
    module ServiceType
      include Types::BaseInterface
      graphql_name 'Service'

      # TODO: Add all the fields that we want to expose for the project services integrations
      # https://gitlab.com/gitlab-org/gitlab/-/issues/213088
      field :type, GraphQL::Types::String, null: true,
            description: 'Class name of the service.'
      field :service_type, ::Types::Projects::ServiceTypeEnum, null: true,
            description: 'Type of the service.'
      field :active, GraphQL::Types::Boolean, null: true,
            description: 'Indicates if the service is active.'

      def type
        enum = ::Types::Projects::ServiceTypeEnum.coerce_result(service_type, context)
        enum.downcase.camelize
      end

      def service_type
        object.type
      end

      definition_methods do
        def resolve_type(object, context)
          if object.is_a?(::Integrations::Jira)
            Types::Projects::Services::JiraServiceType
          else
            Types::Projects::Services::BaseServiceType
          end
        end
      end

      orphan_types Types::Projects::Services::BaseServiceType, Types::Projects::Services::JiraServiceType
    end
  end
end