Build a GraphQL API powered by Django

Sunday 1:30pm, Sierra 5
Intermediate

About This Tutorial

WHAT is the workshop about?

In this workshop you’ll learn what GraphQL is and why it is a viable alternative to REST for building powerful APIs. You’ll also build your very own GraphQL API from scratch based on Django and the popular graphene-python library. No previous experience with GraphQL is required.

WHY should you attend?

GraphQL is much more than a library or technical specification. One of its most valuable assets is the mindset that encourages robust, scalable, and elegant design patterns for building APIs. It can help you better understand and express the individual parts of your application (nodes), and how they interact with each other (edges). It will also provide structure to both how you build and consume your API, documenting itself along the way, reducing friction and boosting productivity in the frontend and backend implementations.

Program

We’ll start with a quick intro to get acquainted with GraphQL and some basic concepts. Then we’ll jump right into our text editors and explore a Django app with an existing set of models. We’ll write the required code to expose our models via a GraphQL API that will allow us to query and modify the records in the database. We will use GraphiQL, an in-browser IDE, to explore our API (we won’t write any frontend code).

OUTLINE

  • Introduction
    • Shallow dive into graph theory
    • GraphQL: the spec
    • GraphQL vs REST
  • Graphene and Django
    • Installing Graphene
    • Write your first resolver
    • Exploring your API with GraphiQL
  • Queries: exposing our data via GraphQL
    • Django models as nodes
    • Single node queries
    • Edge queries via connection fields
    • Queries and filters
  • Mutations: modifying our data via GraphQL
    • Node creation
    • Node updates
  • Review and learning resources

Attendee requirements

You should have Python and Django installed in your computer, and be comfortable installing packages via pip. You should be familiar with Python classes (attributes, methods, and inheritance) and with Django’s ORM (models and querysets). Experience with REST APIs is a plus, but not necessary to understand the content.

No previous knowledge of GraphQL or graphene is required. No JavaScript, HTML, or CSS will be used in this workshop.

Photo of

Ed Rivas

Hi, I’m Ed! I’m a full-stack web developer building fast, elegant sites with Python / Django. On the frontend, I love bringing beautiful designs to life using accessible and performant HTML, (S)CSS, and JavaScript. I’m passionate about helping others learn and master technology to solve problems and achieve their goals. I like to participate in communities built around open source software, both as an organizer in local meetups, and online via mailing lists and GitHub.