GraphQL exposes a graph of things in a nice, clear API. At the moment, within the story, when searching for habitable planets a query like this is used:
query {
stars {
entries {
node {
planets(type:"Water") {
...pinfo
}
}
}
}
}
fragment pinfo on Planet {
name
length_of_day
hazards {
...hzd
}
}
fragment hzd on Hazards {
bio
thermal
weather
tectonics
}
...and then we scroll in a huge list looking for something interesting... We also scroll past a lot of stars with no planets that are interesting (planets being an empty list).
Obviously, the answer here is to make a query like this, instead:
query {
planets(type:"Water") {
entries {
node {
...pinfo
star {
name
hyperspaceRange
}
}
}
}
}
(in other words, get all of the interesting planets, and for those planets that are interesting get their parent star so you know where to go and how far away it is)
(ideally also add a way to filter for hazards in the Planets query)
It'd be great to work this into the story somehow: make the user first do the dumb query, then tell them about the smart one. It'd be a great opportunity to learn.
(honestly, I feel kind of silly for not having thought about this before; I guess that in itself is a good demonstration of how thinking in graphs can still be a bit alien and is like a muscle that needs to be exercised)
GraphQL exposes a graph of things in a nice, clear API. At the moment, within the story, when searching for habitable planets a query like this is used:
...and then we scroll in a huge list looking for something interesting... We also scroll past a lot of stars with no planets that are interesting (
planets
being an empty list).Obviously, the answer here is to make a query like this, instead:
(in other words, get all of the interesting planets, and for those planets that are interesting get their parent star so you know where to go and how far away it is)
(ideally also add a way to filter for hazards in the Planets query)
It'd be great to work this into the story somehow: make the user first do the dumb query, then tell them about the smart one. It'd be a great opportunity to learn.
(honestly, I feel kind of silly for not having thought about this before; I guess that in itself is a good demonstration of how thinking in graphs can still be a bit alien and is like a muscle that needs to be exercised)