Python Conference APAC 2024

GraphQL in Python
2024-10-27 , CLASS #6
Language: English

GraphQL is a more flexible alternative to REST for building web APIs and thus is becoming a strong foundation for any modern web stack. This is especially true where static HTML templates are not enough or a sophisticated single-page interface is needed. In this talk, we will look at various solutions for building GraphQL APIs in Python to power modern, dynamic web apps.


GraphQL is establishing itself as a foundation of the modern web development stack, particularly where a dynamic, single-page UI is required. It unlocks many great benefits, some of which are:

  • Fetching only the required data necessary to render particular views, while eliminating the need to call and combine data from multiple endpoints.
  • Developer experience through incredible out-of-the-box tooling available - interactive API explorers or code generators for statically typed languages used in the frontend.
  • Ability to combine various APIs under a single gateway with federations.

There are multiple libraries and approaches to build GraphQL APIs in Python. In this talk, we will look at two different approaches with popular libraries: schema-first approach with Ariadne (https://github.com/mirumee/ariadne) and code-first approach with Graphene (https://github.com/graphql-python/graphene). We'll take a look at the architecture and different aspects of a Python web app that serves a GraphQL API:

  • Basics of GraphQL - the most essential benefits, how it differs from REST, the main concepts, and examples.
  • Schema-first approach with Ariadne - how to design the schema and implement queries and mutations to interact with our data.
  • Code-first approach with Graphene - how to represent types and operations with classes, examples of a large production web app built with Django and Graphene, mapping Django models to GraphQL types.
  • Common web-app recipes - how to deal with authentication, permissions, or database performance in a GraphQL-first backend app.

I'm a Principal Developer at Saleor Commerce (https://github.com/saleor/saleor), where I work on the core GraphQL API of the largest open-source e-commerce platform written in Python. In my free time, I enjoy cycling, making music, and traveling. I'm based in Wrocław, Poland.

This speaker also appears in: