Class: Mutations::Metrics::Dashboard::Annotations::Create

Inherits:
BaseMutation
  • Object
show all
Defined in:
app/graphql/mutations/metrics/dashboard/annotations/create.rb

Defined Under Namespace

Classes: AnnotationSource

Constant Summary collapse

ANNOTATION_SOURCE_ARGUMENT_ERROR =
'Either a cluster or environment global id is required'
INVALID_ANNOTATION_SOURCE_ERROR =
'Invalid cluster or environment id'

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods inherited from BaseMutation

#api_user?, authorization, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #raise_resource_not_available_error!

Methods included from Gitlab::Graphql::GlobalIDCompatibility

#coerce_global_id_arguments!

Instance Method Details

#resolve(args) ⇒ Object


64
65
66
67
68
69
70
71
72
73
# File 'app/graphql/mutations/metrics/dashboard/annotations/create.rb', line 64

def resolve(args)
  annotation_response = ::Metrics::Dashboard::Annotations::CreateService.new(context[:current_user], annotation_create_params(args)).execute

  annotation = annotation_response[:annotation]

  {
    annotation: annotation.valid? ? annotation : nil,
    errors: errors_on_object(annotation)
  }
end