From 72e50c155677e1ec01ddc80aede7c94ba86a4076 Mon Sep 17 00:00:00 2001 From: Daniel Harvey Date: Wed, 13 Dec 2023 12:30:33 +0000 Subject: [PATCH] chore: check we have fields in our Logical Model before outputting a parser PR-URL: https://github.com/hasura/graphql-engine-mono/pull/10550 GitOrigin-RevId: 85f83274f696e381da68547bf7af098ea8f5ac11 --- server/src-lib/Hasura/LogicalModel/Schema.hs | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/server/src-lib/Hasura/LogicalModel/Schema.hs b/server/src-lib/Hasura/LogicalModel/Schema.hs index b8287fcc152..6f460fb5b7a 100644 --- a/server/src-lib/Hasura/LogicalModel/Schema.hs +++ b/server/src-lib/Hasura/LogicalModel/Schema.hs @@ -250,13 +250,22 @@ defaultLogicalModelSelectionSet logicalModel = runMaybeT do -- We entirely ignore Relay for now. implementsInterfaces = mempty - lift $ P.memoizeOn 'defaultLogicalModelSelectionSet fieldName do - -- we filter out parsers that return 'Nothing' as those we are no permitted to see. - parsers <- catMaybes <$> traverse (\(column, lmField, redactionExp) -> parseLogicalModelField mempty column lmField redactionExp) allowedColumns + -- we filter out parsers that return 'Nothing' as those we are no permitted to see. + parsers <- + catMaybes + <$> traverse + ( \(column, lmField, redactionExp) -> + lift (parseLogicalModelField mempty column lmField redactionExp) + ) + allowedColumns - pure - $ P.selectionSetObject fieldName description parsers implementsInterfaces - <&> parsedSelectionsToFields IR.AFExpression + -- if we have no fields, we can't create a parser + if null parsers + then hoistMaybe Nothing + else lift $ P.memoizeOn 'defaultLogicalModelSelectionSet fieldName do + pure + $ P.selectionSetObject fieldName description parsers implementsInterfaces + <&> parsedSelectionsToFields IR.AFExpression logicalModelSelectionList :: (MonadBuildSchema b r m n, BackendLogicalModelSelectSchema b) =>