diff options
Diffstat (limited to 'app/graphql/mutations/metrics')
-rw-r--r-- | app/graphql/mutations/metrics/dashboard/annotations/base.rb | 18 | ||||
-rw-r--r-- | app/graphql/mutations/metrics/dashboard/annotations/delete.rb | 32 |
2 files changed, 50 insertions, 0 deletions
diff --git a/app/graphql/mutations/metrics/dashboard/annotations/base.rb b/app/graphql/mutations/metrics/dashboard/annotations/base.rb new file mode 100644 index 00000000000..3126267da64 --- /dev/null +++ b/app/graphql/mutations/metrics/dashboard/annotations/base.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Mutations + module Metrics + module Dashboard + module Annotations + class Base < BaseMutation + private + + # This method is defined here in order to be used by `authorized_find!` in the subclasses. + def find_object(id:) + GitlabSchema.object_from_id(id) + end + end + end + end + end +end diff --git a/app/graphql/mutations/metrics/dashboard/annotations/delete.rb b/app/graphql/mutations/metrics/dashboard/annotations/delete.rb new file mode 100644 index 00000000000..fb828ba0e2f --- /dev/null +++ b/app/graphql/mutations/metrics/dashboard/annotations/delete.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Mutations + module Metrics + module Dashboard + module Annotations + class Delete < Base + graphql_name 'DeleteAnnotation' + + authorize :delete_metrics_dashboard_annotation + + argument :id, + GraphQL::ID_TYPE, + required: true, + description: 'The global id of the annotation to delete' + + def resolve(id:) + annotation = authorized_find!(id: id) + + result = ::Metrics::Dashboard::Annotations::DeleteService.new(context[:current_user], annotation).execute + + errors = Array.wrap(result[:message]) + + { + errors: errors + } + end + end + end + end + end +end |