I’m starting my journey with GraphQL, and I own a book from Pragmatic Programmers called Craft GraphQL APIs in Elixir with Absinthe. However this book dates from March of 2018 so it’s more than 5 years old. I’m wondering if I’m wasting my time going through this book; seems like Absinthe has had tons of commits since that time so there may be better resources out there?
Any views? Is the book still the best place to start? I’m kind of a total beginner on GraphQL though I know the principles and I know Postgres/SQL/relational theory very well.
I suspect we could summon @benwilson512 here but I suspect it’s still relevant.
I’m using Absinthe in a project for about that long (sic!) and we barely ever had to touch the existing resolvers or subscriptions as they continue to work. Maybe there are some new conventions in use, but I don’t remember any breaking major breaking changes since, with one exception of something related to how you hook them up to PubSub, but that was something minor.
Short answer: yes. Particularly as a total beginner.
Longer answer: While Absinthe has had a lot of commits since the book it is still a 1.X version, there have been no backwards incompatible changes introduced. The GraphQL spec itself hasn’t introduced any backwards incompatible changes, and while the libraries around Absinthe like Phoenix and Ecto have added major features (like live view) the bits used by Absinthe haven’t changed. It’s honestly a testament to the stability and foresight of the community.
The big unknown: Will the book’s dependencies run on a modern machine? The code that ships with the book is as you note pretty old at this point and it asks you to run a pretty old version of erlang and elixir. I don’t know of that’s going to work on say a modern M1 macbook.
I’ll give it a whirl this weekend, I haven’t tried to get it up and running in a long time.
Great news thanks @benwilson512 book is great btw been sitting on my bookshelf for a couple of years but took it to the coffee shop and next thing I knew I had been there over 2 hours Nix has a bunch of older Elixir releases going back to 1.10 in 2020 so might mitigate some issues with any older versions. And there’s always good 'ol ‘asdf’ which goes back ages.
I recently purchased this book from @pragprog and the version I have is P2.0 from April/2020.
Though the book don’t mention Absinthe’s version used on it, If you take a look at the releases absinthe versions | Hex you will see that should be
The book is a great place to start since it will take you by the hand and walk you through everything about Absinthe and thus GraphQL.
If you’re short on cash, Absinthe has a very good documentation, you can start there. But since there are a lot of new concepts, mostly due to GraphQL’s world, not only Absinthe’s, you may find yourself lost. Plus if you’re new to functional programming Absinthe documentation won’t help too much on that.
Otherwise I’d consider to start with the book indeed, and don’t mind the version of Absinthe, after you build your GraphQL API, you should be able to upgrade to newer Absinthe’s versions without the need of relearning the fundamentals.
Keep in mind GraphQL has nothing to do with Relational databases. If I had to compare, I’d say GraphQL is more related to API Controllers and JSON.
You can add Absinthe (GraphQL) to an existing Elixir/Phoenix API without changing the layers of your application, and if it’s well designed, you can even reuse your data-layer modules on your GraphQL resolvers (the “controllers” of a GraphQL API).
The reader should probably not even attempt to run it on the same versions of Erlang, Elixir, Phoenix and Absinthe, but set things up on the more recent and supported ones to avoid trouble. Otherwise a docker file with old Linux inside would work but that’s a weird software archeology.
Well… Phoenix unfortunately is pretty tricky, particularly when you get into the asset chapters. You can’t take the book code as is and just go to
mix.exs and bump Phoenix to the latest version. A ton of stuff will break (as I recall). I think bumping Elixir / OTP as high as it’ll go makes sense but Phoenix… probably not. Not without headaches.
yeah but if you want to build Absinthe GraphQL backend you need to basically scaffold the app with the built-in Phoenix generator, then add Absinthe/Absinthe.Phoenix as dependency and mount the endpoint in router. That’s all pretty similar.
I don’t remember what exactly you go through in the book but I suspect that’s the major part and it didn’t change much I think.
Yeah I think if you’re following along with the book and doing stuff step by step then using the latest is probably gonna work just fine (until you hit the JS chapters at the end).
By “book code” I mean the code that you can download from prag prog’s site that has all of the chapters code fully written out. Upgrading those in place may not work great.
I’ll play around with it on my side in the next few days and report back, but if you’re willing to give your code a quick whirl on later versions that could be very useful so thank you in advance.