Class: Mutations::Ml::ModelVersions::Edit

Inherits:
BaseMutation
  • Object
show all
Includes:
FindsProject
Defined in:
app/graphql/mutations/ml/model_versions/edit.rb

Constant Summary

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, authorization_scopes, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #ready?, #unauthorized_object

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

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

Instance Method Details

#resolve(**args) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/graphql/mutations/ml/model_versions/edit.rb', line 33

def resolve(**args)
  project = authorized_find!(args[:project_path])
  model = ::Ml::Model.by_project_id_and_id(project.id, args[:model_id].model_id)

  return { errors: ['Model not found'] } unless model

  service_response = ::Ml::ModelVersions::UpdateModelVersionService.new(project, model.name, args[:version],
    args[:description]).execute

  if service_response.success?
    {
      model_version: service_response.payload,
      errors: []
    }
  else
    {
      model_version: nil,
      errors: service_response.errors
    }
  end
end