2 Graph thinking with GraphQL

 

This chapter covers

  • Describing the requirements of our business review application
  • Translating requirements into GraphQL type definitions
  • Implementing resolver functions for data fetching for these type definitions, using a naive approach
  • Using Apollo Server to combine our type definitions and resolvers and serve a GraphQL endpoint
  • Querying our GraphQL endpoint with Apollo Studio

In this chapter, we will design a GraphQL API for a business review application. First, we will define the requirements of this application; then, we will describe a GraphQL API that addresses these requirements following a GraphQL-first development approach. We then explore how to implement the data fetching logic for this API. Finally, we explore how to combine our GraphQL type definitions and resolver functions to serve a GraphQL API using Apollo Server and to query it, using Apollo Studio. When building APIs, it is often useful to understand the data domain and the common access patterns—in other words, what are the problems to be solved by the API? The GraphQL-first development approach allows us to build APIs by first considering the data domain and defining a GraphQL schema describing that domain, which then serves as a blueprint for implementing the API.

2.1 Your application data is a graph

2.2 Graphs in GraphQL

2.2.1 API modeling with type definitions: GraphQL-first development

2.2.2 Resolving data with resolvers

2.2.3 Our first resolver

2.3 Combining type definitions and resolvers with Apollo Server

2.3.1 Using Apollo Server

2.3.2 Apollo Studio

2.3.3 Implementing resolvers

2.3.4 Querying using Apollo Studio

2.4 Exercises

Summary