Learn GraphQL

Typed query language for APIs: clients ask for exactly the data they need

17 lessons · 3 hours · 4 levels · covers GraphQL Spec September 2025 / graphql-js 17

GraphQL is a query language and runtime for APIs: a server publishes a typed schema, and clients send queries that name exactly the fields they want, getting back JSON in the same shape. It is used by web and mobile teams to fetch nested data in one round trip, evolve APIs without versioning, and give frontends a self-documenting contract.

Before you start

GraphQL builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics6 lessons · 1 hour in total
2. PracticalUse it productively at work, with the usual idioms10 lessons · 2 hours in total
3. AdvancedThe less common features, performance and trade-offs14 lessons · 3 hours in total
4. ExpertInternals and the edge cases experts know17 lessons · 3 hours in total

The GraphQL tree

GraphQLWhat GraphQL isWhat GraphQL isQueries and fieldsQueries and fieldsSchema definition languageSchema definitionlanguageArguments and variablesArguments andvariablesMutationsMutationsResolvers: serving a schemaResolvers: serving aschemaFragments, aliases and directivesFragments, aliasesand directivesInterfaces and unionsInterfaces and unionsErrors and partial resultsErrors and partialresultsGraphQL over HTTP and clientsGraphQL over HTTPand clientsnpm and package.jsonnpm andpackage.jsonasync and awaitasync and awaitMaking HTTP requests with fetchMaking HTTPrequests with fetch
Essentials and Practical shown (10 of 17 lessons); the full list is below. Click a lesson to read it.

All 17 lessons, in order

Querying

  1. What GraphQL is · Essentials · 8 min

    A typed schema on the server, queries that name the exact fields on the client, and JSON responses shaped like the query.

  2. Queries and fields · Essentials · 10 min

    Write selection sets, nest them through object fields, and name operations so they are easy to debug.

  3. Arguments and variables · Essentials · 10 min

    Pass arguments to fields and supply their values through typed variables instead of string interpolation.

  4. Mutations · Essentials · 10 min

    Change data with mutation fields that take an input object and return a payload the client can read back.

  5. Fragments, aliases and directives · Practical · 10 min

    Reuse selections with fragments, rename or repeat fields with aliases, and colocate data needs with UI components.

Schemas and types

  1. Schema definition language · Essentials · 12 min

    Describe an API with SDL: object types, the five built-in scalars, enums, lists and non-null markers.

  2. Interfaces and unions · Practical · 12 min

    Model polymorphic data with interfaces (shared fields) and unions (one of several types), and query them with inline fragments.

Building a server

  1. Resolvers: serving a schema · Essentials · 15 min

    Implement a schema with resolver functions that receive parent, args, context and info, and return values or promises.

  2. Errors and partial results · Practical · 12 min

    Read the errors array, understand how null propagates through non-null fields, and decide what errors belong in the schema.

  3. N+1 queries and DataLoader · Advanced · 15 min

    Recognize the N+1 problem caused by per-field resolvers and fix it with per-request batching and caching via DataLoader.

Clients and transport

  1. GraphQL over HTTP and clients · Practical · 12 min

    Send operations as JSON over POST or GET, read the response format, and know what client libraries add on top.

  2. Subscriptions and incremental delivery · Advanced · 12 min

    Push real-time events to clients with subscription operations over WebSockets or server-sent events.

Schema design at scale

  1. Pagination and connections · Advanced · 12 min

    Page through lists with offset or cursor arguments, and understand the Relay connection pattern with edges and pageInfo.

  2. Evolving a schema without versions · Advanced · 12 min

    Add fields freely, deprecate before removing, use @oneOf inputs, and track which clients use what.

  3. Federation and distributed graphs · Expert · 15 min

    Compose one supergraph from many team-owned subgraphs, and know the trade-offs versus schema stitching or a monolith.

Execution and security

  1. Parse, validate, execute · Expert · 15 min

    Follow a request through graphql-js: parsing to an AST, validation rules, coercion and execution with completion.

  2. Securing a GraphQL API · Expert · 15 min

    Defend against expensive queries with depth and cost limits, trusted documents, timeouts and field-level authorization.