For anyone struggling with grouping, aggregation, etc., I found this client-side library that adds the majority of lodash functions to your queries. Transformations are applied client-side, so it will only get you so far, but at least you can define your queries without any additional steps:
https://github.com/APIs-guru/graphql-lodash