debian-mirror-gitlab/app/graphql/types/metrics/dashboard_type.rb

30 lines
1.1 KiB
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# 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,
2021-03-11 19:13:27 +05:30
description: 'Path to a file with the dashboard definition.'
2020-04-22 19:07:51 +05:30
2020-06-23 00:09:42 +05:30
field :schema_validation_warnings, [GraphQL::STRING_TYPE], null: true,
2021-03-11 19:13:27 +05:30
description: 'Dashboard schema validation warnings.'
2020-06-23 00:09:42 +05:30
2020-04-22 19:07:51 +05:30
field :annotations, Types::Metrics::Dashboards::AnnotationType.connection_type, null: true,
2021-03-11 19:13:27 +05:30
description: 'Annotations added to the dashboard.',
2020-04-22 19:07:51 +05:30
resolver: Resolvers::Metrics::Dashboards::AnnotationResolver
2020-11-24 15:15:51 +05:30
# 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
2020-04-22 19:07:51 +05:30
end
# rubocop: enable Graphql/AuthorizeTypes
end
end