https://prefect.io logo
a

Andy Dyer

02/15/2021, 3:56 PM
Hey All, I am a graphql noob and was wondering if anyone had an example of a mutation to run a flow with given parameters?
1
k

Kyle Moon-Wright

02/15/2021, 4:39 PM
Shazam!
Copy code
mutation {
    create_flow_run(
        input: {
            flow_id: "<MY_FLOW_ID>",
            parameters: "{\"<TASK_NAME>\": \"<TASK_VALUE>\"}"
        }
    ) {
        id
    }
}
🙌 1
1
a

Andy Dyer

02/15/2021, 4:40 PM
thanks Kyle!
👍 1
@Kyle Moon-Wright what is the url for the api I cant find it in the docs. (not using the prefect python api using a graph ql client)
k

Kyle Moon-Wright

02/15/2021, 9:03 PM
<https://api.prefect.io>
a

Andy Dyer

02/15/2021, 9:04 PM
thanks totally missed that and cmd-f’d now in the docs and its front and center. Thanks Kyle
hattip 1
hey Kyle any reason why a token created like
Copy code
mutation {
  create_api_token(input: { name: "ARBITARY_NAME", scope: TENANT }) {
    token
  }
}
would be getting forbidden from the prefect api. Am i messing up scoping ?
k

Kyle Moon-Wright

02/16/2021, 1:44 AM
Hmm, tough to say - that mutation works for me no problem. 🤔
a

Andy Dyer

02/16/2021, 5:50 PM
It worked this morning with the same input, is it possible that API keys take a while to propagate?
k

Kyle Moon-Wright

02/16/2021, 8:22 PM
It should be pretty instant if you create a token, are you not able to access your tenant with the token you created?
a

Andy Dyer

02/16/2021, 9:03 PM
i was only after a few hours. I had a postman query not work EOD with a 403, ran it first thing with 0 changes and it worked 200 no problem. As an aside for that mutation, is their anyway to create_a_flow_run for the latest version. I supposed you could also query to get the latest flow versions’ id by name and take the greatest version
k

Kyle Moon-Wright

02/16/2021, 9:58 PM
Yep, I think that’s the best way to do it. As you already know, each flow version has its own ID and must be provided to run that flow. Though, I’m sure there’s a better call/mutation to get the last flow ID for that version group.
2 Views