Not sure if I understood perfectly. But for
“I want to find the “projects” that they mutually work on.”
You can do something like:
Take into account that I had to improvise by simplifying the sample.
{
company1(func: type(Company))
@filter(eq(name, "Equinor ASA") ) {
uid
name
PC1 as ~project.company
count(~project.company)
}
company2(func: type(Company))
@filter(eq(name, "Royal Dutch Shell") ) {
uid
PC2 as ~project.company
count(~project.company)
}
worked(func: uid(PC1)) @filter(uid(PC2)) {
name
~project.company {
name
}
count(uid)
}
}
Result
{
"data": {
"company1": [
{
"uid": "0xea6f",
"name": "Equinor ASA",
"count(~project.company)": 6
}
],
"company2": [
{
"uid": "0xea70",
"name": "Royal Dutch Shell",
"count(~project.company)": 6
}
],
"worked": [
{
"count": 4
},
{
"name": "Worked with Shell 1"
},
{
"name": "Worked with Shell 3"
},
{
"name": "Worked with Shell 2"
},
{
"name": "Worked with Shell 4"
}
]
}
}
Mutation
{
"set": [{
"uid": "_:EquinorASA",
"name": "Equinor ASA",
"dgraph.type": "Company"
},
{
"uid": "_:Shell",
"name": "Royal Dutch Shell",
"dgraph.type": "Company"
}, {
"name": "the Timor Sea",
"project.company": {
"uid": "_:EquinorASA"
}
},
{
"name": "the Canyon Lime formation",
"project.company": {
"uid": "_:EquinorASA"
}
}, {
"uid": "_:Shell1",
"name": "Worked with Shell 1",
"project.company": [{
"uid": "_:EquinorASA"
}, {
"uid": "_:Shell"
}]
}, {
"uid": "_:Shell2",
"name": "Worked with Shell 2",
"project.company": [{
"uid": "_:EquinorASA"
}, {
"uid": "_:Shell"
}]
}, {
"uid": "_:Shell3",
"name": "Worked with Shell 3",
"project.company": [{
"uid": "_:EquinorASA"
}, {
"uid": "_:Shell"
}]
}, {
"uid": "_:Shell4",
"name": "Worked with Shell 4",
"project.company": [{
"uid": "_:EquinorASA"
}, {
"uid": "_:Shell"
}]
}, {
"name": "Tobago",
"project.company": {
"uid": "_:Shell"
}
}, {
"name": "the Hazira LNG and Port venture",
"project.company": {
"uid": "_:Shell"
}
}
]
}