What I want to do
I have a service graph which connect services and their dependencies, here’s the schema:
name: string @index(exact) .
dependsOn: [uid] @reverse .
type Service {
name
dependsOn
}
and sample data:
_:a <dgraph.type> "Service" .
_:a <name> "serviceA" .
_:b <dgraph.type> "Service" .
_:b <name> "serviceB" .
_:c <dgraph.type> "Service" .
_:c <name> "serviceC" .
_:d <dgraph.type> "Service" .
_:d <name> "serviceD" .
_:a <dependsOn> _:b .
_:a <dependsOn> _:c .
_:b <dependsOn> _:c .
_:c <dependsOn> _:b .
_:b <dependsOn> _:d .
I want to find all service pairs that depends on each other, serviceB
and serviceC
is what I expected in example data above.
What I did
I’ve tried many queries but none get work, here’s is one of my queries:
{
q(func: eq(dgraph.type, "Service")) {
uid
name
D as dependsOn {
uid
name
}
providesOf: ~dependsOn @filter(uid(D)) {
uid
name
}
}
}
result is:
{
"q": [
{
"uid": "0xfffd8d67d85fdd75",
"name": "serviceA",
"dependsOn": [
{
"uid": "0xfffd8d67d85fdd76",
"name": "serviceB"
},
{
"uid": "0xfffd8d67d85fdd77",
"name": "serviceC"
}
]
},
{
"uid": "0xfffd8d67d85fdd76",
"name": "serviceB",
"dependsOn": [
{
"uid": "0xfffd8d67d85fdd77",
"name": "serviceC"
},
{
"uid": "0xfffd8d67d85fdd78",
"name": "serviceD"
}
]
},
{
"uid": "0xfffd8d67d85fdd77",
"name": "serviceC",
"dependsOn": [
{
"uid": "0xfffd8d67d85fdd76",
"name": "serviceB"
}
]
},
{
"uid": "0xfffd8d67d85fdd78",
"name": "serviceD"
}
]
}
What did I missunderstanding? Any suggestions?
Dgraph metadata
dgraph version
[Decoder]: Using assembly version of decoder
Page Size: 4096
Dgraph version : v20.11.0
Dgraph codename : tchalla
Dgraph SHA-256 : 8acb886b24556691d7d74929817a4ac7d9db76bb8b77de00f44650931a16b6ac
Commit SHA-1 : c4245ad55
Commit timestamp : 2020-12-16 15:55:40 +0530
Branch : HEAD
Go version : go1.15.5
jemalloc enabled : true
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.