I promise to stop being annoying today!! After thi...
# ask-community
j
I promise to stop being annoying today!! After this lol Is it possible to write a single mutation to delete every flow in a given project?
😂 1
k
Do you wanna just use the UI to delete the project is one go?
j
No want the project to stay just be empty - I have a "dev" project which I want to be able to easily clean up
k
The answer though is I don’t think it’s a single mutation. You really need to get all the flows is one query and then loop through and delete them
j
So this gives me all the IDs;
Copy code
{
  flow(where: {project: {name: {_eq: "dev"}}}) {
    id
  }
}
Can you pass that into the delete_flow mutation somehow?
Ok that makes sense - don't really understand what graphql can do - so need to drop into python or something using the result from that first query?
k
So you do something like:
Copy code
query = """
{
  flow(where: {project: {name: {_eq: "dev"}}}) {
    id
  }
}
"""

from prefect.client import Client
client = Client()
client.graphql(query)
and you can print the return. It’s JSON and then you can pull the ids from the
data
field I think and then make a new query
Copy code
query = """
mutation {
  deleteFlow(input: "flow_id") {
    success
  }
}
"""
🙌 1
a
you could delete the project and then create it again - you do it in like 2 clicks in the UI and you're done 😄 any reason why you want to do it from GraphQL?
k
I think that doesn’t work smoothly @Anna Geller, because the project deletion is a soft delete so you can’t recreate the same name until a few hours later when the delete actually pushes through
a
oh I see, TMYK thanks. btw, Joshua, there is also an option to archive a flow - just in case you may want to keep the run history for auditability
j
cos I don't like clicking firstly lol - I want to be able to run it from the terminal - they are completely throw away its just going to be a place for devs to test things they can't do easily locally before merging into master and then being deployed to a prod project
I think the loopy way is perfect
@Anna Geller I also love to shave yaks