GraphQL N+1 Problem: From 2000 Queries to 3
GraphQL makes it stupidly easy to write queries that murder your database. Our homepage was hitting the database 2,031 times per page load. Yeah. Here’s how we got it down to 3 queries without changing the API. The query that looked innocent query Homepage { posts { id title author { id name avatar } comments { id text author { name } } } } Looks fine. Perfectly reasonable GraphQL query. Returns 10 posts with their authors and comments. ...