Queries & Resolvers
Arguments & Input Types
- Scott explains that enums are a set of discrete values that allow limiting a field to a few different options, and demonstrates how to add an enum to a type. - https://static.frontendmasters.com/resources/2019-10-14-full-stack-graphql/intro-to-server-graphql.pdf
- Scott explains that if there are two or more types with common fields, an interface allows types to share fields, and allows the client to make one query instead of multiple when looking for a field. An interface can resolve all the types that belongs to it.
- Scott answers questions from the audience regarding interfaces and data sources, how to uncover the type of a type, and the GraphQL syntax.
- Scott explains that unions are similar to interfaces, because they give access to types. However, unlike interfaces, they can access types that have no fields in common with a single query. Questions from the audience are answered.
- Scott explains that in GraphQL, APIs are set of nodes linked to other nodes, and defines a relationship to be adding a type as a field value on another type.
- Scott demonstrates how to use field level resolvers to write relationships between types.
- Students are instructed to add new fields on types that reference other types and create resolvers for field types that point to other types.
- Scott live codes the first part of the solution to the relationships exercise by first adding new fields to different types.
- Scott continues to live code the solution to the relationships exercise by adding field resolvers, and making the querying of data possible.
- Scott answers questions from the audience regarding queries in GraphQL, field level resolvers, and the rthe order queries run in.
- Scott demonstrates how to add authentication to an Apollo server, and explains that the level of authentication depends on what needs to be protected within the schema. Request level caching to avoid querying the database each time is also discussed.