Hello,
I am new to dGraph and run into such a problem.
This is my schema:
type Person {
email: String! @search(by:[fulltext]) @id
name: String @search(by:[fulltext])
member_of: [Organization] @hasInverse(field: has_member)
}
type Organization {
id: ID!
name: String @search(by:[fulltext])
has_member: [Person] @hasInverse(field: member_of)
}
Person can be in many Organizations and Organization can have many People.
Now, when I perform adding Person:
{
"email": "test@email5",
"name": "test5",
"member_of": [
{ "name": "org5" }
]
}
it will create new Person and new Organization.
Now when I perform query to get all People it will respond correctly:
{
"name": "test5",
"email": "test@email5",
"member_of": [
{
"id": "0x2719",
"name": "org5"
}
]
},
but analogous query to get all Organizations lacks of relationships:
{
"id": "0x2719",
"name": "org5",
"has_member": []
},
.
Analogous add Organization mutation works fine as I am providing email of Person which is actually id od Person:
{
"name": "org6",
"has_member": [ {"email": "test@email6"} ]
}
results in:
{
"id": "0x271c",
"name": "test6",
"has_member": [
{
"email": "test@email6"
}
]
}
.
So it seems that to properly create new nodes with relationship we need to provide id.
Why it is not handled automatically?
[ENVIRONMENT]
PS C:\Users\developer\Desktop\dgraph-windows-amd64> .\dgraph.exe version
[Decoder]: Using assembly version of decoder
Page Size: 4096
Dgraph version : v20.11.1
Dgraph codename : tchalla-1
Dgraph SHA-256 : f254ac1544b4bbea79bd4d199ab27c970294b4484ec067b5ce3febc2892dd108
Commit SHA-1 : 7153d13fe
Commit timestamp : 2021-01-28 15:59:35 +0530
Branch : HEAD
Go version : go1.15.5
jemalloc enabled : false
For Dgraph official documentation, visit https://dgraph.io/docs/.
For discussions about Dgraph , visit http://discuss.dgraph.io.
Licensed variously under the Apache Public License 2.0 and Dgraph Community License.
Copyright 2015-2020 Dgraph Labs, Inc.