GraphQL

Intermediate · Roadmap · 59 lessons · 9 groups

GraphQL from the schema up — the type system, queries, mutations and subscriptions, building a server with resolvers and DataLoader, schema design and pagination, Apollo Client and other clients, security and performance, and federation and production. API-style theory stays in api-design and the language in javascript. Fifty-nine lessons.

0%

Not started

Nothing saved yet. Progress is kept in this browser until you sign in.

Start the path

Getting started · 5

The schema and type system · 8

Querying · 7

Mutations and subscriptions · 5

Building a server · 8

Schema design · 7

Clients · 6

Security and performance · 6

Federation and production · 7

01What GraphQL is and why it existsGraphQL is a typed query language for APIs where the client names the fields it wants, from the problem it solved at Facebook to a first run in graphql-js.Beginner · 11 min02GraphQL vs RESTCompare GraphQL and REST on fetching, versioning, caching, errors and tooling, and learn when each one is the better fit rather than picking a side.Beginner · 5 min03Your first query in GraphiQLStart a GraphQL Yoga server, open its built-in GraphiQL explorer, read the docs panel, write a query with autocomplete, and use variables and headers.Beginner · 7 min04GraphQL over HTTPSee what actually crosses the wire in a GraphQL request, from the JSON body of a POST to GET queries, status codes and the response media type.Beginner · 4 min05The GraphQL ecosystemA map of the GraphQL tool landscape, with servers, clients, explorers, code generators, gateways and where each fits, so the rest of the roadmap has a frame.Beginner · 4 min01Schema definition languageRead and write GraphQL's schema definition language: type declarations, descriptions, the Query root type, extend, and what the parser can and cannot catch.Beginner · 3 min02Scalar types and custom scalarsThe five built-in GraphQL scalars, how input and output coercion works, and how to write a DateTime custom scalar with serialize, parseValue and parseLiteral.Intermediate · 10 min03Object types and fieldsObject types and their fields are the core of a GraphQL schema, including nesting, fields with arguments, computed fields, and how a field maps to a resolver.Beginner · 1 min04Non-null and listsHow the ! and [] modifiers combine into four list types, how null propagates up to the nearest nullable parent, and how to choose between nullable and required.Intermediate · 6 min05EnumsDefine a fixed set of allowed values with a GraphQL enum, see how names differ from internal values, how enums are validated, and how to deprecate a value.Beginner · 1 min06InterfacesUse an interface when several object types share fields, query it with inline fragments and __typename, and how the server resolves the concrete type.Intermediate · 1 min07UnionsModel a field that can return one of several unrelated object types with a GraphQL union, query it with inline fragments, and use unions for result types.Intermediate · 7 min08Input typesUse input object types to group arguments into one structured value, with defaults, nested inputs, required fields, and the oneOf directive for either-or input.Intermediate · 2 min01Fields and selection setsLearn the anatomy of a GraphQL query, from the operation to nested selection sets, how fields map to the response, and the rules the validator enforces.Beginner · 3 min02ArgumentsPass arguments to GraphQL fields to choose, filter and limit data, with defaults, required arguments, enum and ID arguments, and how the validator checks them.Beginner · 1 min03AliasesRename fields in a GraphQL response and query the same field twice with different arguments using aliases, plus how they resolve field conflicts in validation.Beginner · 5 min04FragmentsReuse field selections with named fragments, pick type-specific fields with inline fragments, and see how the validator checks type conditions and cycles.Intermediate · 3 min05Variables and operation namesSend values separately from the query text with typed variables, set defaults, name operations, and pick one operation from a document with several.Beginner · 9 min06DirectivesUse @include and @skip to shape queries, @deprecated to retire fields, and how custom directives are declared but not run by default.Intermediate · 5 min07IntrospectionQuery a GraphQL schema with __schema and __type, understand how GraphiQL and code generators use it, and why production servers often restrict it.Intermediate · 2 min01MutationsWrite data with the Mutation root type, send variables, return the changed object, and see why mutation fields run serially while queries run in parallel.Beginner · 12 min02Designing mutation inputs and payloadsOne input object and one payload type per mutation, expected failures as userErrors, and the difference between an omitted field and an explicit null.Intermediate · 9 min03SubscriptionsA subscription streams results as events happen. Define the root, return an async iterator, publish from a mutation, and filter per client.Intermediate · 1 min04Subscriptions over WebSockets and SSECarry subscriptions over server-sent events with no setup, or WebSockets with graphql-ws, and choose by proxies, auth and connection limits.Intermediate · 5 min05Defer and streamSend a response in pieces: @defer delivers slow fields after the rest, @stream sends list items as they are ready, over a multipart HTTP response.Advanced · 5 min01ResolversA resolver produces one field's value. See how execution walks the query, why default resolvers cover most fields, and how Query.post leads to Post.author.Beginner · 10 min02Context and resolver argumentsEvery resolver receives parent, args, context and info. Build context once per request for the database and current user, and learn what info is for.Intermediate · 1 min03Schema-first and code-firstAuthor one schema two ways: write SDL and attach resolvers, or build types in code with graphql-js. Compare the output and when to pick each.Intermediate · 6 min04A server with GraphQL YogaStand up a GraphQL server with graphql-yoga on Node: schema, resolvers, context, built-in GraphiQL, and a Fetch handler you can test offline.Intermediate · 1 min05Connecting a databasePut SQLite behind resolvers: open the handle once, pass it via context, use parameterised queries, map columns to fields, and use transactions.Intermediate · 13 min06The N+1 problemPer-field resolvers turn one list query into 1 + N database calls. Count the queries, see why GraphQL invites it, and what a fix must do.Intermediate · 16 min07DataLoader and batchingFix N+1 with DataLoader: batch keys from one tick into one query, cache per request, and build loaders in context. 11 queries become 2.Intermediate · 1 min08Errors and partial responsesA response can carry data and errors together. See how a failing field nulls itself or its parent, what errors holds, and why 200 is not success.Intermediate · 35 min01Schema design principlesDesign the schema around what clients need, not your tables: model the domain, name actions for intent, be specific, and keep one graph.Intermediate · 25 min02Naming conventionsNaming habits for a readable schema: PascalCase types, camelCase fields, SCREAMING_SNAKE_CASE enum values, verb-first mutations, Input and Payload suffixes.Intermediate · 25 min03Nullability in practiceDecide where the exclamation mark goes: why fields are nullable by default, how one failing non-null field blanks a response, what to promise.Intermediate · 23 min04Pagination: offset and cursorPage a list with limit and offset or an opaque cursor. See offset repeat items, measure deep-page cost, and build a keyset cursor.Intermediate · 26 min05Relay connectionsThe Relay connection pattern: a connection type with edges, a cursor per edge and pageInfo, with a working Yoga resolver over ten posts.Intermediate · 6 min06Global object identificationGive every object a globally unique ID and a Node interface with node(id) so clients can refetch anything by ID. Built and run on Yoga.Advanced · 17 min07Evolving a schema without versionsChange a schema without a v2: add fields freely, deprecate before removing, tell breaking changes from safe ones, and check usage first.Advanced · 30 min01Calling GraphQL with fetchA GraphQL request is one HTTP POST with a JSON body. Send queries and variables with plain fetch, read the errors array, and see what a client adds.Beginner · 7 min02Apollo Client basicsSet up ApolloClient with an HttpLink and an InMemoryCache, read data with useQuery, and see what the client adds beyond a bare fetch call.Intermediate · 10 min03The Apollo cacheHow InMemoryCache normalizes responses into entities keyed by typename and id, why one edit shows up everywhere, and how keyFields and eviction work.Intermediate · 8 min04Mutations and optimistic UI on the clientRun mutations with Apollo Client, keep the cache current with refetchQueries or update, and show results early with optimisticResponse.Intermediate · 4 min05urql and RelayTwo alternatives to Apollo Client: urql with its small core and document cache, and Relay with its compiler and fragment colocation for large apps.Intermediate · 14 min06Code generation and typed operationsGenerate TypeScript types and typed document nodes from your schema and operations with GraphQL Code Generator's client preset.Intermediate · 5 min01Authentication and authorizationAuthenticate once per request in the context function, then authorize where data is resolved, with stable error codes and no top-level-only checks.Intermediate · 23 min02Query depth and complexity limitsOne small query can demand millions of nodes in a cyclic schema. Cap depth and estimated cost in GraphQL Yoga with GraphQL Armor, and learn what limits miss.Intermediate · 5 min03Rate limiting and cost analysisRequest counts are the wrong unit for GraphQL. Limit per field, budget by query cost, choose the right key, and enforce limits in front of the server.Intermediate · 9 min04Persisted queriesReplace query text on the wire with a hash. Allowlists block arbitrary operations, automatic persisted queries save bandwidth, and both enable GET caching.Intermediate · 9 min05Disabling introspection and hardeningTurning introspection off hides the schema map but does not secure an API. See what still leaks, then cover GraphiQL, error masking and batching.Intermediate · 19 min06Caching GraphQLWhy one POST URL defeats HTTP caching, and the layers that work instead: client cache, DataLoader, server response cache with invalidation, and CDN.Intermediate · 9 min01Schema stitching and federationTwo ways to present several GraphQL services as one schema: stitching merges them in a gateway, federation has each service declare how types join.Intermediate · 3 min02Apollo Federation basicsBuild two subgraphs sharing a Product entity with @key, resolve it through _entities, and compose them into a supergraph with Rover.Intermediate · 5 min03The router and the supergraphThe router is the endpoint clients call. It loads the supergraph, plans each query across subgraphs, fetches in parallel or sequence, and merges results.Intermediate · 8 min04Testing a GraphQL APITest a schema by executing real queries against it, directly with graphql() and through yoga.fetch, including errors, auth and schema snapshots.Intermediate · 12 min05Observability and tracingOne URL and mostly 200 responses hide GraphQL problems. Add per-operation metrics, OpenTelemetry resolver traces, and error tracking that reads errors.Intermediate · 13 min06Schema registry and CI checksGate every schema change in CI. Diff against the published schema with GraphQL Inspector, fail on breaking changes, and see what a registry adds.Intermediate · 4 min07Deploying GraphQLA GraphQL server is a fetch handler that runs on Node or the edge. Configure by environment, add health checks, and roll out schema changes safely.Intermediate · 2 min

