10 Building GraphQL APIs with Python

 

This chapter covers

  • Creating GraphQL APIs using the Ariadne web server framework
  • Validating request and response payloads
  • Creating resolvers for queries and mutations
  • Creating resolvers for complex object types, such as union types
  • Creating resolvers for custom scalar types and object properties

In chapter 8, we designed a GraphQL API for the products service, and we produced a specification detailing the requirements for the products API. In this chapter, we implement the API according to the specification. To build the API, we’ll use the Ariadne framework, which is one of the most popular GraphQL libraries in the Python ecosystem. Ariadne allows us to leverage the benefits of documentation-driven development by automatically loading data validation models from the specification. We’ll learn to create resolvers, which are Python functions that implement the logic of a query or mutation. We’ll also learn to handle queries that return multiple types. After reading this chapter, you’ll have all the tools you need to start developing your own GraphQL APIs!

10.1 Analyzing the API requirements

 
 
 

10.2 Introducing the tech stack

 
 

10.3 Introducing Ariadne

 
 
 

10.4 Implementing the products API

 
 
 

10.4.1 Laying out the project structure

 

10.4.2 Creating an entry point for the GraphQL server

 

10.4.3 Implementing query resolvers

 
 
 
 

10.4.4 Implementing type resolvers

 
 

10.4.5 Handling query parameters

 
 
 
 

10.4.6 Implementing mutation resolvers

 

10.4.7 Building resolvers for custom scalar types

 
 

10.4.8 Implementing field resolvers

 
 
 
 

Summary

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest