No input field null validation on non nullable fields

I just experienced this:

Ran the following mutation:

mutation{
  addTranscript(input: {name: "test"}){
    numUids
  }
}

Transcript is created.

However, the schema specifies that primaryLanguage is non-nullable, so my expectation is that the mutation should fail because there is no value specified for primaryLanguage:

image

If I removed primaryLanguage from requested return result, then I get the following result:

{
  "data": {
    "queryTranscript": [
      {
        "id": "0x4e21",
        "name": "test",
        "isPublished": null,
        "shareDescription": null,
        "shareTitle": null,
        "slug": null
      },
      {
        "id": "0x4e22",
        "name": "test",
        "isPublished": null,
        "shareDescription": null,
        "shareTitle": null,
        "slug": null
      }
    ]
  },
  "extensions": {
    "touched_uids": 12,
    "tracing": {
      "version": 1,
      "startTime": "2021-05-25T08:20:37.1343371Z",
      "endTime": "2021-05-25T08:20:37.1421826Z",
      "duration": 7845400,
      "execution": {
        "resolvers": [
          {
            "path": [
              "queryTranscript"
            ],
            "parentType": "Query",
            "fieldName": "queryTranscript",
            "returnType": "[Transcript]",
            "startOffset": 317600,
            "duration": 7473600,
            "dgraph": [
              {
                "label": "query",
                "startOffset": 425600,
                "duration": 7355200
              }
            ]
          }
        ]
      }
    }
  }
}

However, if I include it, I get the following:

{
  "errors": [
    {
      "message": "Non-nullable field 'primaryLanguage' (type String!) was not present in result from Dgraph.  GraphQL error propagation triggered.",
      "locations": [
        {
          "line": 12,
          "column": 5
        }
      ],
      "path": [
        "queryTranscript",
        0,
        "primaryLanguage"
      ]
    },
    {
      "message": "Non-nullable field 'primaryLanguage' (type String!) was not present in result from Dgraph.  GraphQL error propagation triggered.",
      "locations": [
        {
          "line": 12,
          "column": 5
        }
      ],
      "path": [
        "queryTranscript",
        1,
        "primaryLanguage"
      ]
    }
  ],
  "data": {
    "queryTranscript": [
      null,
      null
    ]
  },
  "extensions": {
    "touched_uids": 14,
    "tracing": {
      "version": 1,
      "startTime": "2021-05-25T08:22:22.1628428Z",
      "endTime": "2021-05-25T08:22:22.1710665Z",
      "duration": 8223000,
      "execution": {
        "resolvers": [
          {
            "path": [
              "queryTranscript"
            ],
            "parentType": "Query",
            "fieldName": "queryTranscript",
            "returnType": "[Transcript]",
            "startOffset": 278900,
            "duration": 7893000,
            "dgraph": [
              {
                "label": "query",
                "startOffset": 485300,
                "duration": 7677700
              }
            ]
          }
        ]
      }
    }
  }
}
Dgraph version   : v21.03.0
Dgraph codename  : rocket
Dgraph SHA-256   : b4e4c77011e2938e9da197395dbce91d0c6ebb83d383b190f5b70201836a773f
Commit SHA-1     : a77bbe8ae
Commit timestamp : 2021-04-07 21:36:38 +0530
Branch           : HEAD
Go version       : go1.16.2
jemalloc enabled : true

Using Dgraph via Docker locally.

1 Like