This course has been updated! We now recommend you take the Advanced GraphQL, v2 course.
Table of Contents
Introduction
Introducing Advanced GraphQL
Scott Moss introduces himself and provides a high-level overview of GraphQL APIs.GraphQL API Recap
Scott shows how to use graphql-yoga node module to get the GraphQL server up and running. Given a GraphQL Schema, you will need to create a server the correctly allows a query and mutation based on the schema.GraphQL Recap: Schema Definitions
Scott defines the different parts of the schema including types, queries, and inputs to get GraphQL started.GraphQL Recap: Mutations
After discussing the difference between queries and mutations, Scott codes a basic mutation to add data into the database.Github Token Setup
Scott shows how to generate private Github token to be able to query the Github API in following exercises.GraphQL Recap Exercise
Scott sets up a basic "Hello, World!" exercise to generate a schema and play with queries and mutations.Q&A: Mutation vs. Query & Type vs. Input
Scott talks about mutating the database on the query and recommends against this approach. Then Scott answers a question was asked about using types as inputs and being able to define the types as inputs all the way down.GraphQL Recap Solution
Scott walks through the solution to the GraphQL Recap Exercise using queries and mutations.Querying the Solution
Scott demonstrates querying the solution and discusses different ways to query in GraphQL.Q&A: Multiple Mutations & Batching
Scott discusses optimizing GraphQL using multiple operations and batching.
Resolvers
Introducing Resolvers & Setup
Scott overviews what resolvers are and how they tie into schemas.Code Repository Walkthrough
Scott reviews the code repository and where to find the resolvers.Arguments
While arguments can be different depending on when the resolver was called, resolvers almost always receive four arguments. Scott takes questions from students.Arguments: Context
Scott illustrates context as dependency injectors for resolvers by showing how to use context to share state across your resolvers.Info Object AST
Scott demonstrates info objects, which are raw query information and a query AST inside resolvers.Nested Resolvers Exercise
Scott shows that, when given a query, the types and resolvers need to be created, so the query executes correctly.Nested Resolvers Solution
Scott walks through the solution to the Nested Resolvers Exercise showing how to efficiently implementing the resolvers because resolvers can go on and on and on, creating a tree and become confusing.
Schema
Query Fragments
Scott introduces fragments, which reduce repetitive nature of asking for the same data in the same query.Enums
Scott reviews enums, which are a set of constant values to validate fields on types and inputs.Interfaces
Since types might share common fields, Scott shows how to use interfaces to clean up the repetition in schema definitions.Unions
Scott introduces unions, which are used to return a type that could be one of a collection of types.Unions vs. Interfaces
Scott compares unions and interfaces. Unions are a group of types that do not share fields but need to be queried on whereas Interfaces are more often use in GraphQL because of shared fields.Interfaces & Unions Exercise
In this exercise, students use fragments, unions, and interfaces to clean up repetitive queries and schema.Interfaces & Unions Solution
Scott walks through Interfaces & Unions Exercise showing the proper way to stay DRY with GraphQL.
Performance
Optimizing Resolvers
Scott discusses caching problems with GraphQL and how to use "pre-resolving" to cache the results to avoid extra database calls.Caching in GraphQL
Scott reviews the nature of "pre" resolvers that can separate data access logic to other resolvers which can lead to performance issues.Data Loaders
Since resolvers can access the same data that the previous resolvers might have, Scott talks about how to use data loaders to batch and cache that data, per request.Using Data Loaders
Scott walks through a coding demonstrating on how to use data loaders.Data Loaders Exercise
In this exercise, students use data loaders to speed up your queries.Data Loaders Solution
Scott walks through the solution to the Data Loaders Exercise by showing how to speed up the resolvers' efficiency.GitHub API Data Loaders
In this additional data loader example, Scott shows the solution to using data loader with the GitHub API.
Testing GraphQL
Simplifying Resolvers
Since resolvers are just functions, Scott shows resolvers are more accessible to test when breaking them down.Unit Test Resolvers with Jest
Scott illustrates that GraphQL can run anywhere because a server does not need to test GraphQL server.Integration Test with Jest
Scott demonstrates how to set up an integration test with Jest.Unit & Integration Test Exercise
In this exericse, students code a unit and integration test.Unit & Integration Test Solution
Scott walks through the solution to the Unit & Integration Test Exercise showing how to test GraphQL servers.
Wrapping Up
Schema Stitching
Scott shows how to combine GraphQL APIs from multiple sources, even remote ones.Database to GraphQL
Using prisma, Scott discusses how to turn a database into a GraphQL API.Subscriptions and GraphQL Services
Scott wraps up Advanced GraphQL discussing subscriptions, GraphQL services, and taking questions from students.