added query support for 'ref' and 'embed'