summaryrefslogtreecommitdiff
path: root/app/graphql/types/metrics
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/types/metrics')
-rw-r--r--app/graphql/types/metrics/dashboard_type.rb5
-rw-r--r--app/graphql/types/metrics/dashboards/annotation_type.rb31
2 files changed, 36 insertions, 0 deletions
diff --git a/app/graphql/types/metrics/dashboard_type.rb b/app/graphql/types/metrics/dashboard_type.rb
index 11e834013ca..e7d09866bb5 100644
--- a/app/graphql/types/metrics/dashboard_type.rb
+++ b/app/graphql/types/metrics/dashboard_type.rb
@@ -9,6 +9,11 @@ module Types
field :path, GraphQL::STRING_TYPE, null: true,
description: 'Path to a file with the dashboard definition'
+
+ field :annotations, Types::Metrics::Dashboards::AnnotationType.connection_type, null: true,
+ description: 'Annotations added to the dashboard. Will always return `null` ' \
+ 'if `metrics_dashboard_annotations` feature flag is disabled',
+ resolver: Resolvers::Metrics::Dashboards::AnnotationResolver
end
# rubocop: enable Graphql/AuthorizeTypes
end
diff --git a/app/graphql/types/metrics/dashboards/annotation_type.rb b/app/graphql/types/metrics/dashboards/annotation_type.rb
new file mode 100644
index 00000000000..055d2544eff
--- /dev/null
+++ b/app/graphql/types/metrics/dashboards/annotation_type.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module Types
+ module Metrics
+ module Dashboards
+ class AnnotationType < ::Types::BaseObject
+ authorize :read_metrics_dashboard_annotation
+ graphql_name 'MetricsDashboardAnnotation'
+
+ field :description, GraphQL::STRING_TYPE, null: true,
+ description: 'Description of the annotation'
+
+ field :id, GraphQL::ID_TYPE, null: false,
+ description: 'ID of the annotation'
+
+ field :panel_id, GraphQL::STRING_TYPE, null: true,
+ description: 'ID of a dashboard panel to which the annotation should be scoped'
+
+ field :starting_at, GraphQL::STRING_TYPE, null: true,
+ description: 'Timestamp marking start of annotated time span'
+
+ field :ending_at, GraphQL::STRING_TYPE, null: true,
+ description: 'Timestamp marking end of annotated time span'
+
+ def panel_id
+ object.panel_xid
+ end
+ end
+ end
+ end
+end