I think adding the type UID in facets is a valid request. Cuz it opens the possibility to do Hypergraphs. Ofcourse, the Hypergraph wouldn’t be “native” as facets aren’t first-class citizens. But it would be great for users who wanna explore the Hypergraph concepts.
What I have tried to reproduce here
{
set {
_:alice <name> "Alice" .
_:alice <friend> _:bob (close=true, relative=false) .
_:bob <name> "Bob" .
_:charlie <name> "Charlie" .
}
}
One thing to add is give blank nodes support in facets. e.g.:
{
set {
_:alice <name> "Alice" .
_:alice <friend> _:bob (close=true, relative=false, Presentedby="_:charlie") .
_:bob <name> "Bob" .
_:charlie <name> "Charlie" .
}
}
So what I did to add the UID was.
upsert {
query {
q(func: uid(0x2735)) {
v as uid
name
friend @facets {
b as uid
name
}
}
}
mutation {
set {
uid(v) <friend> uid(b) (close=true, relative=false, Presentedby=0x2737) .
}
}
}
Also, another good way would be
upsert {
query {
CH as varg(func: eq(name, "Charlie"))
q(func: uid(0x2735)) {
v as uid
name
friend @facets {
b as uid
name
}
}
}
mutation {
set {
uid(v) <friend> uid(b) (close=true, relative=false, Presentedby=uid(CH)) .
}
}
}
Worth to mention
Dgraph converts the UID to Hex. In my case it had converted 0x2737
to 10039
The Final Facet format with UID type.
{
"data": {
"q": [
{
"uid": "0x2735",
"name": "Alice",
"friend": [
{
"name": "Bob",
"friend|Presentedby": {
"uid": "0x2737"
},
"friend|close": true,
"friend|relative": false
}
]
}
]
}
}