
GraphQL: The Query Tax
The Invoice — Episode 15 "Query exactly what you need! One endpoint! No over-fetching!" Splendid. Let us examine what you are actually paying for. In 2012, Facebook had a problem: hundreds of microservices, a mobile News Feed, constrained bandwidth. They built GraphQL to solve it. The solution was brilliant. For Facebook. You have a REST API with sensible endpoints and a fetch() call. But do carry on. The N+1 Invoice Fetch 25 users with their posts. One query fetches users. Twenty-five resolvers fetch posts. That is 26 database queries for one API call. The fix: DataLoader, a batching utility you must implement yourself. It is not built in. It is homework. Without it, a relation-heavy GraphQL endpoint performs measurably worse than the REST equivalent it was meant to replace. The Caching Invoice REST uses HTTP caching: ETags, Cache-Control, CDN layers. GET requests to unique URLs, cacheable by design. GraphQL uses POST to a single endpoint. Every query, every mutation, one URL. HTTP ca
Continue reading on Dev.to Webdev
Opens in a new tab




