Class: Tasker::Mutations::CancelStep
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Tasker::Mutations::CancelStep
- Defined in:
- app/graphql/tasker/mutations/cancel_step.rb
Instance Method Summary collapse
Instance Method Details
#resolve(task_id:, step_id:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/graphql/tasker/mutations/cancel_step.rb', line 15 def resolve(task_id:, step_id:) step = Tasker::WorkflowStep.where({ task_id: task_id, workflow_step_id: step_id }).first return { step: nil, errors: 'no such step' } unless step # Use state machine to transition step to cancelled step.state_machine.transition_to!(Tasker::Constants::WorkflowStepStatuses::CANCELLED) if step.errors.empty? Tasker::WorkflowStepSerializer.new(step).to_hash else { step: nil, errors: step.errors } end end |