GraphQL Introduction

GraphQL is a query language for APIs. Clients ask for exactly the data they need β€” no more, no less β€” in a single request against a strongly-typed schema.

The core idea

You define a typed schema describing your data and operations. Clients send queries shaped like the data they want, and the response comes back in that exact shape.

query.graphql
query {
  user(id: "1") {
    name
    posts { title }
  }
}

What makes it different

  • One endpoint β€” all queries go to a single URL (usually /graphql).
  • Client-driven β€” the client picks the fields; no fixed response per endpoint.
  • Strongly typed β€” the schema is a contract, validated automatically.
  • Self-documenting β€” tools introspect the schema for docs and autocomplete.

The ecosystem

Created at Facebook and now an open standard, GraphQL has a rich ecosystem: Apollo (server & client), GraphQL Yoga, Relay, and code-first frameworks like the one in the NestJS course.

When to reach for it

Note: GraphQL shines when clients need flexible, varied slices of related data (mobile apps, complex UIs, many consumers). For simple CRUD or when HTTP caching matters most, REST is often simpler β€” the next chapter compares them fairly.
Tip: Think of GraphQL as letting the *client* write the SELECT: instead of the server deciding what each endpoint returns, the client requests precisely the fields it will use.
Free preview. Sign in and subscribe to unlock all 809 lessons across 25 courses.
GraphQL Introduction β€” GraphQL | Full Stack Learning Simplified