How can I build facet

mutation

(Yu Wei) #1

Hi, in doc,build facet like this


why the edge’s facet should be built like

{
  "name": "Carol",
  "name|initial": "C",
  "friend": {
    "name": "Daryl",
    "friend|close": "yes"
  }
}

I think

{
  "name": "Carol",
  "name|initial": "C",
  "friend|close": "yes",
  "friend": {
    "name": "Daryl"
  }
}

is more easier


(Michel Conrado) #2

Hi Yu Wei,
This is a design decision. I don’t know deeply why is as it is, but what I can say is that this approach makes kind of logical the relation of the facet. A -> B in a JSON obj.

In general, the facet stays between the nodes. But you can have “Value Facets”. Which stays in the node itself. There’s no other way to deal with this. The only way is how it is right now.

So this

Is a “Value Facet” - The "name|initial": "C" is a value facet for Carol and in your example "friend|close": "yes" also is, but makes no sense (Carol is close of who? how you can tell?). That’s why it goes to Daryl’s node. To “tell a story between them”.

Most Dgraph users uses value facets to add information on simple edges. With no relations. They use as tags or the like. If we modify this behavior, it can be bad for those users who have already gotten used to this way of doing things.


(Yu Wei) #3

Thx for you reply. I understood