In the UI I have a table where I'm showing data grouped by shipday which is days of the week. To do that in the hasura I've created a PostgreSQL view -
CREATE
OR REPLACE VIEW "public"."view_shipday" AS
SELECT
  shipdata.shipday,
  count(*) AS count,
  sum(shipdata.delivered) AS delivered,
  sum(shipdata.transit) AS transit,
  sum(shipdata.refused) AS refused,
  sum(shipdata.undeliverable) AS undeliverable,
  sum((shipdata.undeliverable + shipdata.refused)) AS total_exceptions
FROM
  shipdata
GROUP BY
  shipdata.shipday;
Now on the UI, I've two filters carrier and shipdate when the user selects filter like shipdate or carrier or both I want to group the data by selected filter with shipday but I want shipday to be always unique(this is important). I've tried creating below view but this creates duplicate shipday .
CREATE
OR REPLACE VIEW "public"."view_shipday_and_filter" AS
SELECT
  shipdata.shipday,
  date(shipdata.shipdate),
  shipdata.carrier,
  count(*) AS count,
  sum(shipdata.delivered) AS delivered,
  sum(shipdata.transit) AS transit,
  sum(shipdata.refused) AS refused,
  sum(shipdata.undeliverable) AS undeliverable,
  sum((shipdata.undeliverable + shipdata.refused)) AS total_exceptions
FROM
  shipdata
GROUP BY
  shipdata.shipday,
  date(shipdata.shipdate),
  shipdata.carrier;
AFAIK hasura doesn't allow to do group by with their graphql queries.
I don't want to do the grouping in the client side since the data size is really big and it will slow down the app. So in the database I want to create one or multiple(if needed) views that will group the data handling above mentioned cases so that shipday always remains unique. If there is other option to achieve this without creating view I'm open for that too.
PS I'm using hasura graphql queries. I don't want to run separate SQL statement in the client side to fetch data.
 
     
    