Skip to content
Tutorials Center
My learning

Topics

GraphQL Tutorial

Learn GraphQL step by step: 37 lessons in 10 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is GraphQL? GraphQL is a query language for APIs where the client names exactly the fields it needs. Learn the problem it solves, its four parts and how a query runs.
  2. 2 GraphQL vs REST Compare GraphQL and REST with the same data: round trips, payload size, versioning, caching and tooling, plus when plain REST is still the better choice.
  3. 3 Your First Query Read and write your first GraphQL query: operations, selection sets and fields, the data and errors envelope, and how a query travels as JSON over POST.
  4. 4 GraphiQL, Playground and Sandbox Tools Compare GraphiQL, GraphQL Playground, Apollo Sandbox, Insomnia and Postman: the editor, variables and headers panes, history, the schema explorer, embedding, and turning tools off in production.
  5. 5 Setting Up a Server: Express, Apollo Server and Yoga Set up a GraphQL server in Node.js step by step: install, write typeDefs and resolvers, start Apollo Server or GraphQL Yoga, mount on Express, and test the endpoint with curl.

Writing Queries

  1. 6 Fields, Arguments and Nested Selections Learn how GraphQL fields work: scalar and object fields, nested selections through relationships, arguments on any field and default values.
  2. 7 Aliases and Fragments Use GraphQL aliases to request the same field twice and fragments to stop repeating selections. Covers named and inline fragments with type conditions.
  3. 8 Variables and Directives Pass dynamic values safely with GraphQL variables, name your operations, and switch fields on or off with the @include and @skip directives.
  4. 9 Mutations and Subscriptions Learn the three GraphQL operation types: queries read, mutations change data one after another, and subscriptions stream events. Includes runnable stand-ins.

The Schema

  1. 10 Schema Definition Language: Types and Scalars Read and write GraphQL's Schema Definition Language: object types, the five built-in scalars, root types and descriptions, with a runnable SDL parser stand-in.
  2. 11 Lists and Non-Null Types Understand ! and [ ] in GraphQL: the four list/non-null combinations, what null means, and how an error bubbles up to the nearest nullable field.
  3. 12 Enums, Interfaces and Unions Model fixed value sets with enums and shared or alternative shapes with interfaces and unions. Learn __typename and inline fragments with a runnable stand-in.
  4. 13 Input Types, Custom Scalars and Introspection Learn input objects, custom scalars like DateTime, the @deprecated directive and introspection queries (__schema, __type), with runnable stand-ins.

Resolvers and Execution

  1. 14 Resolvers Learn how GraphQL resolvers work: the (parent, args, context, info) signature, default resolvers, field-by-field execution and context, with a runnable executor.
  2. 15 How Execution Works and How Errors Behave Follow a GraphQL request through parse, validate and execute, and learn how field errors, the errors array, null bubbling and serial mutations behave.
  3. 16 The N+1 Problem and DataLoader Why nested GraphQL resolvers fire one query per item, and how batching with a per-request DataLoader cuts hundreds of queries down to two.

Schema Design

  1. 17 Schema Design Best Practices Design a GraphQL schema that lasts: model the domain, name things consistently, write specific mutations with payload types, and avoid flags and JSON blobs.
  2. 18 Pagination: Offset, Cursor and Connections Paginate GraphQL lists the robust way: see why offsets drift, then build cursor pagination with edges, nodes, pageInfo and opaque base64 cursors.
  3. 19 Modeling Errors Decide which failures belong in the top-level errors array and which belong in the schema, and model them with result unions, payload fields and codes.
  4. 20 Global Object Identification and the Node Interface Learn the Node interface and the node(id) query: opaque global IDs, refetching any object by ID, how caches benefit, and what Relay-compatible schemas expect.

Security and Performance

  1. 21 Authentication and Authorization Secure a GraphQL API: authenticate once in HTTP middleware, put the user in context, enforce rules in the business layer, and control access per field.
  2. 22 Query Depth, Complexity and Other Attacks Learn how abusive GraphQL queries bring servers down and how depth limits, cost analysis, timeouts, persisted queries and rate limits defend against them.
  3. 23 Caching and Performance Why HTTP caching is harder with GraphQL, and how persisted queries, response and field caches, normalized client caches and resolver timing fix it.

Clients and Transport

  1. 24 GraphQL over HTTP See exactly what a GraphQL request and response look like on the wire: POST bodies, GET for persisted queries, status codes, CORS, and WebSocket or SSE.
  2. 25 Clients, Apollo and Code Generation Compare plain fetch with Apollo Client, urql and Relay, and learn normalized caching, optimistic updates and generating TypeScript types from a schema.
  3. 26 Subscriptions, Live Updates and File Uploads Compare subscriptions, polling and live queries, learn pub/sub topics and event filtering, and see why file uploads usually happen outside GraphQL.
  4. 27 GraphQL with NestJS See how NestJS turns the GraphQL ideas you know into classes: code-first and schema-first schemas, resolver classes, field resolvers, context, and where to read more.

Evolving and Testing

  1. 28 Testing GraphQL APIs Learn how to test GraphQL APIs: unit-test resolvers, run queries against the schema without HTTP, test auth and errors, and check schema contracts in CI.
  2. 29 Schema Evolution, Federation and Tooling Change a GraphQL schema without breaking clients: additive changes, deprecation, breaking-change detection, registries, federation and field usage.
  3. 30 GraphQL Server Architectures Compare GraphQL server architectures: a server connected to a database, a layer over existing services, the hybrid approach and a backend-for-frontend, with trade-offs and examples.

Projects

  1. 31 Project: A Bookstore Query API Build a read-only GraphQL bookstore API: write the SDL for authors, books and reviews, add resolvers over in-memory data and run nested filtered queries.
  2. 32 Project: A Todo API with Mutations Build a todo API in GraphQL: input objects, mutation payload types, validation errors as data and an optimistic client flow, all as runnable stand-ins.
  3. 33 Project: A Blog with DataLoader and Pagination Build a GraphQL blog API: posts, comments and authors, DataLoader batching with query counting, Relay cursor connections and a Python resolver variant.
  4. 34 Project: A Secured API Layer Combine auth context, role-based field access, depth and cost limits, safe error formatting and tests in one runnable GraphQL security stand-in.

Practice and Review

  1. 35 Practice Exercises with Solutions 15 graded GraphQL exercises: write and fix queries, repair schemas, design a mutation, find the N+1, add pagination and spot nullability bugs.
  2. 36 GraphQL Interview Questions 35 GraphQL interview questions with concise answers: concepts, schema, resolvers, N+1, security, caching, federation and REST, plus runnable stand-ins.
  3. 37 GraphQL Cheat Sheet A one-page GraphQL cheat sheet: query syntax, SDL types and modifiers, directives, operation patterns, error and pagination shapes, pitfalls and lesson links.