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.

Choose Your Format(s)

  • $25.95 In Stock
    • Beta: What do I get?

  • Ebooks are DRM free.

  • Ebook delivery options.

About this Title

Pages: 250 (est)
Published: 2018-02-01
Release: B4.0 (2018-01-23)
ISBN: 978-1-68050-255-8

GraphQL is a new way of structuring and building web services, and the result is transformational. Find out how to offer a more tailored, cohesive experience to your users, easily aggregate data from different data sources, and improve your back end’s maintainability with Absinthe’s declarative approach to defining how your API works.

Build a GraphQL-based API from scratch using Absinthe, starting from core principles. Learn the type system and how to expand your schema to suit your application’s needs. Discover a growing ecosystem of tools and utilities to understand, debug, and document your API. Take it to production, but do it safely with solid best practices in mind. Find out how complexity analysis and persisted queries can let you support your users flexibly, but responsibly too. Along the way, discover how Elixir makes all the difference for a high performance, fault-tolerant API. Use asynchronous and batching execution, or write your own custom add-ons to extend Absinthe. Go live with subscriptions, delivering data over websockets on top of Elixir (and Erlang/OTP’s) famous solid performance and real-time capabilities.

Transform your applications with the powerful combination of Elixir and GraphQL, using Absinthe.

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

This book is currently in beta, so the contents and extracts will change as the book is developed.

  • 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 Absinthe Context
      • Securing Fields with Authorization
      • Moving On
    • Tuning Performance
      • Async fields
      • Batching
      • Moving On
  • Integrate With Your API
    • Customizing the Pipeline
      • Default Functionality
      • Building a Phase
      • Moving On
    • Integrating with the Frontend
      • Configuring Phoenix for Webpack
      • Using Relay
      • Using Apollo Client
      • Other Frameworks
      • Moving On


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.