How to get all flows via a GraphQL query, but only including the latest version of each flow?

View in #prefect-community on Slack

Ewerton_Henrique_Marschalk @Ewerton_Henrique_Marschalk: hey, someone can help me with a query in graphql api?
I wan’t to collect all created flows in one query, but I wan’t ONLY the LASTEST version of each,
how can I do so?

Kevin_Kho @Kevin_Kho: Something like this (archived = False)

query {
  flow(where: {name: {_eq: "schedule_test"}, archived: {_eq: false}}) {
    name
    project{
      name
    }
    version
    archived
  }
}

Ewerton_Henrique_Marschalk @Ewerton_Henrique_Marschalk: thanks, archved: false did the trick,

{
  flow(where: {archived: { _eq: false}}) {
    id
    name
    version
    flow_runs(where: {state: {_neq: "Scheduled"}} order_by: { start_time: desc }, limit: 1) {
      id
      state
      start_time
      end_time
    }
  }
}

will return the last time each flow run

Kevin_Kho @Kevin_Kho: Nice!