Query workflow generator