https://prefect.io logo
#prefect-server
Title
# prefect-server
b

Bruno Nunes

03/21/2022, 1:53 PM
How would we retrieve the status of a flow using graphQL queries?
k

Kevin Kho

03/21/2022, 1:55 PM
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

Bruno Nunes

03/21/2022, 1:59 PM
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

Kevin Kho

03/21/2022, 2:02 PM
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

Bruno Nunes

03/21/2022, 2:26 PM
Thanks! So the input is the flow id?
k

Kevin Kho

03/21/2022, 2:26 PM
Yeah that is returned from creating the flow run
b

Bruno Nunes

03/21/2022, 2:27 PM
Thanks!
👍 1
3 Views