ASPNetCoreGraphQL
ASPNetCoreGraphQL copied to clipboard
Adding player with non-nullable data is allowed!
adding a player with mutation:
mutation ($player: PlayerInput!){
createPlayer(player: $player){
id
name
birthDate
}
}
and variables:
{
"player":{
"name":"test"
}
}
creates the player, with no validation for any field.
then reading the player generates the following error:
{
"data": {
"player": {
"name": "test",
"birthDate": "0001-01-01",
"birthPlace": null,
"weightLbs": 0
}
},
"errors": [
{
"message": "GraphQL.ExecutionError: Cannot return null for non-null type. Field: birthPlace, Type: String!.\r\n at GraphQL.Execution.ExecutionStrategy.ValidateNodeResult(ExecutionContext context, ExecutionNode node)\r\n at GraphQL.Execution.ExecutionStrategy.ExecuteNodeAsync(ExecutionContext context, ExecutionNode node)",
"locations": [
{
"line": 5,
"column": 5
}
],
"path": [
"player",
"birthPlace"
]
}
]
}
can you add validation please so that bad data can not be saved?