DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
← From Beginner to Expert in Fundamentals of Frontend
  • How the Web Works
  • Browsers: The Engines
  • Networking & Latency
  • HTTPS & TLS Handshake
  • CDNs & Edge Computing
  • WebSockets & WebRTC
  • RESTful Architecture
  • GraphQL Architecture
  • CORS (Cross-Origin Resource Sharing)
  • Load Balancing
  • Critical Rendering Path Deep Dive
  • DOM vs. CSSOM Construction
  • The Rendering Engine: Layout, Paint, Compositing
  • JavaScript Engine: V8 Internals
  • The Event Loop: Macro vs. Micro Tasks
  • Garbage Collection
  • Browser Storage Architecture
  • Service Workers & PWAs
  • Web Workers: Multi-Threading
← From Beginner to Expert in Fundamentals of Frontend

GraphQL Architecture

20 min read
GraphQLSchemaResolversQueriesMutationsSubscriptionsOver-fetching

GraphQL: A Query Language for Your API

GraphQL was created by Facebook in 2012 to solve the over-fetching and under-fetching problems of REST APIs. Instead of multiple endpoints, you have one endpoint and the client specifies exactly what data it needs.

Core Concepts

Schema Definition Language (SDL)

The schema is the contract between client and server. It defines types, queries, and mutations:

Queries vs. Mutations vs. Subscriptions

OperationPurposeHTTP Analogy
QueryRead dataGET
MutationWrite/update dataPOST/PUT/DELETE
SubscriptionReal-time updatesWebSocket

REST vs. GraphQL Trade-offs

AspectRESTGraphQL
EndpointsMany (/users, /posts)Single (/graphql)
Data fetchingFixed response shapeClient specifies fields
CachingHTTP caching (easy)Complex (needs client-side cache)
Versioning/v1, /v2Evolve schema, deprecate fields
Learning curveLowHigher
File uploadsNative (multipart)Complex (spec extension)

The N+1 Problem in GraphQL

If a query fetches 100 users and each user has posts, a naive resolver would make 100 separate database queries for posts. The solution is DataLoader — a utility that batches and caches database lookups within a single request.

When to Use GraphQL

  • Multiple clients (web, mobile, TV) needing different data shapes
  • Complex, nested data relationships
  • Rapid frontend iteration without backend changes

When NOT to Use GraphQL

  • Simple CRUD APIs with few clients
  • Heavy file upload requirements
  • When HTTP caching is critical

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.