Commit ff8f5459 authored by Stan Hu's avatar Stan Hu

Merge branch 'simplify-import-start-mutation' into 'master'

Simplification of graphql mutations

See merge request gitlab-org/gitlab!34077
parents 13979ec3 f566f1be
......@@ -27,7 +27,7 @@ module Mutations
def prepare_response(result)
{
alert: result.payload[:alert],
errors: result.error? ? [result.message] : []
errors: result.errors
}
end
end
......
......@@ -48,7 +48,7 @@ module Mutations
{
container_expiration_policy: result.payload[:container_expiration_policy],
errors: result.error? ? [result.message] : []
errors: result.errors
}
end
......
......@@ -23,29 +23,21 @@ module Mutations
description: 'Project name of the importer Jira project'
def resolve(project_path:, jira_project_key:)
project = find_project!(project_path: project_path)
raise_resource_not_available_error! unless project
project = authorized_find!(full_path: project_path)
service_response = ::JiraImport::StartImportService
.new(context[:current_user], project, jira_project_key)
.execute
jira_import = service_response.success? ? service_response.payload[:import_data] : nil
errors = service_response.error? ? [service_response.message] : []
{
jira_import: jira_import,
errors: errors
errors: service_response.errors
}
end
private
def find_project!(project_path:)
return unless project_path.present?
authorized_find!(full_path: project_path)
end
def find_object(full_path:)
resolve_project(full_path: full_path)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment