Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dashboard_resolver.rb « metrics « resolvers « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0669fececd5e88029b83479ddc0aaf1483b69a76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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