relay: add query implemenatation