Getting started

5 lessons

  1. 01 / 05What GraphQL is and why it existsGraphQL is a typed query language for APIs where the client names the fields it wants, from the problem it solved at Facebook to a first run in graphql-js.11 min
  2. 02 / 05GraphQL vs RESTCompare GraphQL and REST on fetching, versioning, caching, errors and tooling, and learn when each one is the better fit rather than picking a side.5 min
  3. 03 / 05Your first query in GraphiQLStart a GraphQL Yoga server, open its built-in GraphiQL explorer, read the docs panel, write a query with autocomplete, and use variables and headers.7 min
  4. 04 / 05GraphQL over HTTPSee what actually crosses the wire in a GraphQL request, from the JSON body of a POST to GET queries, status codes and the response media type.4 min
  5. 05 / 05The GraphQL ecosystemA map of the GraphQL tool landscape, with servers, clients, explorers, code generators, gateways and where each fits, so the rest of the roadmap has a frame.4 min

The schema and type system

8 lessons

  1. 01 / 08Schema definition languageRead and write GraphQL's schema definition language: type declarations, descriptions, the Query root type, extend, and what the parser can and cannot catch.3 min
  2. 02 / 08Scalar types and custom scalarsThe five built-in GraphQL scalars, how input and output coercion works, and how to write a DateTime custom scalar with serialize, parseValue and parseLiteral.10 min
  3. 03 / 08Object types and fieldsObject types and their fields are the core of a GraphQL schema, including nesting, fields with arguments, computed fields, and how a field maps to a resolver.1 min
  4. 04 / 08Non-null and listsHow the ! and [] modifiers combine into four list types, how null propagates up to the nearest nullable parent, and how to choose between nullable and required.6 min
  5. 05 / 08EnumsDefine a fixed set of allowed values with a GraphQL enum, see how names differ from internal values, how enums are validated, and how to deprecate a value.1 min
  6. 06 / 08InterfacesUse an interface when several object types share fields, query it with inline fragments and __typename, and how the server resolves the concrete type.1 min
  7. 07 / 08UnionsModel a field that can return one of several unrelated object types with a GraphQL union, query it with inline fragments, and use unions for result types.7 min
  8. 08 / 08Input typesUse input object types to group arguments into one structured value, with defaults, nested inputs, required fields, and the oneOf directive for either-or input.2 min

