https://prefect.io logo
Title
k

kevin

03/04/2022, 5:14 PM
hey guys would anyone have a simple example of using a GQL query to trigger a flow run I can look at?
k

Kevin Kho

03/04/2022, 5:15 PM
It will be easier to use
Client.create_flow_run
, do you really want to use the GraphQL API?
You can use the native requests library like this:
import requests

query = """
 mutation {
  create_flow_run(input: { version_group_id: "fb919cc4-7f74-4ed7-9f3c-71bdd9be69e8" }) {
    id
  }
}
"""

url = "<<https://api.prefect.io>>"
response = <http://requests.post|requests.post>(
    url, json={"query": query}, headers={"authorization": "Bearer XXX"}
)
print(response.status_code)
print(response.text)
Also can be seen here but pretty much the same
k

kevin

03/04/2022, 5:17 PM
ah cool I was asking primarily out of curiosity. I was imagining making requests direct to prefect via some external application
thanks for the quick response 🙂
👍 1