Vastly expanded macro.query's capabilities

Summary:
Depends on D5420; Fixes T2822

Increased `macro.query`'s capabilities by at least 9001%!

Test Plan: Used it in several combination of query strings. Behaves as expected.

Reviewers: epriestley

CC: aran, Korvin

Maniphest Tasks: T2822

Differential Revision: https://secure.phabricator.com/D5421