blob: abc54614a59f99a8e6108a349603aa1735976b36 (
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
41
42
43
|
# frozen_string_literal: true
module Resolvers
module AlertManagement
class HttpIntegrationsResolver < BaseResolver
include ::Gitlab::Graphql::Laziness
alias_method :project, :object
argument :id, Types::GlobalIDType[::AlertManagement::HttpIntegration],
required: false,
description: 'ID of the integration.'
type Types::AlertManagement::HttpIntegrationType.connection_type, null: true
def resolve(id: nil)
return [] unless Ability.allowed?(current_user, :admin_operations, project)
if id
integrations_by(gid: id)
else
http_integrations
end
end
private
def integrations_by(gid:)
id = Types::GlobalIDType[::AlertManagement::HttpIntegration].coerce_isolated_input(gid)
object = GitlabSchema.find_by_gid(id)
defer { object }.then do |integration|
ret = integration if project == integration&.project
Array.wrap(ret)
end
end
def http_integrations
::AlertManagement::HttpIntegrationsFinder.new(project, {}).execute
end
end
end
end
|