moxley
I defined a generic mutation action that takes an :id argument and an :input argument with an embedded resource backing :input. When I test the AshGraphql mutation, it doesn’t know about the arguments. It appears that AshGraphql has generated an input type that I can’t control.
[
%{
"locations" => [%{"column" => 36, "line" => 2}],
"message" =>
"Unknown argument \"id\" on field \"silenceConversationNotifications\" of type \"RootMutationType\"."
},
%{
"locations" => [%{"column" => 45, "line" => 2}],
"message" =>
"Argument \"input\" has invalid value $input.\nIn field \"input\": Expected type \"Conversation2InputInput!\", found null.\nIn field \"id\": Expected type \"String!\", found null.\nIn field \"silenceUntil\": Unknown field.\nIn field \"token\": Unknown field."
}
]
mutation SilenceConversationNotifications($id: ID!, $input: SilenceConversationNotificationsInput!) {
silenceConversationNotifications(id: $id, input: $input) {
result {
id
}
errors {
code
fields
message
shortMessage
vars
}
}
}
GraphQL variables:
%{
"id" => conversation.id,
"input" => %{"silenceUntil" => silence_until, "token" => token}
}
Here’s the action:
action :silence_notifications, GF.Messaging.Types.SilenceNotificationsResult do
argument :id, :string, allow_nil?: false
argument :input, SilenceNotificationsInput, allow_nil?: false
Here’s the AshGraphql mutation:
mutations do
action :silence_conversation_notifications, :silence_notifications
The input embedded resource:
defmodule GF.Messaging.Resources.SilenceNotificationsInput do
use Ash.Resource,
data_layer: :embedded,
extensions: [AshGraphql.Resource]
graphql do
type :silence_notifications_input
end
attributes do
attribute :silence_until, :utc_datetime do
allow_nil? false
constraints precision: :second,
cast_dates_as: :start_of_day,
timezone: :utc
public? true
end
attribute :token, :string do
allow_nil? true
constraints trim?: true, allow_empty?: false
public? true
end
end
end
Any ideas?
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
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
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 really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
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
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
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
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
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
- #ai
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming










Showing Posts 11 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
moxley
Great, thanks for the help!
zachdaniel
You can do it with filters on the update action, yes.
moxley
That gets us much closer. Here are the actions now:
And here’s the debug output:
The variables passed to the GraphQL mutation are:
It looks like the read action doesn’t see any arguments other than
:id. However, instead of relying on the read action to provide authorization gatekeeping, the update can do that, I think. Do you see any issues with that?moxley
I’ll give that a shot. Thanks!
zachdaniel
It should have whatever the arguments are on the read action, so in the read action you could do something like:
moxley
Okay, then with
identity false, and with theread_action :get_by_token_or_id, would the mutation still accept an ID argument?zachdaniel
You could view it in playground or you could use
mix absinthe.schema.sdl Your.Schemato see the full schema. Right now it does not look like we have a way for you to put those action inputs outside of the action, but it is not something that would be hard to add. We would likely call it something likeinput_location :input_object | :top_level.For your specific case though you should be able to add
identity falsein the update mutation to not need theidinput generated by default, andread_action :get_by_token_or_idthat has arguments that you could use to locate the user.moxley
Stepping back a bit, this is what I’m trying to accomplish:
I need a graphQL mutation that can take either a session user, or a special, single-purpose signed token to authenticate the user. The mutation should take an ID, and an input of map values. One of those map values is the token. I tried to do this with a regular update action, but the read action requires a session user, so that doesn’t work with the token authentication.
moxley
But I want the
idto be outside of the input, so that it looks and behaves like an update action. Is that possible?How do I view the generated GraphQL schema?
zachdaniel
like
input: %{id: .., input: ...}