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

dashboard_type.rb « metrics « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 47502356773c6a27325c36d9bb6c9a3291fba68b (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
# frozen_string_literal: true

module Types
  module Metrics
    # rubocop: disable Graphql/AuthorizeTypes
    # Authorization is performed at environment level
    class DashboardType < ::Types::BaseObject
      graphql_name 'MetricsDashboard'

      field :path, GraphQL::STRING_TYPE, null: true,
            description: 'Path to a file with the dashboard definition'

      field :schema_validation_warnings, [GraphQL::STRING_TYPE], null: true,
            description: 'Dashboard schema validation warnings'

      field :annotations, Types::Metrics::Dashboards::AnnotationType.connection_type, null: true,
            description: 'Annotations added to the dashboard',
            resolver: Resolvers::Metrics::Dashboards::AnnotationResolver

      # In order to maintain backward compatibility we need to return NULL when there are no warnings
      # and dashboard validation returns an empty array when there are no issues.
      def schema_validation_warnings
        warnings = object.schema_validation_warnings
        warnings unless warnings.empty?
      end
    end
    # rubocop: enable Graphql/AuthorizeTypes
  end
end