Commit adb5d6ac authored by charlie ablett's avatar charlie ablett

Merge branch '217909-move-alert-management-graphql' into 'master'

Move AlertManagementAlertResolver into module

Closes #217909

See merge request gitlab-org/gitlab!33916
parents 384849e5 ee492f62
......@@ -32,7 +32,7 @@ module Mutations
return unless project
resolver = Resolvers::AlertManagementAlertResolver.single.new(object: project, context: context, field: nil)
resolver = Resolvers::AlertManagement::AlertResolver.single.new(object: project, context: context, field: nil)
resolver.resolve(iid: iid)
end
end
......
# frozen_string_literal: true
module Resolvers
module AlertManagement
class AlertResolver < BaseResolver
argument :iid, GraphQL::STRING_TYPE,
required: false,
description: 'IID of the alert. For example, "1"'
argument :statuses, [Types::AlertManagement::StatusEnum],
as: :status,
required: false,
description: 'Alerts with the specified statues. For example, [TRIGGERED]'
argument :sort, Types::AlertManagement::AlertSortEnum,
description: 'Sort alerts by this criteria',
required: false
argument :search, GraphQL::STRING_TYPE,
description: 'Search criteria for filtering alerts. This will search on title, description, service, monitoring_tool.',
required: false
type Types::AlertManagement::AlertType, null: true
def resolve(**args)
parent = object.respond_to?(:sync) ? object.sync : object
return ::AlertManagement::Alert.none if parent.nil?
::AlertManagement::AlertsFinder.new(context[:current_user], parent, args).execute
end
end
end
end
# frozen_string_literal: true
module Resolvers
class AlertManagementAlertResolver < BaseResolver
argument :iid, GraphQL::STRING_TYPE,
required: false,
description: 'IID of the alert. For example, "1"'
argument :statuses, [Types::AlertManagement::StatusEnum],
as: :status,
required: false,
description: 'Alerts with the specified statues. For example, [TRIGGERED]'
argument :sort, Types::AlertManagement::AlertSortEnum,
description: 'Sort alerts by this criteria',
required: false
argument :search, GraphQL::STRING_TYPE,
description: 'Search criteria for filtering alerts. This will search on title, description, service, monitoring_tool.',
required: false
type Types::AlertManagement::AlertType, null: true
def resolve(**args)
parent = object.respond_to?(:sync) ? object.sync : object
return ::AlertManagement::Alert.none if parent.nil?
::AlertManagement::AlertsFinder.new(context[:current_user], parent, args).execute
end
end
end
......@@ -216,13 +216,13 @@ module Types
Types::AlertManagement::AlertType.connection_type,
null: true,
description: 'Alert Management alerts of the project',
resolver: Resolvers::AlertManagementAlertResolver
resolver: Resolvers::AlertManagement::AlertResolver
field :alert_management_alert,
Types::AlertManagement::AlertType,
null: true,
description: 'A single Alert Management alert of the project',
resolver: Resolvers::AlertManagementAlertResolver.single
resolver: Resolvers::AlertManagement::AlertResolver.single
field :alert_management_alert_status_counts,
Types::AlertManagement::AlertStatusCountsType,
......
......@@ -33,7 +33,7 @@ describe Mutations::AlertManagement::UpdateAlertStatus do
context 'error occurs when updating' do
it 'returns the alert with errors' do
# Stub an error on the alert
allow_next_instance_of(Resolvers::AlertManagementAlertResolver) do |resolver|
allow_next_instance_of(Resolvers::AlertManagement::AlertResolver) do |resolver|
allow(resolver).to receive(:resolve).and_return(alert)
end
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe Resolvers::AlertManagementAlertResolver do
describe Resolvers::AlertManagement::AlertResolver do
include GraphqlHelpers
let_it_be(:current_user) { create(:user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment