Unfortunately I think search and replace is the only way. You can shorten the task somewhat by using an external editor that can search and replace across multiple files at once (VS Code is often recommended, and I think BBEdit on Mac can do it). Of course, be careful and make sure your backups are up to date when modifying multiple files.
I strongly suggest switching out your existing query with a dv.view() call, and let the view function execute the query. This way when you want to change it later on, you’ll just update the view function, and that’s it.
I’m afraid using search and replace is your best option, and if would also give a vote for VS Code. It’s a very capable tool.
Then again, you could also do a search for something unique in your query from within Obsidian, and just have the new code in your clipboard, and then manually go through the search result, mark the entire section and hit paste (and thusly replace the entire section).
It’s tolerably efficient when you’re only talking about a one time operation in not too many files.