How can we use the GraphQL API to find which user ...
# ask-community
m
How can we use the GraphQL API to find which user manually restarted a flow run? Or separately, a task run?
k
I think this is also available on Enterprise plans as it requires the Audit Trail functionality. Let me check the GraphQL schema and see if it’s there
m
We’re on the enterprise plan.
I see created_by on flow_run, but I want to confirm that that will give us the user who restarted, not just created a flow_run
k
Yeah I see that too. Let me check if there is a way with the team
m
Thank you so much Kevin
k
This should be in the log like this
Copy code
query {
  flow_run_by_pk(id: "xxxxxxxxx") {
    states {
      message
    }
    name
  }
}
m
Can we get this without parsing the log?
And can we get it for the task_run?
k
On the first question, this is not quite the log, it's the state transition messages (which also appear in the logs). If you are asking about extracting with without parsing the string, I am fairly sure the answer is no since it doesn't seem to be anywhere in the schema. On the second one, will try more concretely later but this seems to be a flow run concept as to who triggered/restarted the flow. Will try with tasks and get back to you to confirm though. Maybe if you walk me through your use case, we can find some other way to solve it?
m
Sure, thanks Kevin
Suppose I have a scheduled flow that runs every day at 8am and usually finishes by 10am. At 9am, a task fails. I, Matthew, restart the task (my understanding is that there will be a new task run), and I want to send a notification from an agent saying who restarted the task. So it should say my name. Please let me know if this doesn’t make sense!
k
Ok I tried it and it doesn’t seem available at the task level because the task is kinda agnostic to that info. Just a note that there will not be a new task run, the task run state will just get changed to scheduled. I think this is very hard right now, and the only solution I can think of is literally traversing the states of the flow run and looking for the last state transition or the restart word in the state messages. This is definitely a rough experience. I don’t know enough on the backend of Cloud as to how to make this easier. I can open a feature request for you (or you’re welcome to yourself).
m
Thanks for digging into this Kevin! It seems like what you’re saying is that my understanding of the task restart mechanism is wrong. There is simply a transition between states, and not an entirely new task run. Before opening a ticket, does it make sense to you to add this functionality?
k
I think so? I can imagine it being a requested feature for audit trail purposes
But I’m honestly not sure on this one
m
In that case, I think it makes sense to at least open a feature request.
I think it helps to think about the operational case where you’ve got a large flow or flow of flows with 100s of tasks as part of a daily production process. Different people might restart different tasks in the flow and knowing which users intervened on which task is important to track.
k
I will open a ticket for this tomorrow
m
Thanks Kevin
Appreciate your help
k
Of course!
m
Kevin, do you mind sending me the feature request once you create it? Would be great to keep track of these on our side
k
yep will do in a bit
m
Awesome ty!