Hello Team, Looks like `delete_flow_run` mutation ...
# ask-community
s
Hello Team, Looks like
delete_flow_run
mutation is clashing with Hasura's auto-generated mutation schemas. I am self hosting Prefect and as part of data retention policy, need to cleanup old data objects. I am using below mutation to cleanup old flow/task runs:
Copy code
mutation($created_before: timestamptz) {
            delete_flow_run(where: {created: {_lt: $created_before}}) {
                affected_rows
            }

            delete_flow_run_state(where: {created: {_lt: $created_before}}) {
                affected_rows
            }

            delete_log(where: {created: {_lt: $created_before}}) {
                affected_rows
            }

            delete_task_run(where: {created: {_lt: $created_before}}) {
                affected_rows
            }

            delete_task_run_state(where: {created: {_lt: $created_before}}) {
                affected_rows
            }
        }
The request fails with below error:
Copy code
2020-08-27T12:40:17.586Z {"message":"Unknown argument \"where\" on field \"delete_flow_run\" of type \"Mutation\".","locations":[{"line":3,"column":37}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}
2020-08-27T12:40:17.586Z {"message":"Cannot query field \"affected_rows\" on type \"success_payload\".","locations":[{"line":7,"column":9}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}
2020-08-27T12:40:17.586Z {"message":"Field \"delete_flow_run\" argument \"input\" of type \"delete_flow_run_input!\" is required, but it was not provided.","locations":[{"line":3,"column":21}],"extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}
When I remove
delete_flow_run
from above mutation, everything works fine.
d
Hi @Sandeep Aggarwal, I have great news! You shouldn’t have to do this manually. The database is set to delete all dependent objects on cascade. So, as long as you delete the flow runs, all task runs, logs, etc will be deleted.
Try only deleting Flow Runs with that where clause
affected_rows
does look like something from Hasura’s schema, as our mutations only have
success
and
error
Does
affected_rows
appear in the schema of the Interactive API?
s
Thanks @Dylan for quick response. I am referring hasura docs for autogenerated schemas: https://hasura.io/docs/1.0/graphql/core/mutations/delete.html
This runs fine via Hasura UI, however when I run it via client, it clashes with the one provided by prefect
d
That’s correct, we actually filter Hasura’s auto-generated schemas and compose mutations so that they work to achieve a specific goal across many tables
s
Makes sense. The issue is that the prefect's mutation only accepts ID of flow run to be deleted. So in order to use this one, I will have to query all flow_runs and then delete them one by one. Is there any option to perform bulk delete?
d
Not at this time, but that’s a great feature request!
Would you mind opening an issue on the server repo?
s
Sure
d
Thank you!
And just to be clear, is the above mutation working in the Hasura ui as you expected?
s
Yup it works as expected.
d
Great 👍