Add query builder interface

This works really well! Won't work for non-CQ servers, but we'll cross that bridge when we come to it.