GraphQL Foundations
GraphQL is a query language for APIs paired with a type system that describes the data those APIs can return. Instead of calling many fixed URLs and hoping each one gives back the right shape, a client sends one request to a single endpoint and asks for exactly the fields it wants. The server replies with a response shaped to match the request — nothing more, nothing less.
That single idea changes a lot. The data your API can serve becomes a connected graph of types, and a query is simply a path you trace through that graph.
What this module covers
Section titled “What this module covers”This is the foundations module of the course. By the end of it you will be able to read GraphQL, explain why teams reach for it, and reason about how a server turns a query into a response. The five lessons are:
- GraphQL Foundations (you are here) — the big picture and your first live query.
- What is GraphQL — single endpoint, typed schema, client-specified queries.
- GraphQL vs REST — the trade-offs, and when each approach fits.
- The Type System — object types, scalars, root types, and nullability.
- Request Lifecycle — how a request is parsed, validated, and executed.
The whole course is taught with TypeScript. Every code sample is real: the in-browser runner below actually executes GraphQL using the reference implementation, and later lessons spin up a full GraphQL Yoga server you can run yourself.
The shape of a GraphQL system
Section titled “The shape of a GraphQL system”flowchart LR C["Client"] -->|"query: fields it needs"| E["Single GraphQL endpoint"] E --> S["Schema (the contract)"] E --> R["Resolvers (the logic)"] R --> D["Data sources"] E -->|"JSON shaped like the query"| C
A client builds a query describing the fields it needs. The server holds a schema (the contract) and a set of resolver functions (the logic). It checks the query against the schema, runs the resolvers to gather data, and returns a response that mirrors the query’s shape.
Your first real query
Section titled “Your first real query”Below is a working GraphQL example. It defines a tiny schema with one field, greeting, provides a function to resolve it, and runs a query. Press Run and watch the actual GraphQL engine produce a JSON result in the output panel.
Notice the result is wrapped in a data key, and inside it the field name greeting maps to the value the resolver returned. The response is predictable because it follows the query. Try changing the name argument, or the field, and run it again.