Skip to main content

Command Palette

Search for a command to run...

🎯 GraphQL Explained Like You're 5

Published
β€’1 min read
S

Building AI systems and writing about how they actually work. Master of AI @ University of Technology Sydney. Previously B.Tech CS with focus on IoT. I believe the best way to learn is to explain. That's why I'm documenting tech concepts with simple analogies (@sreekarreddy.com). AWS Certified β€’ Azure AI Certified β€’ Neo4j Professional β€’ Google Data Analytics When not coding: exploring Sydney, working on side projects, and teaching tech to anyone who'll listen.

Order exactly what you want, nothing more

Day 27 of 149

πŸ‘‰ Full deep-dive with code examples


The Custom Order

At most restaurants, you order a whole meal:

  • Burger + fries + drink + salad

But you maybe just wanted the burger! πŸ”

GraphQL lets you order exactly what you need!


REST vs GraphQL

REST (fixed menu):

GET /user/5
Returns: name, email, address, phone, birthday,
         avatar, preferences, history, ...

You get everything, even stuff you don't need!

GraphQL (custom order):

{
  user(id: 5) {
    name
    email
  }
}

You get exactly: name and email. That's it!


The Magic

One endpoint, infinite flexibility:

{
  user(id: 5) {
    name
    posts {
      title
      likes
    }
    friends {
      name
    }
  }
}

Get user + their posts + their friends in ONE request!


When to Use

  • REST: Simple CRUD, standard needs
  • GraphQL: Complex data needs, mobile apps (save bandwidth)

In One Sentence

GraphQL lets you ask for exactly the data you need in one request, nothing more, nothing less.


πŸ”— Enjoying these? Follow for daily ELI5 explanations!

Making complex tech concepts simple, one day at a time.

More from this blog

esreekarreddy

132 posts