Class: Mutations::WorkItems::Create
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Mutations::WorkItems::Create
- Includes:
- FindsNamespace, SpamProtection, Widgetable
- Defined in:
- app/graphql/mutations/work_items/create.rb
Constant Summary collapse
- MUTUALLY_EXCLUSIVE_ARGUMENTS_ERROR =
'Please provide either projectPath or namespacePath argument, but not both.'
- DISABLED_FF_ERROR =
'namespace_level_work_items feature flag is disabled. Only project paths allowed.'
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, #read_only?, #unauthorized_object
Methods included from Gitlab::Graphql::Authorize::AuthorizeResource
#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!
Instance Method Details
#ready?(**args) ⇒ Boolean
52 53 54 55 56 57 58 |
# File 'app/graphql/mutations/work_items/create.rb', line 52 def ready?(**args) if args.slice(:project_path, :namespace_path)&.length != 1 raise Gitlab::Graphql::Errors::ArgumentError, MUTUALLY_EXCLUSIVE_ARGUMENTS_ERROR end super end |
#resolve(project_path: nil, namespace_path: nil, **attributes) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/graphql/mutations/work_items/create.rb', line 60 def resolve(project_path: nil, namespace_path: nil, **attributes) container_path = project_path || namespace_path container = (container_path) check_feature_available!(container) 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( container: container, current_user: current_user, params: 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 |