https://prefect.io logo
Title
r

Ravi Kumar

12/14/2022, 1:33 PM
Hello everyone, I wanted to know if there are any prefect server graph-ql apis which let me know all the flows that are running currently across all the agents? Would need to call this api from inside a flow. For version 0.15.13
c

Christopher Boyd

12/14/2022, 2:09 PM
Hi Ravi, you can use the graphql client with Prefect, and probably use a query similar to :
query   {
  flow_run (where: {state : {_eq: "Running"}}) {
  id
  name
	}
}
r

Ravi Kumar

12/14/2022, 2:11 PM
@Christopher Boyd hey thanks a lot! Can u point me to the documentation of using these graph ql queries from inside a flow?
Is this it? https://docs-v1.prefect.io/api/0.15.13/utilities/graphql.html#functions parse_graphql method seems promising
c

Christopher Boyd

12/14/2022, 2:16 PM
Hi Ravi, That one is good for the API specifics, this one provides a bit of overview with using the client: https://docs-v1.prefect.io/orchestration/concepts/api.html
I have an example, one moment
🙌 1
import prefect
client = prefect.Client()

client.graphql(
    {
        'query': {
            'flow': {
                'id'
            }
        }
    }
)
r

Ravi Kumar

12/14/2022, 2:17 PM
@Christopher Boyd Great! will check it out.. Thanks a lot
c

Christopher Boyd

12/14/2022, 2:18 PM
no problem! you can use other modules if you want, it doesn’t have to be the prefect graphql client - that said, if you do use the prefect one, it handles authentication for you
otherwise if you are using prefect cloud, you’ll need to authenticate yourself in the headers
r

Ravi Kumar

12/14/2022, 2:19 PM
@Christopher Boyd ok..will probably use the graphql one.. not using the cloud version currently
1
c

Christopher Boyd

12/14/2022, 2:20 PM
sounds good!
👍 1