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?