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