1
Fork 0
mirror of https://github.com/Airsequel/AirGQL.git synced 2025-08-14 10:46:58 +03:00

Mark non-null gql query output fields as such

This commit is contained in:
prescientmoon 2024-07-11 00:07:35 +02:00 committed by Adrian Sieber
commit 529573b675
4 changed files with 33 additions and 12 deletions

View file

@ -1212,14 +1212,27 @@ getSchemaFieldOutput
getSchemaFieldOutput dbId conn accessMode tables = do
typesForTables <- forM tables $ \table -> do
columns <- getColumns dbId conn table.name
fields <- forM columns $ \columnEntry -> do
fieldsIn <- forM columns $ \columnEntry -> do
let colName = columnEntry.column_name_gql
pure $
createType
colName
"" -- TODO: Reactivate description when user can specify it
[] -- No arguments
( if columnEntry.notnull && not columnEntry.isOmittable
( if columnEntry.isOmittable
then ["SCALAR"]
else ["NON_NULL", "SCALAR"]
)
(getFullDatatype columnEntry)
fieldsOut <- forM columns $ \columnEntry -> do
let colName = columnEntry.column_name_gql
pure $
createType
colName
"" -- TODO: Reactivate description when user can specify it
[] -- No arguments
( if columnEntry.notnull
then ["NON_NULL", "SCALAR"]
else ["SCALAR"]
)
@ -1347,7 +1360,7 @@ getSchemaFieldOutput dbId conn accessMode tables = do
<> table.name
<> "\""
)
, ("fields", List fields)
, ("fields", List fieldsOut)
]
, requiresWrite $
Object $
@ -1438,7 +1451,7 @@ getSchemaFieldOutput dbId conn accessMode tables = do
( "description"
, String $ "Input object for " <> table.name
)
, ("inputFields", List fields)
, ("inputFields", List fieldsIn)
]
, fieldEnumType
, requiresWrite $

View file

@ -809,7 +809,7 @@ getColumnsFromParsedTableEntry connection tableEntry = do
columnDefMb = P.find (\d -> columnDefName d == column_name) columnDefs
selectOpts = columnDefMb >>= columnSelectOptions
isNotNull =
notnull == 1 || case columnDefMb of
notnull == 1 || primary_key == 1 || case columnDefMb of
Just columnDef -> columnIsNonNull columnDef
Nothing -> False