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

37 lines
1.1 KiB
Ruby
Raw Normal View History

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.'
argument :project_path, GraphQL::ID_TYPE,
required: true,
2021-03-08 18:12:59 +05:30
description: 'The project to import the Jira users into.'
2020-06-23 00:09:42 +05:30
argument :start_at, GraphQL::INT_TYPE,
required: false,
2021-03-08 18:12:59 +05:30
description: 'The 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