Course Outline - Intro to GraphQL

Day 1

  • GraphQL is a query language and a type system
  • Unlike REST, GraphQL uses a single endpoint
  • The simplest type: scalars
  • Can add comments to a query
  • Types: Scalars, Objects, Lists
  • GraphQL playground: ctrl+space to show available fields; cmd+click to GTD
  • A GraphQL API can be queried using plain HTTP POST (curl/fetch)
  • Schema Definition Language (SDL)
  • Building a GraphQL server: typeDefs and resolvers
  • Deeply nested field selections
  • Query args (e.g. task ID)
  • Aliases (e.g. same field with different params)
  • Multiple queries within a single request
  • Argument/Parameter Defaults
  • Named Queries (typically use UpperCamelCase)
  • Mutations (e.g. createAccount)
  • Query variables
  • Async resolvers; persisting data to a database

Day 2

  • Custom resolver chains for deep nesting and circular relationships
  • Context, headers and auth
  • __typename field implicit on all types
  • Frontend:
  • Apollo Client and React
  • Tagged template literals and gql``
  • Using variables to pass dynamic input
  • Params received at `mutation()` level
  • Using React hooks; useQuery and useMutation
  • Refresh a query after a mutation
  • Mutations for authentication
  • Context in Apollo Server
  • Fragments