summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/alert_management/http_integrations_resolver.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/resolvers/alert_management/http_integrations_resolver.rb')
-rw-r--r--app/graphql/resolvers/alert_management/http_integrations_resolver.rb30
1 files changed, 25 insertions, 5 deletions
diff --git a/app/graphql/resolvers/alert_management/http_integrations_resolver.rb b/app/graphql/resolvers/alert_management/http_integrations_resolver.rb
index 94a72bca7c7..abc54614a59 100644
--- a/app/graphql/resolvers/alert_management/http_integrations_resolver.rb
+++ b/app/graphql/resolvers/alert_management/http_integrations_resolver.rb
@@ -3,19 +3,39 @@
module Resolvers
module AlertManagement
class HttpIntegrationsResolver < BaseResolver
- alias_method :project, :synchronized_object
+ 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(**args)
- http_integrations
+ 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 http_integrations
- return [] unless Ability.allowed?(current_user, :admin_operations, project)
+ 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