What would the graphql query look like to filter f...
# prefect-server
l
What would the graphql query look like to filter flow runs on parameters? More generally, how do you filter on a json field?
a
@Lawrence Finn do you want to find all flow runs for which a specific flow was triggered with specific parameter values?
l
yeah
i have something like
Copy code
{
flow_run(
    where: {flow: {name: {_eq: "demo-flow"}} state: {_eq: "Scheduled"}}
    order_by: {scheduled_start_time: asc}
  ) {
    id
    flow_id
    labels
    name
    version
    scheduled_start_time
    __typename
    state
    parameters
  }

}
but i want to filter on a paramter
a
@Lawrence Finn it’s a bit tricky, but this should work:
Copy code
query ($param_value: jsonb) {
  flow_run(
    where: {_and: [{flow_id: {_eq: "eb45ed0a-a76c-445b-b0b8-1fdc05c1f54c"}}, 
      {parameters: {_eq: $param_value}}]}
  ) {
    name
    state
    end_time
    start_time
    parameters
  }
}
you need to make sure to pass parameter values as query variables:
l
ah, so this would be like a string comparison and i couldn’t filter on a single parameter out of a bunch of parameters?
a
you need to pass all parameters and the values you want to filter for into query variables, here is an example with 2 parameters:
I don’t think that this is a string comparison, I use parameters which are integers, so it should work the same way regardless of data types, as long as you specify it in the query variables
l
but i cant just filter on one parameter out of N?
a
I think you’re right. when I only set value for one parameter, then it would filter as if the other one wouldn’t exist, but it does, resulting in empty result set