Before you begin
If you find bugs in this training or have suggestions, create an issue or email contact@bitovi.com.
Overview
In GraphQL 101, you built an API for a fictional insurance company. It works, but it isn’t ready for real users yet. It returns every claim in one response, it accepts dates that don’t exist, it tells anyone who asks exactly how it’s built, anyone can issue a policy, and nothing stops a client from sending a query big enough to slow it down.
This course fixes those problems, one section and exercise at a time.
After this course, you’ll be able to:
- Paginate long lists with cursor-based connections
- Use a custom scalar from a library to reject invalid values
- Return errors that clients can act on
- Protect an API from leaking its details, and from expensive queries
- Decide who can see and change which data
- Mark how long data can be cached, and cache repeated queries on the server
- Explain how subscriptions push live updates to clients
- Describe what else changes when a GraphQL API runs in production
Prerequisites
This course assumes you’ve completed GraphQL 101, or are comfortable writing queries, mutations, schemas, and resolvers.
Outline
- Course Setup: create the course Codespace and start the API
- The Course Data: the policyholders, policies, and claims the API starts with
- Pagination: return claims one page at a time with cursors and connections
- Custom Scalars: replace plain-string dates with a date type that rejects invalid dates
- Error Handling: return coded errors for mistakes, and typed results for problems the user needs to see
- Security: turn off introspection, hide schema details from errors, and limit page size and query depth
- Authorization: decide who can see and change which data, and let only agents issue policies
- Caching: mark how long data can be cached, and serve repeated queries from a server-side cache
- Subscriptions: how a server pushes live updates to clients, and when to use them instead of polling
- Performance and Hosting: persisted queries, compression, monitoring, health checks, and a production checklist
- Wrapping Up: what you changed, and where to go next