debian-mirror-gitlab/app/graphql/resolvers/metrics/dashboard_resolver.rb
2021-04-29 21:17:54 +05:30

34 lines
844 B
Ruby

# frozen_string_literal: true
module Resolvers
module Metrics
class DashboardResolver < Resolvers::BaseResolver
type Types::Metrics::DashboardType, null: true
calls_gitaly!
argument :path, GraphQL::STRING_TYPE,
required: true,
description: <<~MD
Path to a file which defines a metrics dashboard eg: `"config/prometheus/common_metrics.yml"`.
MD
alias_method :environment, :object
def resolve(path:)
return unless environment
::PerformanceMonitoring::PrometheusDashboard.find_for(path: path, **service_params)
end
private
def service_params
{
project: environment.project,
user: current_user,
options: { environment: environment }
}
end
end
end
end