Skip to content

Adding player with non-nullable data is allowed! #4

@omar84

Description

@omar84

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions