Hello everyone, I wanted to know if there are any ...
# ask-community
r
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
Hi Ravi, you can use the graphql client with Prefect, and probably use a query similar to :
Copy code
query   {
  flow_run (where: {state : {_eq: "Running"}}) {
  id
  name
	}
}
r
@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
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
Copy code
import prefect
client = prefect.Client()

client.graphql(
    {
        'query': {
            'flow': {
                'id'
            }
        }
    }
)
r
@Christopher Boyd Great! will check it out.. Thanks a lot
c
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
@Christopher Boyd ok..will probably use the graphql one.. not using the cloud version currently
1
c
sounds good!
👍 1