Hi all - if I set a task to manual trigger only, is there a way of triggering it programmatically?
I know that sounds counterintuitive, but we have a task which we want to pause and wait on a particular task until a manual process takes place on another system. We then want to trigger the workflow to continue from that system. It would be more elegant than having the task sleeping and polling.
Can we use a mutation query against the cloud API to do it?
j
Jenny
06/09/2021, 10:34 AM
Hi @Ben Collier I’ve not tried it but I believe other users have done this through the cloud API. You’d need to use the set_state mutation and set the state to resume. I’m on mobile right now but can send an example version later if you need it.
b
Ben Collier
06/09/2021, 3:08 PM
Hi Jenny, thanks! That would be enormously useful, saves me having to figure out how to send a resume mutation.
j
Jenny
06/09/2021, 3:49 PM
Copy code
mutation {
set_task_run_states (input: {states: {task_run_id: "TASK RUN ID", version: 3, state: {type: "Resume", message: "YOUR MESSAGE"}}}) {
states {
id
}
}
}
Should do it. The state input is JSON so you may need to format them. The version is how many times the task run has changed state - I believe that should be in context.
b
Ben Collier
06/09/2021, 10:16 PM
Can I ignore version entirely if I’m setting a mutation? Or is it better to do a query and figure out what the current state is?
Ben Collier
06/09/2021, 10:16 PM
(Thanks for this)
j
Jenny
06/09/2021, 10:27 PM
I believe it's required but you shouldn’t need another query, you should have it in the prefect.context.
Jenny
06/10/2021, 11:22 AM
Oh… just realized you're doing this from another flow? Context won't help there 🤦♀️
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.