mirror of
https://github.com/Airsequel/AirGQL.git
synced 2025-08-13 02:06:57 +03:00
Mark non-null gql query output fields as such
This commit is contained in:
parent
94556eaca5
commit
529573b675
4 changed files with 33 additions and 12 deletions
|
@ -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 $
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -476,7 +476,7 @@ testSuite = do
|
|||
, datatype = "INTEGER"
|
||||
, datatype_gql = Just $ stringToGqlTypeName "Int"
|
||||
, select_options = Nothing
|
||||
, notnull = False
|
||||
, notnull = True
|
||||
, isUnique = True
|
||||
, isOmittable = True
|
||||
, isGenerated = False
|
||||
|
|
|
@ -92,9 +92,13 @@
|
|||
"isDeprecated": false,
|
||||
"name": "rowid",
|
||||
"type": {
|
||||
"kind": "SCALAR",
|
||||
"name": "Int",
|
||||
"ofType": null
|
||||
"kind": "NON_NULL",
|
||||
"name": null,
|
||||
"ofType": {
|
||||
"kind": "SCALAR",
|
||||
"name": "Int",
|
||||
"ofType": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -638,9 +642,13 @@
|
|||
"isDeprecated": false,
|
||||
"name": "rowid",
|
||||
"type": {
|
||||
"kind": "SCALAR",
|
||||
"name": "Int",
|
||||
"ofType": null
|
||||
"kind": "NON_NULL",
|
||||
"name": null,
|
||||
"ofType": {
|
||||
"kind": "SCALAR",
|
||||
"name": "Int",
|
||||
"ofType": null
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue