idi527
Right now i get an unnecessary (to me) In field "signUp": in front of the actual message:
{
"errors": [
{
"message": "In field \"signUp\": should be at least 3 character(s)",
...
"key": "username"
},
{
"message": "In field \"signUp\": should be at least 6 character(s)",
...
"key": "password"
}
]
...
}
But i would like to just get "should be at least 6 character(s)" in the "message" fields. Is this possible? Or is there some other way to access this message?
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
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
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
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
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
- #security
- #metaprogramming










Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
idi527
I’ve decided to add an additional
"error"field to put the error message in.benwilson512
Hey there! Your solution is definitely one approach.
By way of analogy, you can kind of think of GraphQL errors like exceptions in a regular programming language. They aren’t return values from the field, but rather field execution errors that bubble up to the top.
For errors like you’re trying to expose there’s another pattern that uses a union type to represent that a field may return validation errors. Here’s an example:
And here’s how you’d use this in a document:
This is a lot like the difference between Elixir functions that return
{:ok, result} | {:error, reason}and functions that simply return the result or raise.idi527
Thanks! It seems like i need to learn more about both Absinthe and GraphQL.
idi527
I’ve tried the union operator but whenever I supply an invalid username/password pair so that to get
ValidationErrorI keep getting this error insteadHere’s my
schema.exschema/types.exand
resolver/session.exand the document I send
idi527
I’ve replaced
list_of(:validation_error)with:validation_errorsadded
validation_errorstypeand updated
session.exto return%{errors: ...}mapand now it works. The document I send now is
I wonder if there is a shorter solution which doesn’t require defining a new type.
benwilson512
Unfortunately no not at the moment. The reason returning
list_of(:valication_error)didn’t work is thatlist_ofis really a type modifier as far as GraphQL is concerned, rather than a proper generic type of the formList<T>. Practically speaking I think the reason is that any given key that is requested should always be a list of a type or a regular type, but never sometimes one and sometimes the other.We are looking to perhaps support some schema tools that would make this pattern less verbose and more first class, but at the moment I believe what you have here is the best for now.
rafbgarcia
I’m trying to implement this solution, and it’s kind of working but something unexpected is going on, I’m getting this error:
This is my code:
I import this in my schema:
And this is my resolver:
Any ideas on what’s going on?
FWIW this is what I see in the console: see gist
It returns a function with my return value and Absinthe.Resolution as a second param.
benwilson512
Hey! You may be confused about what gets passed to the
resolve_typefunction.You should just be doing:
rafbgarcia
That worked \o/ Thanks (for the fast answer too)!