2020-06-08 15:08:20 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Mutations
|
|
|
|
module JiraImport
|
|
|
|
class ImportUsers < BaseMutation
|
|
|
|
graphql_name 'JiraImportUsers'
|
|
|
|
|
2022-02-15 12:14:49 +00:00
|
|
|
include FindsProject
|
|
|
|
|
2021-01-26 18:09:30 +00:00
|
|
|
authorize :admin_project
|
|
|
|
|
2020-06-08 15:08:20 +00:00
|
|
|
field :jira_users,
|
|
|
|
[Types::JiraUserType],
|
|
|
|
null: true,
|
|
|
|
description: 'Users returned from Jira, matched by email and name if possible.'
|
|
|
|
|
2021-07-22 21:09:40 +00:00
|
|
|
argument :project_path, GraphQL::Types::ID,
|
2020-06-08 15:08:20 +00:00
|
|
|
required: true,
|
2021-08-12 03:10:11 +00:00
|
|
|
description: 'Project to import the Jira users into.'
|
2021-07-22 21:09:40 +00:00
|
|
|
argument :start_at, GraphQL::Types::Int,
|
2020-06-08 15:08:20 +00:00
|
|
|
required: false,
|
2021-08-12 03:10:11 +00:00
|
|
|
description: 'Index of the record the import should started at, default 0 (50 records returned).'
|
2020-06-08 15:08:20 +00:00
|
|
|
|
2020-07-23 21:09:19 +00:00
|
|
|
def resolve(project_path:, start_at: 0)
|
2021-01-26 18:09:30 +00:00
|
|
|
project = authorized_find!(project_path)
|
2020-06-08 15:08:20 +00:00
|
|
|
|
2020-07-23 21:09:19 +00:00
|
|
|
service_response = ::JiraImport::UsersImporter.new(context[:current_user], project, start_at.to_i).execute
|
2020-06-08 15:08:20 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
jira_users: service_response.payload,
|
|
|
|
errors: service_response.errors
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|