To facilitate better answering of questions, if you have a question, please fill in the following info. Otherwise, please delete the template.
What I want to do
I want to create a Edge between from one node to 2 other nodes that can be traversaled in reverse.
Start with a new fresh Docker and load the following Schema via
curl -X POST localhost:8080/admin/schema -d ‘@schema.graphql’
schema.graphql:
type Company {
id: ID!
Name: String
Location: String
Shareholder: [Person] @hasInverse(field: "Share")
}
type Person{
id: ID!
FirstName: String
LastName: String
Share: [Company] @hasInverse(field: "Shareholder")
}
Result:
Initial Data:
{
"set":
[
{
"dgraph.type": "Company",
"Company.Name": "Company A",
"Company.Location": "Texas"
},
{
"dgraph.type": "Company",
"Company.Name": "Company B",
"Company.Location": "Florida"
},
{
"dgraph.type": "Person",
"Person.FirstName": "Mike",
"Person.LastName": "Timberland"
}
]
}
the i get success with 3 new Id´s.
"uids": {
"dg.2159301538.151": "0x4f4f",
"dg.2159301538.152": "0x4f50",
"dg.2159301538.153": "0x4f51"
}
With these ID´s i will create the Edges like the following:
{
"set":
[
{
"uid": "0x4f51",
"dgraph.type": "Person",
"Person.Share":
[
{
"uid": "0x4f4f",
"dgraph.type": "Company"
},
{
"uid": "0x4f50",
"dgraph.type": "Company"
}
]
}
]
}
and again
"data": {
"code": "Success",
"message": "Done",
"queries": null,
"uids": {}
},
So now if i look at at the Data:
{
q(func: has(Person.FirstName)) {
uid
expand(_all_) {
uid
expand(_all_)
}
}
}
Result:
"data": {
"q": [
{
"uid": "0x4f51",
"Person.Share": [
{
"uid": "0x4f4f",
"Company.Name": "Company A",
"Company.Location": "Texas"
},
{
"uid": "0x4f50",
"Company.Name": "Company B",
"Company.Location": "Florida"
}
],
"Person.FirstName": "Mike",
"Person.LastName": "Timberland"
}
]
This Works great. But if want to resolve from the Company:
{
q(func: has(Company.Name)) {
uid
expand(_all_) {
uid
expand(_all_)
}
}
}
Result
"data": {
"q": [
{
"uid": "0x4f4f",
"Company.Name": "Company A",
"Company.Location": "Texas"
},
{
"uid": "0x4f50",
"Company.Name": "Company B",
"Company.Location": "Florida"
}
]
i dont see the shareholder. if i go expicit
{
q(func: has(Company.Name)) {
uid,
Company.Name
Company.Shareholder
{
Person.FirstName
},
~Company.Shareholder
{
Person.FirstName
}
}
}
i get an error -Predicate Company.Shareholder doesn’t have reverse edge-
If i fix this in Ratel UI with checking Reverse on the Edge.
The Result doesent Contain the Person.
Result:
"data": {
"q": [
{
"uid": "0x4f4f",
"Company.Name": "Company A"
},
{
"uid": "0x4f50",
"Company.Name": "Company B"
}
]
}
So now what am I doing wrong?
The result I expect, that in the Company node is a list of Shareholders with Mike Timberland.