Querying

7 lessons

  1. 01 / 07Fields and selection setsLearn the anatomy of a GraphQL query, from the operation to nested selection sets, how fields map to the response, and the rules the validator enforces.3 min
  2. 02 / 07ArgumentsPass arguments to GraphQL fields to choose, filter and limit data, with defaults, required arguments, enum and ID arguments, and how the validator checks them.1 min
  3. 03 / 07AliasesRename fields in a GraphQL response and query the same field twice with different arguments using aliases, plus how they resolve field conflicts in validation.5 min
  4. 04 / 07FragmentsReuse field selections with named fragments, pick type-specific fields with inline fragments, and see how the validator checks type conditions and cycles.3 min
  5. 05 / 07Variables and operation namesSend values separately from the query text with typed variables, set defaults, name operations, and pick one operation from a document with several.9 min
  6. 06 / 07DirectivesUse @include and @skip to shape queries, @deprecated to retire fields, and how custom directives are declared but not run by default.5 min
  7. 07 / 07IntrospectionQuery a GraphQL schema with __schema and __type, understand how GraphiQL and code generators use it, and why production servers often restrict it.2 min

Mutations and subscriptions

5 lessons

  1. 01 / 05MutationsWrite data with the Mutation root type, send variables, return the changed object, and see why mutation fields run serially while queries run in parallel.12 min
  2. 02 / 05Designing mutation inputs and payloadsOne input object and one payload type per mutation, expected failures as userErrors, and the difference between an omitted field and an explicit null.9 min
  3. 03 / 05SubscriptionsA subscription streams results as events happen. Define the root, return an async iterator, publish from a mutation, and filter per client.1 min
  4. 04 / 05Subscriptions over WebSockets and SSECarry subscriptions over server-sent events with no setup, or WebSockets with graphql-ws, and choose by proxies, auth and connection limits.5 min
  5. 05 / 05Defer and streamSend a response in pieces: @defer delivers slow fields after the rest, @stream sends list items as they are ready, over a multipart HTTP response.5 min

