This course has been updated! We now recommend you take the Server-Side GraphQL in Node.js course.
Table of Contents
Introduction
Introduction
Scott introduces the course repo, and recommends tools that will be utilized in the course.What is GraphQL?
Scott defines the key points to know about GraphQL.GraphQL vs REST
Scott contrasts GraphQL and REST because the two are often confused.Course Code Overview
Scott goes over the package.json, environment variables, and a brief overview of what the rest of the course repository contains. The context of the API that will be created is also discussed.
GraphQL
GraphQL Basics & Starting the Server
Scott demonstrates how to create simple types in the schema, and starts the server.GraphQL Playground
Scott demonstrates some of the capabilities of the GraphQL playground.GraphQL Exploration Exercise
Students are instructed to set aside 10 minutes to explore the code, and the GraphQL playground.GraphQL Q&A
Questions are asked about the VSCode GraphQL extension, a clarification about the schemas and resolvers, and Apollo server's relation to Express.GraphQL Exploration Review
Scott demonstrates how to create a type that is type String instead of an Object.
Schemas
GraphQL Schemas
Scott contrasts the GraphQL and database schemas.Schema Definition Language
Scott explains why a Schema Definition Language, or SDL, is the best way to create schemas.Scalar & Object Types
Scott describes what scalars are and the object types that exist in GraphQL.Validations: Non Nullable & List
Scott demonstrates how to require that a field be populated by GraphQL.GraphQL Cheat Sheet
Scott references a resource to utilize when constructing a GraphQL Schema.Query & Mutation Types
Scott explains why queries and mutations are instrumental in a functional API.Writing a Mutation Type
Scott demonstrates how to write a mutation with an input type.Create a Schema Exercise
Students are instructed to create a schema that passes several tests that check for fields, queries, and mutations.Create a Schema Solution
Scott live codes the solution to the exercise.GraphQL Schemas Q&A
Questions are asked regarding where the GQL file gets used, if content is required to be returned, what the schema would look like in a real world application,
Resolvers
Resolvers
Scott introduces what Resolvers are, and why they matter.Resolver Arguments
Scott demonstrates how to start writing a resolver that takes a starting object, any arguments from the incoming request, context, and AST of the incoming request.Errors in Resolvers
Scott explains how errors are handled in GraphQL.Implimenting a Resolver
Scott live codes several resolvers to demonstrate how the data is called.Field Type Resolvers
Scott live codes field types underneath the resolvers.Nested Resolvers
Scott demonstrates how resolvers can reference other resolvers and return a value.Relational Data
Scott demonstrates why GraphQL needs to be strongly typed by walking through an example involving relational data.Query Errors
Scott demonstrates what an error looks like as a response from the API.Info Resolver Argument
Scott shows the audience what the info argument looks like to give context to what is meant by an AST.Resolvers Exercise
Students are instructed to create resolvers for the Queries and Mutations on the product type.Resolvers Solution
Scott live codes the solution to the exercise.Resolvers Q&A
Scott answers questions from the audience about clarifications on the last exercise, including how Apollo is processing the schema, extending the current example, and usage of the spread operator in this case.
Interfaces
Interfaces
Scott explains how to utilize interfaces as a base type when types are very similar.Unions
Scott explains how to utilize unions, which allow the user to return more than just one type.Interfaces Exercise
Students are instructed to create an interface from the product type, then create types for each possible type.Interfaces Solution
Scott live codes the solution to the exercise.
Auth
Authentication
Scott introduces several ways that authentication could take place.Authentication Exercise
Students are instructed to authenticate a request, and block requests when appropriate.Authentication Solution
Scott live codes the solution to the exercise.
Advanced Topics
Testing with Jest
Scott gives an overview on how the tests were written for the course.Caching & Performance
Scott gives references to resources, and strategies to handle caching, and improve performance.Dates & Custom Scalars
Scott gives a reference to explore more on dates and custom scalars.Layering GraphQL on REST
Scott gives thoughts on layering GraphQL on to of REST.Sending Multiple Queries
Scott demonstrates how to use an alias to perform two requests on a GraphQL server at the same time.More GraphQL Tools & Services
Scott gives examples of several products that will spin up a GraphQL API for you, tools to make GraphQL easy to work with anywhere, and other resources.