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’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zachdaniel
idjust needs to go inside theinput. What does the generated GraphQL schema for that look like?zachdaniel
like
input: %{id: .., input: ...}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?
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.
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
Okay, then with
identity false, and with theread_action :get_by_token_or_id, would the mutation still accept an ID argument?zachdaniel
It should have whatever the arguments are on the read action, so in the read action you could do something like:
moxley
I’ll give that a shot. Thanks!
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?zachdaniel
You can do it with filters on the update action, yes.