Thread
#prefect-community
    Jack Sundberg

    Jack Sundberg

    10 months ago
    I don't have any experience with GraphQL so I'm struggling to format my query. How would I get a count of running/submitted flow runs for a specific flow name? I'm a django orm user, so I know it would look this:
    nruns = FlowRuns.objects.filter(flow__name="MyExampleFlow", state__in=["Running", "Submitted"]).count()
    But for graphql... I'm kinda lost. And how would I format this in python for the
    client.query()
    method?
    Kevin Kho

    Kevin Kho

    10 months ago
    This is the source for what the UI uses
    Jack Sundberg

    Jack Sundberg

    10 months ago
    awesome thanks!
    query FlowRuns($flow_run_name: "MyExampleFlow",) {
      Success: flow_run_aggregate(
        where: {
          flow: { name: { _eq: $flow_run_name }}
          state: { _eq: "Success" }
        }
      ) {
        aggregate {
          count
        }
      }
    so would it look something like this? I'm getting errors but honestly have no idea what's wrong
    Actually nevermind. I think I'm getting the hang of it. My query is:
    query {
      flow_run_aggregate (where: 
        {flow: {name:{_eq: "MyExampleFlow"}}
        state: { _in: ["Success", "Pending"] }
        })
         {
          aggregate {count}
        }
    }
    Kevin Kho

    Kevin Kho

    10 months ago
    That looks good. I was expecting you to just use the flow id but this looks like it works