node.jsdgraph

Dgraph query returning data even if the uid is not present


I was querying dgraph for the user's details, but it's returning an array with one object having the key uid and value as the "uid_string" that I queried for, even if no user exists with that uid.

The query:

{
  User(func: uid(0x44)) {
    uid
    name
  }
}

The result that I am getting:

"User": [
      {
        "uid": "0x44"
      }
    ]

The expected result should be:

"User": []

Solution

  • The uid() function is like an identity function: it will return to you the uid specified, regardless if it has any incoming or outgoing edges to it.

    A uid without any edges is effectively an orphan node, and has no impact to how data is stored or queried in Dgraph.