Building a server

8 lessons

  1. 01 / 08ResolversA resolver produces one field's value. See how execution walks the query, why default resolvers cover most fields, and how Query.post leads to Post.author.10 min
  2. 02 / 08Context and resolver argumentsEvery resolver receives parent, args, context and info. Build context once per request for the database and current user, and learn what info is for.1 min
  3. 03 / 08Schema-first and code-firstAuthor one schema two ways: write SDL and attach resolvers, or build types in code with graphql-js. Compare the output and when to pick each.6 min
  4. 04 / 08A server with GraphQL YogaStand up a GraphQL server with graphql-yoga on Node: schema, resolvers, context, built-in GraphiQL, and a Fetch handler you can test offline.1 min
  5. 05 / 08Connecting a databasePut SQLite behind resolvers: open the handle once, pass it via context, use parameterised queries, map columns to fields, and use transactions.13 min
  6. 06 / 08The N+1 problemPer-field resolvers turn one list query into 1 + N database calls. Count the queries, see why GraphQL invites it, and what a fix must do.16 min
  7. 07 / 08DataLoader and batchingFix N+1 with DataLoader: batch keys from one tick into one query, cache per request, and build loaders in context. 11 queries become 2.1 min
  8. 08 / 08Errors and partial responsesA response can carry data and errors together. See how a failing field nulls itself or its parent, what errors holds, and why 200 is not success.35 min

Schema design

