debian-mirror-gitlab/app/graphql/resolvers/alert_management/alert_resolver.rb

53 lines
1.7 KiB
Ruby
Raw Normal View History

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