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.