How to use the query hook/filter?

How to use the query hook/filter?