Commit c0bcfde7 authored by Marc Shaw's avatar Marc Shaw Committed by Luke Duncalfe

Expose UserInteractions for participants of a merge request

MR: gitlab.com/gitlab-org/gitlab/-/merge_requests/82257
Issue: gitlab.com/gitlab-org/gitlab/-/issues/353982

Changelog: added
parent d14b5c3f
......@@ -137,7 +137,7 @@ module Types
null: true,
complexity: 5,
description: 'Assignees of the merge request.'
field :author, Types::UserType, null: true,
field :author, Types::MergeRequests::AuthorType, null: true,
description: 'User who created this merge request.'
field :discussion_locked, GraphQL::Types::Boolean,
description: 'Indicates if comments on the merge request are locked to members only.',
......@@ -150,7 +150,7 @@ module Types
description: 'Labels of the merge request.'
field :milestone, Types::MilestoneType, null: true,
description: 'Milestone of the merge request.'
field :participants, Types::UserType.connection_type, null: true, complexity: 15,
field :participants, Types::MergeRequests::ParticipantType.connection_type, null: true, complexity: 15,
description: 'Participants in the merge request. This includes the author, assignees, reviewers, and users mentioned in notes.',
resolver: Resolvers::Users::ParticipantsResolver
field :reference, GraphQL::Types::String, null: false, method: :to_reference,
......
......@@ -6,7 +6,6 @@ module Types
graphql_name 'MergeRequestAssignee'
description 'A user assigned to a merge request.'
include FindClosest
include ::Types::MergeRequests::InteractsWithMergeRequest
authorize :read_user
......
# frozen_string_literal: true
module Types
module MergeRequests
class AuthorType < ::Types::UserType
graphql_name 'MergeRequestAuthor'
description 'The author of the merge request.'
include ::Types::MergeRequests::InteractsWithMergeRequest
authorize :read_user
end
end
end
# frozen_string_literal: true
module Types
module MergeRequests
class ParticipantType < ::Types::UserType
graphql_name 'MergeRequestParticipant'
description 'A user participating in a merge request.'
include ::Types::MergeRequests::InteractsWithMergeRequest
authorize :read_user
end
end
end
......@@ -6,7 +6,6 @@ module Types
graphql_name 'MergeRequestReviewer'
description 'A user assigned to a merge request as a reviewer.'
include FindClosest
include ::Types::MergeRequests::InteractsWithMergeRequest
authorize :read_user
......
This diff is collapsed.
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['MergeRequestAssignee'] do
it_behaves_like "a user type with merge request interaction type"
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['MergeRequestAuthor'] do
it_behaves_like "a user type with merge request interaction type"
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['MergeRequestParticipant'] do
it_behaves_like "a user type with merge request interaction type"
end
......@@ -3,55 +3,5 @@
require 'spec_helper'
RSpec.describe GitlabSchema.types['MergeRequestReviewer'] do
specify { expect(described_class).to require_graphql_authorizations(:read_user) }
it 'has the expected fields' do
expected_fields = %w[
id
bot
user_permissions
snippets
name
username
email
publicEmail
avatarUrl
webUrl
webPath
todos
state
status
location
authoredMergeRequests
assignedMergeRequests
reviewRequestedMergeRequests
groupMemberships
groupCount
projectMemberships
starredProjects
callouts
merge_request_interaction
namespace
timelogs
groups
gitpodEnabled
preferencesGitpodPath
profileEnableGitpodPath
savedReplies
]
expect(described_class).to have_graphql_fields(*expected_fields)
end
describe '#merge_request_interaction' do
subject { described_class.fields['mergeRequestInteraction'] }
it 'returns the correct type' do
is_expected.to have_graphql_type(Types::UserMergeRequestInteractionType)
end
it 'has the correct arguments' do
is_expected.to have_attributes(arguments: be_empty)
end
end
it_behaves_like "a user type with merge request interaction type"
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.shared_examples "a user type with merge request interaction type" do
specify { expect(described_class).to require_graphql_authorizations(:read_user) }
it 'has the expected fields' do
expected_fields = %w[
id
bot
user_permissions
snippets
name
username
email
publicEmail
avatarUrl
webUrl
webPath
todos
state
status
location
authoredMergeRequests
assignedMergeRequests
reviewRequestedMergeRequests
groupMemberships
groupCount
projectMemberships
starredProjects
callouts
merge_request_interaction
namespace
timelogs
groups
gitpodEnabled
preferencesGitpodPath
profileEnableGitpodPath
savedReplies
]
expect(described_class).to have_graphql_fields(*expected_fields)
end
describe '#merge_request_interaction' do
subject { described_class.fields['mergeRequestInteraction'] }
it 'returns the correct type' do
is_expected.to have_graphql_type(Types::UserMergeRequestInteractionType)
end
it 'has the correct arguments' do
is_expected.to have_attributes(arguments: be_empty)
end
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