Commit 0df61d12 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ajk-mr-set-labels-minor-fix' into 'master'

Avoid parsing global-ids multiple times

See merge request gitlab-org/gitlab!33650
parents eddb2802 747667a3
......@@ -24,8 +24,9 @@ module Mutations
project = merge_request.project
label_ids = label_ids
.map { |gid| GlobalID.parse(gid) }
.select(&method(:label_descendant?))
.map { |gid| GlobalID.parse(gid).model_id } # MergeRequests::UpdateService expects integers
.map(&:model_id) # MergeRequests::UpdateService expects integers
attribute_name = case operation_mode
when Types::MutationOperationModeEnum.enum[:append]
......@@ -46,7 +47,7 @@ module Mutations
end
def label_descendant?(gid)
GlobalID.parse(gid)&.model_class&.ancestors&.include?(Label)
gid&.model_class&.ancestors&.include?(Label)
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