Refactor the e2e query handler to separate out the local query, and then make the federation handler use it.