How would we retrieve the status of a flow using g...
# prefect-server
b
How would we retrieve the status of a flow using graphQL queries?
k
If you already know the query you want to run, you can run it using
Client.graphql()
. The
Client()
also has some methods that might help you like
get_flow_run_info
b
I would like to launch a prefect flow from an external service but also keep checking it's status. The trigger I could use the same example that you shared https://discourse.prefect.io/t/can-i-use-python-requests-library-to-trigger-a-flow-run-through-the-graphql-api/127 Do you have a similar one to get the status?
k
Let me try. That will be more complicated
This should be good enough to get you starts:
Copy code
flow_run_info = """
query($input: uuid!) {
  flow_run_by_pk(id: $input) {
    id
    name
  }
}
"""

response = <http://requests.post|requests.post>(
    url="<https://api.prefect.io>",
    json=dict(query=flow_run_info, variables=dict(input="6764bf4d-7de0-4682-a5ae-8b9b2c744ced")),
    headers=dict(authorization=f"Bearer {API_KEY}"),
)
print(response.status_code)
print(response.text)
b
Thanks! So the input is the flow id?
k
Yeah that is returned from creating the flow run
b
Thanks!
👍 1