# Title

Table of Contents

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

Contrasting REST

  • partials
  • versions
  • fields

Parsing

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

Operations

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

Selection Sets

  {
    id
    firstName
    lastName
  }
  • Can contain aliases

Types

  • ID
  • String
  • DateTime

Schemas

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

Schema Root

Fragments

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

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

Queries

Variables

Mutations

Enums

Abstract Types

interface Animal {
  name: String!
}

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

Unions

union Entity = Plant | Animal

Federation

Maintaining GraphQL

Tools

GraphQL Playground

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

Reading

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

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

Security

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

Performance & Monitoring

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

Tooling

  • [ ] Linting
  • [ ] Analytics

Workflow

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

Public GraphQL APIs

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

GraphQL in a Distributed Architecture

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

Versioning

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

Documenting GraphQL APIs

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

Migrating From Other API Styles

  • [ ] Generators
  • [ ] REST & GraphQL Alongside

Videos

Conferences

GraphQL Summit 2020

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

j@wal.sh

Last Updated: 2024-10-30 16:43:54