Table of Contents

1. Concepts

GraphQL is a specification for an API query language and server engine capable of executing such queries.

  • Document has many operations or fragments (executables) or type system information
  • Operation types may be queries, mutations, and subscriptions

1.1. Contrasting REST

  • partials
  • versions
  • fields

1.2. Parsing

  • Whitespace and line terminations are as expected
  • Tokens
  • The "query" keyword and name may not be present for [{ field }]

1.3. Operations

  • query: read-only fetch
  • mutation: write + fetch
  • subscription: response to source events

1.4. Selection Sets

{
  id
  firstName
  lastName
}
  • Can contain aliases

1.5. Types

  • ID
  • String
  • DateTime

1.6. Schemas

The SDL provides a language for describing the type system for GraphQL.

1.7. Schema Root

1.8. Fragments

query withFragments {
  user(id: 4) {
    friends(first: 10) {
      ...friendFields
    }
    mutualFriends(first: 10) {
      ...friendFields
    }
  }
}

fragment friendFields on User {
  id
  name
  profilePic(size: 50)
}

1.9. Queries

1.9.1. Variables

1.10. Mutations

1.11. Enums

1.12. Abstract Types

interface Animal {
  name: String!
}

interface Plant {
  genus: String!
  species: String!
}

1.13. Unions

union Entity = Plant | Animal

2. Federation

3. Maintaining GraphQL

4. Tools

4.1. GraphQL Playground

4.3. Mocking

npm install -g get-graphql-schema graphql-cli graphql-faker
mkdir t && cd t
# graphql init

get-graphql-schema https://$HOST/graphql/ > schema.graphql
graphql-faker schema.graphql
open http://localhost:9002/editor

5. Reading

5.1. Production Ready GraphQL

5.1.1. An Introduction to GraphQL

  • [ ] An Introduction to GraphQL
  • [ ] One-Size-Fits-All
  • [ ] Let’s Go Back in Time
  • [ ] Enter GraphQL
  • [ ] Type System
  • [ ] Introspection

5.1.2. 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

5.1.3. Implementing GraphQL Servers

  • [ ] GraphQL Server Basics
  • [ ] Code First vs SchemaFirst
  • [ ] Generating SDL Artifacts
  • [ ] Resolver Design
  • [ ] Schema Metadata
  • [ ] Multiple Schemas
  • [ ] Modular Schemas
  • [ ] Testing

5.1.4. Security

  • [ ] Rate Limiting
  • [ ] Blocking Abusive Queries
  • [ ] Timeouts
  • [ ] Authentication
  • [ ] Authorization
  • [ ] Blocking Introspection
  • [ ] Persisted Queries

5.1.5. Performance & Monitoring

  • [ ] Monitoring
  • [ ] The N+1 Problem and the Dataloader Pattern
  • [ ] Caching
  • [ ] Compiled Queries

5.1.6. Tooling

  • [ ] Linting
  • [ ] Analytics

5.1.7. Workflow

  • [ ] Design
  • [ ] Review
  • [ ] Development
  • [ ] Publish
  • [ ] Analyze Ship

5.1.8. Public GraphQL APIs

  • [ ] Is GraphQL a Good Choice for Public APIs
  • [ ] Lack of Conventions
  • [ ] With Great Power comes Great Responsibility

5.1.9. GraphQL in a Distributed Architecture

  • [ ] GraphQL API Gateway
  • [ ] GraphQL as a BFF
  • [ ] Service Communication

5.1.10. Versioning

  • [ ] API Versioning is Never Fun
  • [ ] Versioning GraphQL is Possible
  • [ ] Continuous Evolution
  • [ ] Change Management

5.1.11. Documenting GraphQL APIs

  • [ ] Documentation Generators
  • [ ] The What, Not Just the How
  • [ ] Workflows and Use Cases
  • [ ] Example / Pre-Made Queries
  • [ ] Changelogs
  • [ ] Upcoming Changes

5.1.12. Migrating From Other API Styles

  • [ ] Generators
  • [ ] REST & GraphQL Alongside

6. Videos

7. Conferences

7.1. GraphQL Summit 2020

7.1.2. GraphQL in Production

  • Paypal, Shopify, Priceline, American
  • Invest in tooling
  • Look at the execution
  • Measure timing
  • Public APIs can be difficult
  • How teams roll out GraphQL
  • Schema design shouldn't just map REST
  • Error handling
  • Caching
  • Providence of data and finding owner of data
  • Collaborating on the features with Product and Engineering
  • Duplicated data
  • Be patient when evangelizing GraphQL

Author: Jason Walsh

Created: 2023-10-24 Tue 12:05

Validate