Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create.rb « models « ml « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 21570fc34b8f9724b4f6b6bef0bd81ee1dcbd249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

module Mutations
  module Ml
    module Models
      class Create < Base
        graphql_name 'MlModelCreate'

        include FindsProject

        argument :name, GraphQL::Types::String,
          required: true,
          description: 'Name of the model.'

        argument :description, GraphQL::Types::String,
          required: false,
          description: 'Description of the model.'

        def resolve(**args)
          project = authorized_find!(args[:project_path])

          model = ::Ml::CreateModelService.new(project, args[:name], current_user, args[:description]).execute

          {
            model: model.persisted? ? model : nil,
            errors: errors_on_object(model)
          }
        end
      end
    end
  end
end