Schema
connection: uid .
name: string .
type Node {
name
connection
}
Set data
{
set {
_:node1 <name> "node_1" .
_:node1 <dgraph.type> "Node" .
_:node2 <name> "node_2" .
_:node2 <dgraph.type> "Node" .
_:node3 <name> "node_3" .
_:node3 <dgraph.type> "Node" .
}
}
Set initial connection
{
set {
<0x1> <connection> <0x2> .
}
}
Replace connection
{
set {
<0x1> <connection> <0x3> .
}
}
Replace connection a second time
{
set {
<0x1> <connection> <0x2> .
}
}
Using this query
{
q(func: type(Node)) {
uid
name
connection {
uid
}
}
}
I get an array for the connection of node with uid 0x1
"data": {
"q": [
{
"uid": "0x1",
"name": "node_1",
"connection": {
"uid": [
"0x2",
"0x3"
]
}
},
{
"uid": "0x2",
"name": "node_2"
},
{
"uid": "0x3",
"name": "node_3"
}
]
},
But with this query
{
q(func: type(Node)) {
uid
name
connection {
name
uid
}
}
}
I get the correct result
"data": {
"q": [
{
"uid": "0x1",
"name": "node_1",
"connection": {
"name": "node_3",
"uid": "0x3"
}
},
{
"uid": "0x2",
"name": "node_2"
},
{
"uid": "0x3",
"name": "node_3"
}
]
},
I can reproduce it this way most of the time. If the connection array does not appear, try the mutations which change the connection again.
I tested with dgraph v24.1.2, v24.1.0 (which both have this problem) and dgraph v24.0.5 (which does not have this problem).