hykw

hykw

Absinthe showcase: Battery included GraphQL sample

Hello,
I’ve written a GraphQL server with Absinthe as a proof of concept and a prototype for the next project.

I found some samples, Absinthe Tutorial Codel for example, and those were good start as the first step, but the learning curve would be too steep when you want to implement some logics, such as avoiding an N+1 problem with dataloader, authorizing users, injecting some values into the result returned from dataloader, etc.

You can get the source code and some description about it here: absinthe_showcase

Features

  • Battery included

    • You can soon try in Docker Compose.
  • Written in the latest libraries:

    • OTP 21, Elixir 1.7.4
    • Phoenix 1.4, Ecto 3.0
    • Absinthe 1.4.13
  • Avoiding N+1 problem with dataloader

  • Authorizing user permission with a custom middleware

  • Count the number of records regardless of LIMIT/OFFSET specified, which is very useful in pagination

  • Supports multistage query such as {questions{users{} answers{}}}, {me {users{} questions{} answers{}}}, {questions{answers{users{}}}}, etc.

  • Various queries/mutations

    • mutations
      • login with email and password; supports two permissions
        • normal user
        • admin user
      • create user account
        • the only admin user can create new accounts
        • guests(no login user) or normal users are rejected
    • query
      • various queries includes total record counts

Feedback welcome!

This is the first time I’ve written an application with Absinthe. Any suggestions for improving this application, even the mistakes you find in my English, are welcome.

Most Liked

hykw

hykw

Having a lot of entities I found putting everything in 1 types file easier than putting the queries and mutations in the schema like you did.

@hlx I’ve never thought of it!
Thank you for your feedback.

Where Next?

Popular in Discussions Top

sashaafm
I’m trying to evaluate the best combo/stack for a BEAM Web app. Right now I’m exploring Yaws a bit, after having dealt with Phoenix for a...
New
thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New
pillaiindu
I want to convert a Phoenix LiveView CRUD website to a CRUD mobile app. What do you think is the easiest way to do so?
New
PragTob
Hey everyone, this has been brewing in my head some time and it came up again while reading Adopting Elixir. GenServers, supervisors et...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
RudManusachi
What configs will make sense to put to runtime.exs? – A bit of how I configure apps: I have generic configs in config/config.exs, dev...
New
ben-pr-p
In general I’ve been sticking to this community style guide GitHub - christopheradams/elixir_style_guide: A community driven style guide ...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
pdgonzalez872
If this has been asked here before, please point me to where it was asked as I didn’t find it when I searched the forum. Maybe a mailing ...
New
paulanthonywilson
I like Umbrella projects and pretty much always use them for personal Elixir stuff, especially Nerves things. But I don’t think this is ...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement