debian-mirror-gitlab/app/graphql/mutations/jira_import/start.rb

48 lines
1.6 KiB
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
module Mutations
module JiraImport
class Start < BaseMutation
graphql_name 'JiraImportStart'
2022-04-04 11:22:00 +05:30
include FindsProject
2021-03-11 19:13:27 +05:30
authorize :admin_project
2020-04-22 19:07:51 +05:30
field :jira_import,
Types::JiraImportType,
null: true,
2021-10-27 15:23:28 +05:30
description: 'Jira import data after mutation.'
2020-04-22 19:07:51 +05:30
2021-10-27 15:23:28 +05:30
argument :jira_project_key, GraphQL::Types::String,
2020-04-22 19:07:51 +05:30
required: true,
2021-03-08 18:12:59 +05:30
description: 'Project key of the importer Jira project.'
2021-10-27 15:23:28 +05:30
argument :jira_project_name, GraphQL::Types::String,
2020-04-22 19:07:51 +05:30
required: false,
2021-03-08 18:12:59 +05:30
description: 'Project name of the importer Jira project.'
2022-01-26 12:08:38 +05:30
argument :project_path, GraphQL::Types::ID,
required: true,
description: 'Project to import the Jira project into.'
2020-07-28 23:09:34 +05:30
argument :users_mapping,
[Types::JiraUsersMappingInputType],
required: false,
2021-10-27 15:23:28 +05:30
description: 'Mapping of Jira to GitLab users.'
2020-04-22 19:07:51 +05:30
2020-07-28 23:09:34 +05:30
def resolve(project_path:, jira_project_key:, users_mapping:)
2021-03-11 19:13:27 +05:30
project = authorized_find!(project_path)
2020-07-28 23:09:34 +05:30
mapping = users_mapping.to_ary.map { |map| map.to_hash }
2020-04-22 19:07:51 +05:30
service_response = ::JiraImport::StartImportService
2020-07-28 23:09:34 +05:30
.new(context[:current_user], project, jira_project_key, mapping)
2020-04-22 19:07:51 +05:30
.execute
jira_import = service_response.success? ? service_response.payload[:import_data] : nil
2020-06-23 00:09:42 +05:30
2020-04-22 19:07:51 +05:30
{
jira_import: jira_import,
2020-06-23 00:09:42 +05:30
errors: service_response.errors
2020-04-22 19:07:51 +05:30
}
end
end
end
end