Hello
When using live loader, reverse edges are not set if not included in the JSON files.
So we are trying to run a DQL logic that sets the reverse edges afterwards
Schema:
type Item {
id: ID!
# Category
category: Category
...
}
type Category {
id: ID!
categoryCode: String! @search(by: [term])
items: [Item] @hasInverse(field: "category")
...
}
This is the code:
curl -H "Content-Type: application/rdf" -X POST localhost:8080/mutate?commitNow=true -d $'
upsert {
query {
items(func: type(Item)) @normalize {
itemUid as uid
Item.category {
categoryUid as uid
}
}
}
mutation {
set {
uid(categoryUid) <Category.items> uid(itemUid) .
}
}
}' | jq
Current dataset:
{
"data": {
"queryItem": [
{
"id": "0x4e3b",
"itemNo": "Sky Wing 5.4",
"category": {
"id": "0x4e30",
"categoryCode": "boards"
}
},
{
"id": "0x1117c",
"itemNo": "Maui Cloud 6.2",
"category": {
"id": "0x4e30",
"categoryCode": "boards"
}
},
{
"id": "0x7c86d",
"itemNo": "watch-serialno",
"category": {
"id": "0x6ddd3",
"categoryCode": "Watches"
}
},
{
"id": "0x7ef5e",
"itemNo": "iphone-7-plus",
"category": {
"id": "0x7ef5b",
"categoryCode": "Phones"
}
}
]
},
Result after running the DQL above.
{
"data": {
"queryCategory": [
{
"id": "0x4e30",
"categoryCode": "boards",
"items": [
{
"id": "0x4e3b",
"description": "Fanatic Sky Wing board 5.4"
},
{
"id": "0x1117c",
"description": "Maui Cloud kite Series E 6.2"
},
{
"id": "0x7c86d",
"description": "Hand made exclusive watch"
},
{
"id": "0x7ef5e",
"description": "iPhone 7 Plus"
}
]
},
{
"id": "0x6ddd3",
"categoryCode": "Watches",
"items": [
{
"id": "0x4e3b",
"description": "Fanatic Sky Wing board 5.4"
},
{
"id": "0x1117c",
"description": "Maui Cloud kite Series E 6.2"
},
{
"id": "0x7c86d",
"description": "Hand made exclusive watch"
},
{
"id": "0x7ef5e",
"description": "iPhone 7 Plus"
}
]
},
{
"id": "0x7ef5b",
The desired results is not achieved. I tried different ways, but I could not find a way to set the variable containing the items uids per category. So the result is that all items are set to the categories …
Thanks
Regards