7 lessons

  1. 01 / 07Schema design principlesDesign the schema around what clients need, not your tables: model the domain, name actions for intent, be specific, and keep one graph.25 min
  2. 02 / 07Naming conventionsNaming habits for a readable schema: PascalCase types, camelCase fields, SCREAMING_SNAKE_CASE enum values, verb-first mutations, Input and Payload suffixes.25 min
  3. 03 / 07Nullability in practiceDecide where the exclamation mark goes: why fields are nullable by default, how one failing non-null field blanks a response, what to promise.23 min
  4. 04 / 07Pagination: offset and cursorPage a list with limit and offset or an opaque cursor. See offset repeat items, measure deep-page cost, and build a keyset cursor.26 min
  5. 05 / 07Relay connectionsThe Relay connection pattern: a connection type with edges, a cursor per edge and pageInfo, with a working Yoga resolver over ten posts.6 min
  6. 06 / 07Global object identificationGive every object a globally unique ID and a Node interface with node(id) so clients can refetch anything by ID. Built and run on Yoga.17 min
  7. 07 / 07Evolving a schema without versionsChange a schema without a v2: add fields freely, deprecate before removing, tell breaking changes from safe ones, and check usage first.30 min

Clients

6 lessons

  1. 01 / 06Calling GraphQL with fetchA GraphQL request is one HTTP POST with a JSON body. Send queries and variables with plain fetch, read the errors array, and see what a client adds.7 min
  2. 02 / 06Apollo Client basicsSet up ApolloClient with an HttpLink and an InMemoryCache, read data with useQuery, and see what the client adds beyond a bare fetch call.10 min
  3. 03 / 06The Apollo cacheHow InMemoryCache normalizes responses into entities keyed by typename and id, why one edit shows up everywhere, and how keyFields and eviction work.8 min
  4. 04 / 06Mutations and optimistic UI on the clientRun mutations with Apollo Client, keep the cache current with refetchQueries or update, and show results early with optimisticResponse.4 min
  5. 05 / 06urql and RelayTwo alternatives to Apollo Client: urql with its small core and document cache, and Relay with its compiler and fragment colocation for large apps.14 min
  6. 06 / 06Code generation and typed operationsGenerate TypeScript types and typed document nodes from your schema and operations with GraphQL Code Generator's client preset.5 min

Security and performance

6 lessons

  1. 01 / 06Authentication and authorizationAuthenticate once per request in the context function, then authorize where data is resolved, with stable error codes and no top-level-only checks.23 min
  2. 02 / 06Query depth and complexity limitsOne small query can demand millions of nodes in a cyclic schema. Cap depth and estimated cost in GraphQL Yoga with GraphQL Armor, and learn what limits miss.5 min
  3. 03 / 06Rate limiting and cost analysisRequest counts are the wrong unit for GraphQL. Limit per field, budget by query cost, choose the right key, and enforce limits in front of the server.9 min
  4. 04 / 06Persisted queriesReplace query text on the wire with a hash. Allowlists block arbitrary operations, automatic persisted queries save bandwidth, and both enable GET caching.9 min
  5. 05 / 06Disabling introspection and hardeningTurning introspection off hides the schema map but does not secure an API. See what still leaks, then cover GraphiQL, error masking and batching.19 min
  6. 06 / 06Caching GraphQLWhy one POST URL defeats HTTP caching, and the layers that work instead: client cache, DataLoader, server response cache with invalidation, and CDN.9 min

Federation and production

7 lessons

  1. 01 / 07Schema stitching and federationTwo ways to present several GraphQL services as one schema: stitching merges them in a gateway, federation has each service declare how types join.3 min
  2. 02 / 07Apollo Federation basicsBuild two subgraphs sharing a Product entity with @key, resolve it through _entities, and compose them into a supergraph with Rover.5 min
  3. 03 / 07The router and the supergraphThe router is the endpoint clients call. It loads the supergraph, plans each query across subgraphs, fetches in parallel or sequence, and merges results.8 min
  4. 04 / 07Testing a GraphQL APITest a schema by executing real queries against it, directly with graphql() and through yoga.fetch, including errors, auth and schema snapshots.12 min
  5. 05 / 07Observability and tracingOne URL and mostly 200 responses hide GraphQL problems. Add per-operation metrics, OpenTelemetry resolver traces, and error tracking that reads errors.13 min
  6. 06 / 07Schema registry and CI checksGate every schema change in CI. Diff against the published schema with GraphQL Inspector, fail on breaking changes, and see what a registry adds.4 min
  7. 07 / 07Deploying GraphQLA GraphQL server is a fetch handler that runs on Node or the edge. Configure by environment, add health checks, and roll out schema changes safely.2 min
Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark