I’m on the side of not exposing query generation outside of context. I usually end up with either many small functions that does the same thing with slightly different query or come up with yet another way to re-implement querying structure which always sucks. Recently I’m exploring this approach :