Im using the below Mutation:
{
"set":[
{
"uid":"_:jack",
"xid": "jack",
"name":"Jack",
"dgraph.type": "Person"
},
{
"uid":"_:bmw1122",
"xid": "bmw1122",
"vehicleNo":"bmw1122",
"dgraph.type": "Vehicle",
"model": "BMW 5 Series"
},
{
"uid":"_:merc2233",
"xid": "merc2233",
"vehicleNo":"merc2233",
"dgraph.type": "Vehicle",
"model": "MERC CLS"
},
{
"uid": "_:jack",
"owner":[{
"nodes": { "uid": "_:bmw1122" },
"edges": [{
"valuationDate": "2001-01-01",
"marketValue":"20k" }]
},
{
"nodes": { "uid": "_:merc2233" },
"edges": [{
"valuationDate": "2002-0101",
"marketValue":"30k" }]
}]
}
]
}
this should create
Jack → owner → IntermediateNode1 → nodes → bmw1122
IntermediateNode1 → edges → marketValue(20k)
Jack → owner → IntermediateNode2 → nodes → merc2233
IntermediateNode2 → edges → marketValue(30k)
What I want to do is add a mutation to create another edge attribute to the bmw1122
something like this
Jack → owner → IntermediateNode1 → nodes → bmw1122
IntermediateNode1 → edges → marketValue(20k)
IntermediateNode1 → edges → marketValue(15k)
The Mutation I used is
upsert {
query {
relExists as relEdge(func: has(name)) @filter(has(owner) AND eq(xid,"jack")) @cascade
{
name
owner @filter(has(nodes))
{
n1 as n1:uid
nodes @filter(eq(xid,"bmw1122"))
{
vehicleNo
}
}
}
}
mutation @if(ge(len(relExists), 1) AND ge(len(n1), 1)) {
set {
uid(n1) <edges> _:edge .
_:edge <valuationDate> "2005-01-01" .
_:edge <marketValue> "15k" .
}
}
}
When I query back to see the outcome of the mutation
it seems the new edge is added to both the IntermediateNode1 and IntermediateNode2
My expectation is it should be added to only IntermediateNode1.
Not sure what I missed?
The reason I had this intermediateNode is I need to keep historical properties of the Node
using facets I was unable to keep historical