How can I add a Facet - mutate, graphql and dgo?
Guessing from doc I am trying to set a facet via mutation:
Facets can be created by using the
|
character to separate the predicate and facet key in a JSON object field name. This is the same encoding schema used to show facets in query results. E.g.
{
"set": [
{
"Box.name": "box one",
"Box.items": [
{
"Item.name": "item one",
"Box.items|ok": "yes"
}
]
}
]
}
graphql:
type Box {
id: ID!
name: String!
items: [Item]
}
type Item {
name: String!
ok: bool(Box.items|ok)
}
dgo:
// ItemEntity --
type ItemEntity struct {
Name string `json:"Item.name,omitempty"`
Ok bool `json:"Item.ok|Box.ok,omitempty"`
DType []string `json:"dgraph.type,omitempty"`
}
// BoxEntity --
type BoxEntity struct {
Uid string `json:"Box.uid,omitempty"`
Name string `json:"Box.name,omitempty"`
Items []ItemEntity `json:"Box.items,omitempty"`
Ok bool `json:"Box.items|Item.ok,omitempty"`
DType []string `json:"dgraph.type,omitempty"`
}
...
box := BoxEntity{
Uid: "_:box",
Name: name,
Items: []ItemEntity{{
Name: "Item one",
DType: []string{"Item"},
}},
Ok: true,
DType: []string{"Box"},
}