diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /app/graphql/mutations/issues/update.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'app/graphql/mutations/issues/update.rb')
-rw-r--r-- | app/graphql/mutations/issues/update.rb | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/app/graphql/mutations/issues/update.rb b/app/graphql/mutations/issues/update.rb index 1ceed868a6c..6cab1214d24 100644 --- a/app/graphql/mutations/issues/update.rb +++ b/app/graphql/mutations/issues/update.rb @@ -7,21 +7,25 @@ module Mutations include CommonMutationArguments - argument :title, GraphQL::STRING_TYPE, + argument :title, GraphQL::Types::String, required: false, description: copy_field_description(Types::IssueType, :title) - argument :milestone_id, GraphQL::ID_TYPE, # rubocop: disable Graphql/IDType + argument :milestone_id, GraphQL::Types::ID, # rubocop: disable Graphql/IDType required: false, - description: 'The ID of the milestone to assign to the issue. On update milestone will be removed if set to null.' + description: 'ID of the milestone to assign to the issue. On update milestone will be removed if set to null.' - argument :add_label_ids, [GraphQL::ID_TYPE], + argument :add_label_ids, [GraphQL::Types::ID], required: false, - description: 'The IDs of labels to be added to the issue.' + description: 'IDs of labels to be added to the issue.' - argument :remove_label_ids, [GraphQL::ID_TYPE], + argument :remove_label_ids, [GraphQL::Types::ID], required: false, - description: 'The IDs of labels to be removed from the issue.' + description: 'IDs of labels to be removed from the issue.' + + argument :label_ids, [GraphQL::Types::ID], + required: false, + description: 'IDs of labels to be set. Replaces existing issue labels.' argument :state_event, Types::IssueStateEventEnum, description: 'Close or reopen an issue.', @@ -31,6 +35,8 @@ module Mutations issue = authorized_find!(project_path: project_path, iid: iid) project = issue.project + args = parse_arguments(args) + spam_params = ::Spam::SpamParams.new_from_request(request: context[:request]) ::Issues::UpdateService.new(project: project, current_user: current_user, params: args, spam_params: spam_params).execute(issue) @@ -39,6 +45,32 @@ module Mutations errors: errors_on_object(issue) } end + + def ready?(label_ids: [], add_label_ids: [], remove_label_ids: [], **args) + if label_ids.any? && (add_label_ids.any? || remove_label_ids.any?) + raise Gitlab::Graphql::Errors::ArgumentError, 'labelIds is mutually exclusive with any of addLabelIds or removeLabelIds' + end + + super + end + + private + + def parse_arguments(args) + args[:add_label_ids] = parse_label_ids(args[:add_label_ids]) + args[:remove_label_ids] = parse_label_ids(args[:remove_label_ids]) + args[:label_ids] = parse_label_ids(args[:label_ids]) + + args + end + + def parse_label_ids(ids) + ids&.map do |gid| + GitlabSchema.parse_gid(gid, expected_type: ::Label).model_id + rescue Gitlab::Graphql::Errors::ArgumentError + gid + end + end end end end |