2021-12-02

Why can I execute mutation function with null parameter with type being `String!`?

Simple table with one two rows. ID (incrementing int) and test_value (TEXT, nullable).

1. Query

query getData($test_value:String!) {
  testtable(where: {test_value: {_eq: $test_value}}) {
    test_value
  }
}

Variables

{"test_value":null} 

Result

{
  "errors": [
    {
      "extensions": {
        "path": "$.selectionSet.testtable.args.where.test_value._eq",
        "code": "validation-failed"
      },
      "message": "unexpected null value for type \"String\""
    }
  ]
}

This is a correct that I expect.

2. Mutation

mutation InsertData($test_value: String!) {
  insert_testtable(objects: {test_value: $test_value}) {
    affected_rows
  }
}

Variables

{"test_value":null} 

Result

{
    data: {
        insert_testtable: {
            affected_rows: 1
        }
    }
}

I expect and error (because of test_value:String! declaration), but I don't get it. Why?

P.S. testable schema looks like this: id: Int! test_value: String



from Recent Questions - Stack Overflow https://ift.tt/3FZNSaw
https://ift.tt/eA8V8J

No comments:

Post a Comment