Class: Mutations::Timelogs::Create
- Inherits:
-
Base
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Base
- Mutations::Timelogs::Create
- Defined in:
- app/graphql/mutations/timelogs/create.rb
Constant Summary
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 inherited from BaseMutation
#api_user?, authorization, authorization_scopes, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #ready?, #unauthorized_object
Methods included from Gitlab::Graphql::Authorize::AuthorizeResource
#authorize!, #authorized_find!, #authorized_resource?, #raise_resource_not_available_error!
Instance Method Details
#resolve(issuable_id:, time_spent:, summary:, **args) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/graphql/mutations/timelogs/create.rb', line 30 def resolve(issuable_id:, time_spent:, summary:, **args) parsed_time_spent = Gitlab::TimeTrackingFormatter.parse(time_spent) if parsed_time_spent.nil? return { timelog: nil, errors: [_('Time spent must be formatted correctly. For example: 1h 30m.')] } end issuable = (id: issuable_id) spent_at = args[:spent_at].nil? ? DateTime.current : args[:spent_at] result = ::Timelogs::CreateService.new( issuable, parsed_time_spent, spent_at, summary, current_user ).execute response(result) end |