Re:If All You Have Is a Database, Everything Looks Like a Nail
by valenterry on Tuesday December 08, 2020 @06:47AM
(#25344094)
Yeah sure. You can use resource expansion and also field targeting (to only get fields you need), add some typesystem on top of it, make sub-resource-expansion look a bit nicer by... I don't know, creating a small DSL for it. And then standardize documentation and tooling around it.
Voila, now you have your own implementation of GraphQL that might even be better than the original one, who knows. Only one way to find out!
Until then I will continue to use GraphQL wherever it works well. :)
The answer to this problem is resource expansion. Dylan Beattie actually has a nice and somewhat humorous presentation about how to address this with REST interfaces: https://youtu.be/g8E1B7rTZBI
Here's the part that addresses such data access in particular with a social media site example (people who have photos, which have comments etc.): https://youtu.be/g8E1B7rTZBI?t=1807
Sadly, approaches like that and even HATEOAS are not awfully widespread, mostly because of the added complexity and the support by frameworks simply not being quite there.