Hi, I am hoping to find some help writing a mutation to delete flows from a query. Any guidance on this so far what I can figure out from lack of understanding of the graphql
Hi @Richard Hughes,
The mutation doesn’t accept another query as a parameter. You’ll have to have an intermediate action that grabs the ids from the first query and passes them to the mutation
Dylan
12/17/2020, 6:38 PM
Something like (in very pseudo python code)
r
Richard Hughes
12/17/2020, 6:43 PM
okay, let me see if I can find the doc on running python graphql
d
Dylan
12/17/2020, 6:45 PM
Copy code
from prefect import Client
from prefect.engine.state import Failed
c = Client()
flows = c.graphql(
query="""
query {
flow(where: {name: {_eq: "My Flow's Name"}}) {
id
}
}"""
)
flows = flows.get("data").get("task_run")
print(flows)
for flow in flows:
print(flow)
id = flow.get("id")
result = c.graphql(
query="""mutation DelteFlow($id: UUID!){ delete_flow(input: {id: $id}) { success } }""",
variables={"id": "1234-1234-1234-1235"},
)
Dylan
12/17/2020, 6:45 PM
I haven’t run that code (like I said, pseudocode) but that’s the general idea of what you’re looking for
Dylan
12/17/2020, 6:45 PM
You can refine the mutation using the interactive API
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.