Hi everyone, I have a question about how to correc...
# ask-community
d
Hi everyone, I have a question about how to correctly search for flows/tasks in a given state using the API. What I’d like to do is search for all flow runs that have finished. If I use
flow_run(where: {state: {_eq: "Finished"}})
that returns nothing, I think because it is using string matching. Is the set of strings that can appear in
state
listed somewhere? Thank you!
k
Maybe you can do:
Copy code
query {
	flow_run(where: {state: {_in: ["Success","Failed"]}}) {
	  id
	}
}
to get the Finished states?
upvote 2
a
or even all three
Copy code
{
  flow_run(
    where: {state: {_in: ["Failed", "Success", "Finished"]}}
    order_by: {state_timestamp: desc}
    limit: 5
  ) {
    name
    start_time
    end_time
    version
    agent {
      type
    }
  }
}
d
There are more states than just that though. What about
Cancelled
? You’d need a list of all the possible states.
k
Looking where we can find this
d
I would think there was some way of doing this through the API, since this means that if you add new states here it could break code written as you suggest.
k
As far as I can tell the state is not a strict Enum. The state Python object gets converted to JSON and contains the info for the UI to load it appropriately. For example, there is a color in the Python class here . The best exhaustive list would be what the UI renders here