https://prefect.io logo
Title
a

Alex Cannon

09/09/2022, 7:19 PM
Hello! I noticed that the
createFlowRunInput
type in the GraphQL API doesn't include
labels
, is there a way to trigger a flow run with a specific label using the GraphQL API?
1
Compare this to the Python client's
create_flow_run
here
r

Rob Freedy

09/09/2022, 7:33 PM
I believe this is possible by passing in the labels into an input like this. You can see that the client is calling the API in a similar manner in this code from the client: https://github.com/PrefectHQ/prefect/blob/929239eda6235fb91173ce63f292551c47b23004/src/prefect/client/client.py#L1209
create_mutation = """
mutation($input: createFlowRunInput!){
    createFlowRun(input: $input){
        flow_run{
            id
        }
    }
}
"""

inputs = dict(
    versionGroupId="339c86be-5c1c-48f0-b8d3-fe57654afe22", parameters=dict(x=6), labels=["test1","test2"]
)
a

Alex Cannon

09/09/2022, 7:50 PM
Should this work then (attached)? I get:
{
  "errors": [
    {
      "message": "Variable \"$input\" got invalid value { versionGroupId: \"a4993c90-ed8b-44d9-a73d-87c82e929afa\", labels: [\"staging\"] }; Field \"labels\" is not defined by type createFlowRunInput.",
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR"
      }
    }
  ]
}
r

Rob Freedy

09/09/2022, 8:05 PM
Could you try the following?
mutation($input: create_flow_run_input!) {
  create_flow_run(input: $input) {
    id
  }
}
with inputs:
{
  "input": {
    "flow_id": "<INSERT_FLOW_ID_HERE>",
    "labels": [
      "test",
      "test2"
    ]
  }
}