Skip to content

Instantly share code, notes, and snippets.

@danielmai
Forked from mjpitz/_README.md
Last active May 28, 2021 19:08
Show Gist options
  • Save danielmai/7db7b0c9e971eb748ce3d483278e820c to your computer and use it in GitHub Desktop.
Save danielmai/7db7b0c9e971eb748ce3d483278e820c to your computer and use it in GitHub Desktop.
dgraph troubles
mutation {
addCloud(input: [
{
name: "aws",
regions: [
{
name: "us-west-1",
zones: [
{name: "us-west-1a"},
{name: "us-west-1b"},
{name: "us-west-1c"}
]
}
]
}
]) {
cloud {
name
regions {
name
zones {
name
}
}
}
}
}
{
getCloud(name: "aws") {
name
regions {
name
zones {
name
}
}
}
}
query {
cloud(func: eq(cloud.name, "aws")) {
cloud.name
cloud.regions {
region.name
region.zones {
zone.name
}
}
}
}
type Cloud @dgraph(type: "cloud") {
id: ID!
name: String! @id
regions: [Region!]! @hasInverse(field: cloud)
}
type Region @dgraph(type: "region") {
id: ID!
name: String! @id
cloud: Cloud!
zones: [Zone!]! @hasInverse(field: region)
}
type Zone @dgraph(type: "zone") {
id: ID!
name: String! @id
region: Region!
}
{
set {
_:aws <dgraph.type> "cloud" .
_:aws <cloud.name> "aws" .
_:aws <cloud.regions> _:us-west-1 .
_:us-west-1 <dgraph.type> "region" .
_:us-west-1 <region.name> "us-west-1" .
_:us-west-1 <region.cloud> _:aws .
_:us-west-1 <region.zones> _:us-west-1a .
_:us-west-1 <region.zones> _:us-west-1b .
_:us-west-1 <region.zones> _:us-west-1c .
_:us-west-1a <dgraph.type> "zone" .
_:us-west-1a <zone.name> "us-west-1a" .
_:us-west-1a <zone.region> _:us-west-1 .
_:us-west-1b <dgraph.type> "zone" .
_:us-west-1b <zone.name> "us-west-1b" .
_:us-west-1b <zone.region> _:us-west-1 .
_:us-west-1c <dgraph.type> "zone" .
_:us-west-1c <zone.name> "us-west-1c" .
_:us-west-1c <zone.region> _:us-west-1 .
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment