Extract viewQuery into new plugin system