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
This commit is contained in:
Daniel Harvey 2023-12-13 12:30:33 +00:00 committed by hasura-bot
parent 75a691a1cf
commit 72e50c1556

View File

@ -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) =>