small medium large xlarge

Craft GraphQL APIs in Elixir with Absinthe: Flexible, Robust Services for Queries, Mutations, and Subscriptions


Cover image for Craft GraphQL APIs in Elixir with Absinthe

Craft GraphQL APIs in Elixir with Absinthe

Flexible, Robust Services for Queries, Mutations, and Subscriptions


Your domain is rich and interconnected, and your API should be too. Upgrade your web API to GraphQL, leveraging its flexible queries to empower your users, and its declarative structure to simplify your code. Absinthe is the GraphQL toolkit for Elixir, a functional programming language designed to enable massive concurrency atop robust application architectures. Written by the creators of Absinthe, this book will help you take full advantage of these two groundbreaking technologies. Build your own flexible, high-performance APIs using step-by-step guidance and expert advice you won’t find anywhere else.

  • GraphQL Video Course
  • Unpacked: Full-Stack GraphQL with Absinthe, Phoenix, and React
  • Authors: Mike Clark and Nicole Clark

Want to see GraphQL at work in the context of a full-stack application? The Pragmatic Studio has a video course just for you! Learn how to put together an app using Phoenix on the backend, Absinthe for the GraphQL API, and React with Apollo on the frontend. You’ll come away understanding how everything works together in harmony so you can build your own GraphQL app from start to finish.

These videos were technically reviewed by Bruce Williams so you know you’re learning techniques and practices based on real-world experiences. The course includes 4.5 hours of video, 17 animations exploring key design elements, and all the source code.

Buy directly from The Pragmatic Studio.

Customer Reviews

Like GraphQL’s meteoric rise, this book is sure to be a breakout hit for readers
looking to revolutionize the way they write APIs. Ben and Bruce combine their
Absinthe expertise with their production experience to take readers from the basics
of GraphQL to exercising its most powerful features with Elixir and Phoenix.

- Chris McCord

Author, Phoenix framework

If we’re lucky, about once per decade or so we’ll come across a technology that
has the chance to revolutionize the Web. GraphQL is one such set of technologies.
This book is written by two of the industry’s experts—co-authors of one of the
best and most complete GraphQL implementations. Even if you’re not planning
to deploy on Elixir, this book will show you GraphQL done right.

- Chad Fowler

, Microsoft and BlueYard Capital

Absinthe single-handedly made one of the most critical and complex parts of
Trailpost’s infrastructure the piece I worry about least. This book should be on
the radar of anyone developing APIs in Elixir, and probably some who aren’t.

- Daniel Pehrson


GraphQL is a broad but rewarding topic, and Bruce and Ben have covered it
comprehensively. The book introduces the key GraphQL concepts in a very approachable
way. It then makes sure you have all the tools and techniques to build
robust, well-structured, and incredibly fast GraphQL APIs using Elixir, Absinthe,
Ecto, and Phoenix. A killer combination for building amazing applications if ever
there was one!

- Josh Price

Technical Director, Alembic

GraphQL is a game changer, and now you can use it with Elixir! This book is an
invaluable must-read for any Elixir developer. I referred to it often as I helped
prepare our web team for the next generation of APIs.

- Daniel Berkompas

Senior Software Engineer; Creator of &, Infinite Red

See All Reviews

Choose Your Format(s)

  • $25.95 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

What You Need

To follow along with the book, you should have Erlang/OTP 20+ and Elixir 1.5+ installed. The book will guide you through setting up a new Phoenix 1.3 application using Absinthe.

Contents & Extracts

  • Introduction
  • Build a GraphQL API
    • Meet GraphQL
      • On the Client
      • On the Server
      • Absinthe and the Tech Stack
      • Moving On
    • Building a Schema
      • Preparing the Application
      • Our Schema Module
      • Making a Query excerpt
      • Running Our Query with GraphiQL
      • Testing Our Query
      • Moving On
    • Taking User Input excerpt
      • Defining Field Arguments
      • Providing Field Argument Values
      • Using Enumeration Types
      • Modeling Input Objects
      • Marking Arguments as Non-Null
      • Creating Your Own Scalar Types
      • Moving On
    • Adding Flexibility
      • Organizing a Schema
      • Understanding Abstract Types
      • Using Named Fragments
      • Moving On
    • Making a Change with Mutations
      • Defining a Root Mutation Type
      • Building the Resolver
      • Handling Mutation Errors
      • Moving On
    • Going Live with Subscriptions
      • Setting Up Subscriptions
      • Event Modeling
      • Submitting Subscriptions excerpt
      • Testing Subscriptions
      • Subscription Triggers
      • Moving On
  • Publish Your API
    • Resolution Middleware
      • Our First Module
      • Applying Middleware
      • Setting Defaults
      • Moving On
    • Securing with Authentication and Authorization
      • Logging In
      • Using the Execution Context
      • Securing Fields
      • Structuring for Authorization
      • Moving On
    • Tuning Resolution
      • Understanding the Problem
      • Using Built-in Plugins
      • Discovering Dataloader
      • Moving On
  • Use Your API
    • Driving Phoenix Actions with GraphQL
      • Building an Action
      • Handling Input
      • Complex Queries
      • Moving On
    • Integrating with the Frontend
      • Starting Simple
      • Choosing a Framework
      • Using Apollo Client
      • Using Relay
      • Wrapping Up


Bruce Williams is a polyglot technologist, speaker, and writer interested in everything from learning type systems and writing parsers to designing UX. He is the CTO of CargoSense, a logistics intelligence company, and the co-creator of Absinthe, the GraphQL toolkit for Elixir.

Ben Wilson is a full-stack developer and leading member of the Elixir community as an open source maintainer, contributor, and conference speaker. He is the back-end team lead at CargoSense and the co-creator of Absinthe.