Refactor how the query service is configured