diff options
Diffstat (limited to 'app/graphql/mutations/work_items/create.rb')
-rw-r--r-- | app/graphql/mutations/work_items/create.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/app/graphql/mutations/work_items/create.rb b/app/graphql/mutations/work_items/create.rb index 88b8cefd8d2..81454db62b1 100644 --- a/app/graphql/mutations/work_items/create.rb +++ b/app/graphql/mutations/work_items/create.rb @@ -3,10 +3,13 @@ module Mutations module WorkItems class Create < BaseMutation + graphql_name 'WorkItemCreate' + include Mutations::SpamProtection include FindsProject - graphql_name 'WorkItemCreate' + description "Creates a work item." \ + " Available only when feature flag `work_items` is enabled. The feature is experimental and is subject to change without notice." authorize :create_work_item @@ -29,16 +32,21 @@ module Mutations def resolve(project_path:, **attributes) project = authorized_find!(project_path) + + unless Feature.enabled?(:work_items, project) + return { errors: ['`work_items` feature flag disabled for this project'] } + end + params = global_id_compatibility_params(attributes).merge(author_id: current_user.id) spam_params = ::Spam::SpamParams.new_from_request(request: context[:request]) - work_item = ::WorkItems::CreateService.new(project: project, current_user: current_user, params: params, spam_params: spam_params).execute + create_result = ::WorkItems::CreateService.new(project: project, current_user: current_user, params: params, spam_params: spam_params).execute - check_spam_action_response!(work_item) + check_spam_action_response!(create_result[:work_item]) if create_result[:work_item] { - work_item: work_item.valid? ? work_item : nil, - errors: errors_on_object(work_item) + work_item: create_result.success? ? create_result[:work_item] : nil, + errors: create_result.errors } end |