bagasprstyadi
Validate graphql query/mutation arguments on Elixir
I’m looking for a module or something that can be used for validating a graphql query/mutation on Elixir. I’ve researched for it and stumble across a cool middleware called yup-middleware: GitHub - JCMais/graphql-yup-middleware: Add validation to your mutations arguments using yup! · GitHub but it is not for elixir
Is there a same module to in elixir that can be used to validate? I know I can use Absinthe.Middleware but I was just wondering if there is such a module that is easier to use.
Trending in Questions
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Hello !
We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Other Trending Topics
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security











First 9 of 9 Posts!
abitdodgy
Can’t you use Ecto changesets? A quick search yielded Kronky. But I’m not sure if this is what you are looking for.
Virviil
GraphQL seems to be a strong typed query language, so absinthe will validate all the parameters for you.
So, when you say “validate” what does that mean? Validate upon business logic? This probably should be done in Ecto Changesets or resolvers.
sorentwo
GraphQL types can be leveraged for data validation to a large degree, provided you make use of the tools it provides (i.e. enums). You can get additional validation through custom types like
emailorurl, but you’ll need to write the parsing and dumping yourself, and in a way that emits helpful errors.There are plenty of places where GraphQL/Absinthe can’t help you though. For example, if you want to enforce a string is a certain size, or that a particular field is filled in but another isn’t, or a provided ID actually exists in the database. You’ll need to fall back to validating with Ecto and your application’s business rules.
bagasprstyadi
If using changeset what I concern is that, there will be a lot of business logic before entering the schema right? What if I want to validate like a lot of formating for example name, email, url. I think Kronky is some module that helps you to return error message back to graphql
bagasprstyadi
Yes Graphql already provided with basic validate parameters as in :string, or :integer. But what I need is something a bit more like String is must be length of with format x. Like that
joaquinalcerro
Bagasprstyadi,
Check-out this talk where the presenter uses Ecto Changeset to create a validation layer.
https://youtu.be/k_xDi7zAcNM
Hope this helps.
Best regards,
Joaquin Alcerro
Virviil
It may be not so obvious, but you don’t need string to be with minimum length. You need password to be minimum length.
And this leads us two 2 different solutons:
You can create GraphQL type Password, it’s easily achieved with Absinthe library itself.
You can pass password as string, but validate it on your business logic. This can be done with your Ecto structures.
bagasprstyadi
Wow thank you, I will check it!
bagasprstyadi
“You can create GraphQL type Password”
This is interesting, so I can create custom type right, and then the graphql will validate it? Awesome, Im gonna look into that