Dgraph v1.1.0: Visualization does not show one-to-one edges

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"
      }
    ]
  }
}

paulftw commented :

This is happening because Ratel expects edges to be represented as arrays.
In 0.16 response would probably be friend: [{...bob's fields...}] but in 1.1 it is friend: {...bob's fields...}

GraphParser needs to be updated to support this type of data.

danielmai commented :

Looks like this issue was fixed in Merge branch 'one-to-one' · dgraph-io/ratel@7559df4 · GitHub.

I see the fix in the ?latest distribution, but not the ?dev distribution.

paulftw commented :

yes, dev is most likely missing it because it’s not built from master (for a short while).
I’ll close this issue, dev will get updated next time we ship it.