Moved from GitHub ratel/106
Posted by danielmai:
Dgraph v1.1.0 supports specifying one-to-one edges using the uid
schema type. e.g.,
friend: uid .
This enforces the predicate to only have a single outgoing edge per node. e.g., instead of having a list of friends, each person would only be allowed to have one friend.
Output non-list uid predicates as a map. by martinmr · Pull Request #2921 · dgraph-io/dgraph · GitHub changed the query response for one-to-one uid edges to output as a single JSON map instead of an array. This breaks the graph visualization for one-to-one edges.
Steps to reproduce
Set schema for a single uid edge:
friend: uid .
Set mutation:
{
"set": [
{
"name": "Alice",
"friend": {
"name": "Bob"
}
}
]
}
Run query:
{
q(func: has(name)) {
name
friend {
name
}
}
}
Query response (does not have JSON array for "friend"
):
{
"data": {
"name": "Alice",
"friend": {
"name": "Bob"
}
}
}
Query visualization in Ratel:
Expected results
The visualization should show the friend
edge. This works for [uid]
edges, as shown below.
Steps to reproduce expected results
Set schema for list [uid]
edge:
friend: [uid] .
Set mutation:
{
"set": [
{
"name": "Alice",
"friend": {
"name": "Bob"
}
}
]
}
Run query:
{
q(func: has(name)) {
name
friend {
name
}
}
}
Query response (JSON array for "friend"
):
{
"data": {
"name": "Alice",
"friend": [
{
"name": "Bob"
}
]
}
}