2020-06-08 20:08:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
module AlertManagement
|
|
|
|
class AlertResolver < BaseResolver
|
2020-06-10 20:08:35 -04:00
|
|
|
include LooksAhead
|
|
|
|
|
2020-06-08 20:08:47 -04:00
|
|
|
argument :iid, GraphQL::STRING_TYPE,
|
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'IID of the alert. For example, "1".'
|
2020-06-08 20:08:47 -04:00
|
|
|
|
|
|
|
argument :statuses, [Types::AlertManagement::StatusEnum],
|
|
|
|
as: :status,
|
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Alerts with the specified statues. For example, [TRIGGERED].'
|
2020-06-08 20:08:47 -04:00
|
|
|
|
|
|
|
argument :sort, Types::AlertManagement::AlertSortEnum,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Sort alerts by this criteria.',
|
2020-06-08 20:08:47 -04:00
|
|
|
required: false
|
|
|
|
|
2020-12-10 13:10:16 -05:00
|
|
|
argument :domain, Types::AlertManagement::DomainFilterEnum,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Filter query for given domain.',
|
2020-12-10 13:10:16 -05:00
|
|
|
required: true,
|
|
|
|
default_value: 'operations'
|
|
|
|
|
2020-06-08 20:08:47 -04:00
|
|
|
argument :search, GraphQL::STRING_TYPE,
|
2020-10-23 11:08:42 -04:00
|
|
|
description: 'Search query for title, description, service, or monitoring_tool.',
|
2020-06-08 20:08:47 -04:00
|
|
|
required: false
|
|
|
|
|
2020-10-12 14:08:31 -04:00
|
|
|
argument :assignee_username, GraphQL::STRING_TYPE,
|
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Username of a user assigned to the issue.'
|
2020-10-12 14:08:31 -04:00
|
|
|
|
2020-06-08 20:08:47 -04:00
|
|
|
type Types::AlertManagement::AlertType, null: true
|
|
|
|
|
2020-06-10 20:08:35 -04:00
|
|
|
def resolve_with_lookahead(**args)
|
2020-06-08 20:08:47 -04:00
|
|
|
parent = object.respond_to?(:sync) ? object.sync : object
|
|
|
|
return ::AlertManagement::Alert.none if parent.nil?
|
|
|
|
|
2020-06-10 20:08:35 -04:00
|
|
|
apply_lookahead(::AlertManagement::AlertsFinder.new(context[:current_user], parent, args).execute)
|
|
|
|
end
|
|
|
|
|
|
|
|
def preloads
|
|
|
|
{
|
2020-06-15 17:08:35 -04:00
|
|
|
assignees: [:assignees],
|
2021-03-04 10:11:19 -05:00
|
|
|
notes: [:ordered_notes, { ordered_notes: [:system_note_metadata, :project, :noteable] }],
|
|
|
|
issue: [:issue]
|
2020-06-10 20:08:35 -04:00
|
|
|
}
|
2020-06-08 20:08:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|