Migrating old query api to the new query api design