From Design to Production: Creating Production-Ready GraphQL APIs
Table of Contents
- Production Ready GraphQL
- Notes
Production Ready GraphQL
An Introduction to GraphQL
[ ]An Introduction to GraphQL[ ]One-Size-Fits-All[ ]Let’s Go Back in Time[ ]Enter GraphQL[ ]Type System[ ]Introspection
GraphQL Schema Design
[ ]What Makes an API Great?[ ]Design First[ ]Client First[ ]Naming[ ]Descriptions[ ]Use the Schema, Luke![ ]Expressive Schemas[ ]Specific or Generic[ ]The Relay Specification[ ]Lists & Pagination[ ]Sharing Types[ ]Global Identification[ ]Nullability[ ]Abstract Types[ ]Designing for Static Queries[ ]Mutations[ ]Fine-Grained or Coarse-Grained[ ]Errors[ ]Schema Organization[ ]Asynchronous Behavior[ ]Data-Driven Schema vs Use-Case-Driven Schema
Implementing GraphQL Servers
Take-away:
- design, code, schema first approaches
- SDL generation audits
- secretField: SecretType @featureFlagged(name: "secret")
- mutating the context object
- how to audit the query root
- metadata on types
- security and calculate complexity with dry run
- REDACTED tooling
[X]GraphQL Server Basics[ ]Code First vs SchemaFirst[ ]Generating SDL Artifacts[ ]Resolver Design[ ]Schema Metadata[ ]Multiple Schemas[ ]Modular Schemas[ ]Testing
Servers are created given a type definition and a runtime.
Resolvers:
function resolveName(parent, arguments, context) { return parent.name; } resolveName({name: 'Jason'});
query {
user(id: "1234") {
name
}
}
Resolvers cascade from the root.
digraph G {
resolver -> {
root
gco
}
}
Schema-first approaches allow for the definition of types but without any business logic.
This requires creating a root with a resolver as well as the schema with the root resolver (as compared with a secondary resolver?).
const root = { hello: () => { return 'Hello' } } graphql(schema, '{ hello }', root). then((resp) => { console.log(resp); });
Resolvers
- Keep business logic out of resolvers
- Immmutable context
- No field ordering dependency
Tooling and Workflow
- schema doctor
- mocking
- feature flags
Security
[ ]Rate Limiting[ ]Blocking Abusive Queries[ ]Timeouts[ ]Authentication[ ]Authorization[ ]Blocking Introspection[ ]Persisted Queries
Performance & Monitoring 120
[ ]Monitoring[ ]The N+1 Problem and the Dataloader Pattern[ ]Caching[ ]Compiled Queries
Tooling 142
[ ]Linting[ ]Analytics
Workflow 147
[ ]Design[ ]Review[ ]Development[ ]Publish[ ]Analyze Ship
Public GraphQL APIs 151
[ ]Is GraphQL a Good Choice for Public APIs[ ]Lack of Conventions[ ]With Great Power comes Great Responsibility
GraphQL in a Distributed Architecture 155
[ ]GraphQL API Gateway[ ]GraphQL as a BFF[ ]Service Communication
Versioning 170
[ ]API Versioning is Never Fun[ ]Versioning GraphQL is Possible[ ]Continuous Evolution[ ]Change Management
Documenting GraphQL APIs 178
[ ]Documentation Generators[ ]The What, Not Just the How[ ]Workflows and Use Cases[ ]Example / Pre-Made Queries[ ]Changelogs[ ]Upcoming Changes
Migrating From Other API Styles 183
[ ]Generators[ ]REST & GraphQL Alongside