arjan
Would there be interest in a (small) DSL for writing graphql queries in Elixir?
In my tests I am now annoyed by the fact that GraphQL does not indent very well (writing gigantic GraphQL queries inside ~s(...)), so I’m tempted to write a macro which takes something like this:
graphql = query [id: :string] do
orders(a: id) do
id
title
order_lines do
id
price
end
end
end
And automagically converts it into this string:
query ($id: String) { orders(id: $id) { id title order_lines { id price } } }
Trending in Discussions
Hey there,
It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hi there! :wave:
@frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
I’ve been using Emacs as my main code editor for more than a two years. It’s a custom build version although I’ve tried doom emacs and sp...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
Lately I’ve been thinking about how to organize components as a LiveView application grows. One of the pain points I’ve found (for myself...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 17 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
arjan
Yes that would be awesome. I see that Sangria has a
graphqlmacro as well to check the query compile-time.OvermindDL1
Mine is more about calling into the locally defined absinthe system.
keathley
This is the main benefit of github’s graphql-client: https://github.com/github/graphql-client. It validates your queries when you define them which is about as close as you can get to a “compile time” check in ruby.
If a DSL could be incorporated into absinthe then that seems great. Ideally you could use any schema. My use case is less about testing and more about interacting with external services though.
law
I’d stayed away from generating queries dynamically primarily from this advice about the benefits of static graphql queries.
But this has me re-thinking. Tooling support and compile time checks are really appealing. This code is really nice to read.
Not sure what conclusion I’ll come to, but awesome work.
benwilson512
Yeah your DSL just needs to build a blueprint tree. See the Draft protocol in Absinthe.
OvermindDL1
Ooo, that is awesome, being able to run that will be fantastic for verifying good strings at compile-time and no doubt for a DSEL too.
benwilson512
lol I hit enter too early. Fixed now with a real reply.
OvermindDL1
Meant a valid query, not schema. ^.^;
arjan
I’ve put it up: GitHub - arjan/absinthe_dsl: Elixir DSL for constructing GraphQL queries · GitHub
Works like this:
Contributors welcome
benwilson512
Absinthe works a lot like a compiler, so you just build a pipeline of phases up prior to the actual resolution point:
It isn’t quite as easy as I’d like. I’m gonna add a phase I think that will automatically run the result phase ONLY on error. Either way, this should get you going for now.