Commit 2149f24c authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch '352029-expose-committers-on-mergerequest-graphql-type' into 'master'

Expose committers on mergeRequest GraphQL type

See merge request gitlab-org/gitlab!79965
parents 617203d8 627a989a
......@@ -51,7 +51,8 @@ module ResolvesMergeRequests
milestone: [:milestone],
security_auto_fix: [:author],
head_pipeline: [:merge_request_diff, { head_pipeline: [:merge_request] }],
timelogs: [:timelogs]
timelogs: [:timelogs],
committers: [merge_request_diff: [:merge_request_diff_commits]]
}
end
end
......@@ -186,6 +186,8 @@ module Types
description: 'Array of available auto merge strategies.'
field :commits, Types::CommitType.connection_type, null: true,
calls_gitaly: true, description: 'Merge request commits.'
field :committers, Types::UserType.connection_type, null: true, complexity: 5,
calls_gitaly: true, description: 'Users who have added commits to the merge request.'
field :commits_without_merge_commits, Types::CommitType.connection_type, null: true,
calls_gitaly: true, description: 'Merge request commits excluding merge commits.'
field :has_ci, GraphQL::Types::Boolean, null: false, method: :has_ci?,
......@@ -280,10 +282,6 @@ module Types
object.author == User.security_bot
end
def reviewers
object.reviewers
end
def merge_user
object.metrics&.merged_by || object.merge_user
end
......
......@@ -12310,6 +12310,7 @@ Maven metadata.
| <a id="mergerequestcommitcount"></a>`commitCount` | [`Int`](#int) | Number of commits in the merge request. |
| <a id="mergerequestcommits"></a>`commits` | [`CommitConnection`](#commitconnection) | Merge request commits. (see [Connections](#connections)) |
| <a id="mergerequestcommitswithoutmergecommits"></a>`commitsWithoutMergeCommits` | [`CommitConnection`](#commitconnection) | Merge request commits excluding merge commits. (see [Connections](#connections)) |
| <a id="mergerequestcommitters"></a>`committers` | [`UserCoreConnection`](#usercoreconnection) | Users who have added commits to the merge request. (see [Connections](#connections)) |
| <a id="mergerequestconflicts"></a>`conflicts` | [`Boolean!`](#boolean) | Indicates if the merge request has conflicts. |
| <a id="mergerequestcreatedat"></a>`createdAt` | [`Time!`](#time) | Timestamp of when the merge request was created. |
| <a id="mergerequestdefaultmergecommitmessage"></a>`defaultMergeCommitMessage` | [`String`](#string) | Default merge commit message of the merge request. |
......@@ -35,7 +35,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do
total_time_spent human_time_estimate human_total_time_spent reference author merged_at
commit_count current_user_todos conflicts auto_merge_enabled approved_by source_branch_protected
default_merge_commit_message_with_description squash_on_merge available_auto_merge_strategies
has_ci mergeable commits commits_without_merge_commits squash security_auto_fix default_squash_commit_message
has_ci mergeable commits committers commits_without_merge_commits squash security_auto_fix default_squash_commit_message
auto_merge_strategy merge_user
]
......
......@@ -76,6 +76,24 @@ RSpec.describe 'getting merge request information nested in a project' do
end
end
context 'when the merge_request has committers' do
let(:mr_fields) do
<<~SELECT
committers { nodes { id username } }
SELECT
end
it 'includes committers' do
expected = merge_request.committers.map do |r|
a_hash_including('id' => global_id_of(r), 'username' => r.username)
end
post_graphql(query, current_user: current_user)
expect(graphql_data_at(:project, :merge_request, :committers, :nodes)).to match_array(expected)
end
end
describe 'diffStats' do
let(:mr_fields) do
<<~FIELDS
......
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