benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

by Bruce Williams and Ben Wilson

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 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.

Don’t forget you can get 35% off the ebook using the code ‘devtalk.com:023:

Showing Posts 41 to 32

conradwt

conradwt

@dustin The book is a bit dated but the concepts still work today. Next, I went through the book a bit differently by creating a new Phoenix application using a current version of Phoenix and Elixir. Then I just manually typed most and/or copied and pasted the code from the downloadable source. When I got stuck, I just referenced the Absinthe online documentation. Well, I wish that it helps and all the best to you.

dustin

dustin

It’s 2024 and it appears that the downloadable code resources are out of date. I just bought the book a few days ago. I get a number of warnings, and the a compilation failure in lib/plate_slate_web/views/layout_view.ex.

Is there a version I might be missing, or any intention on updating the code?

slouchpie

slouchpie

To answer my own question, today I started chapter 9 and it does exactly this thing with a “bookended” middleware using :start and :finish calls. So anyone else doing this, keep reading and all will become clear.

To elaborate, I just expanded the Debug middleware from chapter 9 like this:

defmodule PlateSlateWeb.Schema.Middleware.Debug do
  @behaviour Absinthe.Middleware

  def call(resolution, :start) do
    path = resolution |> Absinthe.Resolution.path |> Enum.join(".")
    time1 = :erlang.timestamp
    IO.puts """
    ========START==========
    started: #{path}
    with source: #{inspect resolution.source}
    """
    %{resolution | middleware: resolution.middleware ++ [{__MODULE__, {:finish, path, time1}}]}
  end

  def call(resolution, {:finish, path, time1}) do
    time2 = :erlang.timestamp
    time_taken = :timer.now_diff(time2, time1)
    IO.puts """
    completed: #{path}
    time taken: #{time_taken} microseconds (#{:erlang.float_to_binary(time_taken * 1.0e-6, [{:decimals, 6}])} seconds )
    value: #{inspect resolution.value}
    ========END==========\
    """
    resolution
  end
end

It’s probably not the best solution but it works for me!

slouchpie

slouchpie

Has anyone found a nice way of doing the challenge at the end of chapter 7 (Resolution Middleware)?

I’ve been trying to do it today and I’m getting nowhere. I think I don’t understand where the time taken is meant to be stored? Should it be on the response?

JFYI the challenge is to “Build some middleware that can be used to measure how long it takes to resolve a field”.

I know I’m showing lack of effort here but I can only do Elixir in my spare time (Python/JS dev by day) so any guidance or hints would be greatly appreciated.

sb8244

sb8244

Author of Real-Time Phoenix

I’m excited to read P2 before the start of my next large project!

kokolegorille

kokolegorille

I just got the P2 version.

Thanks for updating :slight_smile:

benwilson512

benwilson512 OP

Author of Craft GraphQL APIs in Elixir with Absinthe

This is also correct. The main thing that has tripped people up in the past is that they have tried to use the latest Elixir / Erlang without upgrading Absinthe. This leads to compilation errors. If however you upgrade Absinthe and other dependencies, it should all be smooth sailing.

idi527

idi527

So what versions of Erlang and Elixir should I use?

I’ve reread the book recently and worked through the examples with elixir 1.8.1 and latest absinthe, dataloader, phoenix, ecto, etc. Don’t remember encountering any major problems, so I’d say the latest versions of everything should work.

benwilson512

benwilson512 OP

Author of Craft GraphQL APIs in Elixir with Absinthe

Thanks for using Absinthe!

pillaiindu

pillaiindu

Thank you for your time! :slight_smile:

Where Next? Top

Trending in Books Top

manhvu
I have a sharing session about the Elixir ecosystem for Erlang developers. I feel that people are still confused about the differences be...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews