2020-04-08 06:09:54 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
module Projects
|
|
|
|
class ServicesResolver < BaseResolver
|
|
|
|
include Gitlab::Graphql::Authorize::AuthorizeResource
|
|
|
|
|
2020-11-10 00:08:52 +00:00
|
|
|
type Types::Projects::ServiceType.connection_type, null: true
|
2020-12-09 18:09:48 +00:00
|
|
|
authorize :admin_project
|
2021-03-18 06:11:52 +00:00
|
|
|
authorizes_object!
|
2020-11-10 00:08:52 +00:00
|
|
|
|
2020-04-08 06:09:54 +00:00
|
|
|
argument :active,
|
2021-07-22 12:10:04 +00:00
|
|
|
GraphQL::Types::Boolean,
|
2020-04-08 06:09:54 +00:00
|
|
|
required: false,
|
2021-06-09 18:11:25 +00:00
|
|
|
description: 'Indicates if the integration is active.'
|
2020-04-08 06:09:54 +00:00
|
|
|
argument :type,
|
|
|
|
Types::Projects::ServiceTypeEnum,
|
|
|
|
required: false,
|
2021-06-09 18:11:25 +00:00
|
|
|
description: 'Type of integration.'
|
2020-04-08 06:09:54 +00:00
|
|
|
|
|
|
|
alias_method :project, :object
|
|
|
|
|
2021-03-18 06:11:52 +00:00
|
|
|
def resolve(active: nil, type: nil)
|
2021-06-09 18:11:25 +00:00
|
|
|
items = project.integrations
|
|
|
|
items = items.by_active_flag(active) unless active.nil?
|
|
|
|
items = items.by_type(type) unless type.blank?
|
|
|
|
items
|
2020-04-08 06:09:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|