summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/merge_requests/set_assignees.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations/merge_requests/set_assignees.rb')
-rw-r--r--app/graphql/mutations/merge_requests/set_assignees.rb39
1 files changed, 3 insertions, 36 deletions
diff --git a/app/graphql/mutations/merge_requests/set_assignees.rb b/app/graphql/mutations/merge_requests/set_assignees.rb
index de244b62d0f..548c6b55a85 100644
--- a/app/graphql/mutations/merge_requests/set_assignees.rb
+++ b/app/graphql/mutations/merge_requests/set_assignees.rb
@@ -5,43 +5,10 @@ module Mutations
class SetAssignees < Base
graphql_name 'MergeRequestSetAssignees'
- argument :assignee_usernames,
- [GraphQL::STRING_TYPE],
- required: true,
- description: <<~DESC
- The usernames to assign to the merge request. Replaces existing assignees by default.
- DESC
+ include Assignable
- argument :operation_mode,
- Types::MutationOperationModeEnum,
- required: false,
- description: <<~DESC
- The operation to perform. Defaults to REPLACE.
- DESC
-
- def resolve(project_path:, iid:, assignee_usernames:, operation_mode: Types::MutationOperationModeEnum.enum[:replace])
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/issues/36098')
-
- merge_request = authorized_find!(project_path: project_path, iid: iid)
- project = merge_request.project
-
- assignee_ids = []
- assignee_ids += merge_request.assignees.map(&:id) if Types::MutationOperationModeEnum.enum.values_at(:remove, :append).include?(operation_mode)
- user_ids = UsersFinder.new(current_user, username: assignee_usernames).execute.map(&:id)
-
- if operation_mode == Types::MutationOperationModeEnum.enum[:remove]
- assignee_ids -= user_ids
- else
- assignee_ids |= user_ids
- end
-
- ::MergeRequests::UpdateService.new(project, current_user, assignee_ids: assignee_ids)
- .execute(merge_request)
-
- {
- merge_request: merge_request,
- errors: errors_on_object(merge_request)
- }
+ def update_service_class
+ ::MergeRequests::UpdateService
end
end
end