From 63acd0e7b24551fbca82506ec7978f8b3b8ac2cb Mon Sep 17 00:00:00 2001 From: Rakesh Emmadi Date: Thu, 20 Dec 2018 19:31:54 +0530 Subject: [PATCH] generate aggregate order by types only if relevant columns are present, closes #1243 (#1248) --- server/src-lib/Hasura/GraphQL/Schema.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src-lib/Hasura/GraphQL/Schema.hs b/server/src-lib/Hasura/GraphQL/Schema.hs index 05101a7e..8c9dc714 100644 --- a/server/src-lib/Hasura/GraphQL/Schema.hs +++ b/server/src-lib/Hasura/GraphQL/Schema.hs @@ -1143,12 +1143,16 @@ input table__order_by { mkTabAggOpOrdByInpObjs :: QualifiedTable -> [PGCol] -> [PGCol] -> [InpObjTyInfo] mkTabAggOpOrdByInpObjs tn numCols compCols = - map (mkInpObjTy numCols) numAggOps <> map (mkInpObjTy compCols) compAggOps + mapMaybe (mkInpObjTyM numCols) numAggOps + <> mapMaybe (mkInpObjTyM compCols) compAggOps where mkDesc (G.Name op) = G.Description $ "order by " <> op <> "() on columns of table " <>> tn + + mkInpObjTyM cols op = bool (Just $ mkInpObjTy cols op) Nothing $ null cols mkInpObjTy cols op = mkHsraInpTyInfo (Just $ mkDesc op) (mkTabAggOpOrdByTy tn op) $ fromInpValL $ map mkColInpVal cols + mkColInpVal c = InpValInfo Nothing (mkColName c) $ G.toGT ordByTy