Commit 6849c7da authored by charlie ablett's avatar charlie ablett

Merge branch '225212-add-fields-to-jira-mutation' into 'master'

Add gitlab username and name to the mutation response

See merge request gitlab-org/gitlab!35542
parents a70325b9 1dd467b4
...@@ -13,7 +13,11 @@ module Types ...@@ -13,7 +13,11 @@ module Types
field :jira_email, GraphQL::STRING_TYPE, null: true, field :jira_email, GraphQL::STRING_TYPE, null: true,
description: 'Email of the Jira user, returned only for users with public emails' description: 'Email of the Jira user, returned only for users with public emails'
field :gitlab_id, GraphQL::INT_TYPE, null: true, field :gitlab_id, GraphQL::INT_TYPE, null: true,
description: 'Id of the matched GitLab user' description: 'ID of the matched GitLab user'
field :gitlab_username, GraphQL::STRING_TYPE, null: true,
description: 'Username of the matched GitLab user'
field :gitlab_name, GraphQL::STRING_TYPE, null: true,
description: 'Name of the matched GitLab user'
end end
# rubocop: enable Graphql/AuthorizeTypes # rubocop: enable Graphql/AuthorizeTypes
end end
...@@ -14,9 +14,8 @@ module JiraImport ...@@ -14,9 +14,8 @@ module JiraImport
{ {
jira_account_id: jira_user['accountId'], jira_account_id: jira_user['accountId'],
jira_display_name: jira_user['displayName'], jira_display_name: jira_user['displayName'],
jira_email: jira_user['emailAddress'], jira_email: jira_user['emailAddress']
gitlab_id: match_user(jira_user) }.merge(match_user(jira_user))
}
end end
end end
...@@ -25,7 +24,7 @@ module JiraImport ...@@ -25,7 +24,7 @@ module JiraImport
# TODO: Matching user by email and displayName will be done as the part # TODO: Matching user by email and displayName will be done as the part
# of follow-up issue: https://gitlab.com/gitlab-org/gitlab/-/issues/219023 # of follow-up issue: https://gitlab.com/gitlab-org/gitlab/-/issues/219023
def match_user(jira_user) def match_user(jira_user)
nil { gitlab_id: nil, gitlab_username: nil, gitlab_name: nil }
end end
end end
end end
---
title: Add GitLab username and name to the import users from Jira mutation response
merge_request: 35542
author:
type: changed
...@@ -6656,10 +6656,20 @@ type JiraService implements Service { ...@@ -6656,10 +6656,20 @@ type JiraService implements Service {
type JiraUser { type JiraUser {
""" """
Id of the matched GitLab user ID of the matched GitLab user
""" """
gitlabId: Int gitlabId: Int
"""
Name of the matched GitLab user
"""
gitlabName: String
"""
Username of the matched GitLab user
"""
gitlabUsername: String
""" """
Account id of the Jira user Account id of the Jira user
""" """
......
...@@ -18439,7 +18439,7 @@ ...@@ -18439,7 +18439,7 @@
"fields": [ "fields": [
{ {
"name": "gitlabId", "name": "gitlabId",
"description": "Id of the matched GitLab user", "description": "ID of the matched GitLab user",
"args": [ "args": [
], ],
...@@ -18451,6 +18451,34 @@ ...@@ -18451,6 +18451,34 @@
"isDeprecated": false, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{
"name": "gitlabName",
"description": "Name of the matched GitLab user",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "gitlabUsername",
"description": "Username of the matched GitLab user",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{ {
"name": "jiraAccountId", "name": "jiraAccountId",
"description": "Account id of the Jira user", "description": "Account id of the Jira user",
...@@ -1007,7 +1007,9 @@ Autogenerated return type of JiraImportUsers ...@@ -1007,7 +1007,9 @@ Autogenerated return type of JiraImportUsers
| Name | Type | Description | | Name | Type | Description |
| --- | ---- | ---------- | | --- | ---- | ---------- |
| `gitlabId` | Int | Id of the matched GitLab user | | `gitlabId` | Int | ID of the matched GitLab user |
| `gitlabName` | String | Name of the matched GitLab user |
| `gitlabUsername` | String | Username of the matched GitLab user |
| `jiraAccountId` | String! | Account id of the Jira user | | `jiraAccountId` | String! | Account id of the Jira user |
| `jiraDisplayName` | String! | Display name of the Jira user | | `jiraDisplayName` | String! | Display name of the Jira user |
| `jiraEmail` | String | Email of the Jira user, returned only for users with public emails | | `jiraEmail` | String | Email of the Jira user, returned only for users with public emails |
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['JiraUser'] do
specify { expect(described_class.graphql_name).to eq('JiraUser') }
it 'has the expected fields' do
expect(described_class).to have_graphql_fields(
:jira_account_id, :jira_display_name, :jira_email, :gitlab_id, :gitlab_username, :gitlab_name
)
end
end
...@@ -29,9 +29,9 @@ RSpec.describe JiraImport::UsersMapper do ...@@ -29,9 +29,9 @@ RSpec.describe JiraImport::UsersMapper do
# mapping is tracked in https://gitlab.com/gitlab-org/gitlab/-/issues/219023 # mapping is tracked in https://gitlab.com/gitlab-org/gitlab/-/issues/219023
let(:mapped_users) do let(:mapped_users) do
[ [
{ jira_account_id: 'abcd', jira_display_name: 'user1', jira_email: nil, gitlab_id: nil }, { jira_account_id: 'abcd', jira_display_name: 'user1', jira_email: nil, gitlab_id: nil, gitlab_username: nil, gitlab_name: nil },
{ jira_account_id: 'efg', jira_display_name: nil, jira_email: nil, gitlab_id: nil }, { jira_account_id: 'efg', jira_display_name: nil, jira_email: nil, gitlab_id: nil, gitlab_username: nil, gitlab_name: nil },
{ jira_account_id: 'hij', jira_display_name: 'user3', jira_email: 'user3@example.com', gitlab_id: nil } { jira_account_id: 'hij', jira_display_name: 'user3', jira_email: 'user3@example.com', gitlab_id: nil, gitlab_username: nil, gitlab_name: nil }
] ]
end 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