Class: Mutations::WorkItems::Create
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Mutations::WorkItems::Create
- Includes:
- FindsProject, SpamProtection, Widgetable
- Defined in:
- app/graphql/mutations/work_items/create.rb
Constant Summary
Constants included from SpamProtection
SpamProtection::NEEDS_CAPTCHA_RESPONSE_MESSAGE, SpamProtection::NeedsCaptchaResponseError, SpamProtection::SPAM_DISALLOWED_MESSAGE, SpamProtection::SpamActionError, SpamProtection::SpamDisallowedError
Constants inherited from BaseMutation
Constants included from Gitlab::Graphql::Authorize::AuthorizeResource
Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR
Instance Method Summary collapse
Methods included from Widgetable
Methods included from Spam::Concerns::HasSpamActionResponseFields
Methods inherited from BaseMutation
#api_user?, authorization, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #ready?, #unauthorized_object
Methods included from Gitlab::Graphql::Authorize::AuthorizeResource
#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!
Instance Method Details
#resolve(project_path:, **attributes) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/graphql/mutations/work_items/create.rb', line 36 def resolve(project_path:, **attributes) project = (project_path) unless project.work_items_feature_flag_enabled? return { errors: ['`work_items` feature flag disabled for this project'] } end spam_params = ::Spam::SpamParams.new_from_request(request: context[:request]) params = global_id_compatibility_params(attributes).merge(author_id: current_user.id) type = ::WorkItems::Type.find(attributes[:work_item_type_id]) = (type, params) create_result = ::WorkItems::CreateService.new( project: project, current_user: current_user, params: params, spam_params: spam_params, widget_params: ).execute check_spam_action_response!(create_result[:work_item]) if create_result[:work_item] { work_item: create_result.success? ? create_result[:work_item] : nil, errors: create_result.errors } end |