diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/graphql/mutations/labels/create.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/graphql/mutations/labels/create.rb')
-rw-r--r-- | app/graphql/mutations/labels/create.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/app/graphql/mutations/labels/create.rb b/app/graphql/mutations/labels/create.rb new file mode 100644 index 00000000000..cb03651618e --- /dev/null +++ b/app/graphql/mutations/labels/create.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +module Mutations + module Labels + class Create < BaseMutation + include Mutations::ResolvesResourceParent + + graphql_name 'LabelCreate' + + field :label, + Types::LabelType, + null: true, + description: 'The label after mutation' + + argument :title, GraphQL::STRING_TYPE, + required: true, + description: 'Title of the label' + + argument :description, GraphQL::STRING_TYPE, + required: false, + description: 'Description of the label' + + argument :color, GraphQL::STRING_TYPE, + required: false, + default_value: Label::DEFAULT_COLOR, + description: "The color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the CSS color names in https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords" + + authorize :admin_label + + def resolve(args) + parent = authorized_resource_parent_find!(args) + parent_key = parent.is_a?(Project) ? :project : :group + + label = ::Labels::CreateService.new(args).execute(parent_key => parent) + + { + label: label.persisted? ? label : nil, + errors: errors_on_object(label) + } + end + end + end +end |