MainExamplesHistoryRecommended Reading
Explain Like I'm 5 /Web Technology

What is GraphQL?

Help others learn from this page

GraphQL is a query language and runtime for APIs. Instead of making multiple requests to different endpoints, you make one request asking for exactly the data you need. It's like ordering at a restaurant: instead of getting a fixed meal, you specify exactly what you want.

How It Works:

  1. Single endpoint: One URL for all queries
  2. Query language: Describe the data you want
  3. Get exactly what you need: No over-fetching or under-fetching
  4. Strongly typed: Schema defines what's possible

GraphQL Query Example:

query {
  user(id: 123) {
    name
    email
    posts {
      title
    }
  }
}

Benefits:

  • Efficient: Get only the data you need
  • Flexible: Client controls the response shape
  • Single request: Fetch related data in one query
  • Type-safe: Schema prevents errors
  • Introspection: Can query the schema itself

When to Use:

  • Complex data needs: Different clients need different data
  • Mobile apps: Reduce data transfer
  • Rapid iteration: Frontend can request new fields without backend changes

FAQ

Is GraphQL better than REST?
Not necessarily. REST is simpler and more established. GraphQL is better when you need flexible queries and want to reduce over-fetching.
Do I need GraphQL?
For simple APIs, REST might be enough. GraphQL shines when you have complex data relationships and multiple clients with different needs.

Enjoyed this explanation? Share it!

Last Week in Plain English

Stay updated with the latest news in the world of AI, tech, business, and startups.

Interested in Promoting Your Content?

Reach our engaged developer audience and grow your brand.

Help us expand the developer universe!

This is your chance to be part of an amazing community built by developers, for developers.