| > This is a feature of literally every API... Why aren't you asking this same question about REST queries? Combinatoric explosions of complexity via a single query path are not a feature of every API. > The 'Graph' part of 'GraphQL' means that queries can theoretically request connected nested objects of nearly infinite depth. Thanks for this. > just that MORE JOINS == MORE WORK and MORE PAYLOAD So like SQL but without all the excellent query complexity tools or clarity around what precipitates a join? > Why aren't you asking "why does REST deny clients the right to make as deeply nested queries as they need?" Because RESTful APIs tend not to allow ad hoc graph traversal. When they do, it's because they're tunneling a graph query language. When they do (e.g., ElasticSearch) I (and we, as in the community at large)_DO ask these questions. |
> Because RESTful APIs tend not to allow ad hoc graph traversal.
I think you're taking this graph part too literally. Almost every API has a "graph" of connected objects. GraphQL just makes it so that you can traverse them with a single query. REST endpoints tend to force you to make multiple queries to go back and fetch information about the entities whose IDs or URLs you received in earlier requests – thus the rate limiting. In both cases, combinoratic explosions (and infinite depth) are possible – REST just forces you to explode into more round-trips (and the server is likely doing even more duplicated work than it needs to to fulfill those subsequent requests).
If you wanted to simulate the ease-off aspect of REST requiring clients to return for multiple rate-limited round trips to get the query data they want, you could simply add a timeout in the nested object's GraphQL resolvers that perform self-rate-limiting. Same result but the clients don't need to know about it, they can just wait the same amount of time they'd have had to wait for all the data anyway.