grangerelixx
Argument \"input\" has invalid value - input object GQL mutations
My tests were passing until I wrote the input_object block. In my ecto schema, the field title is non-null. Since I wanted the updation to take place with either title or slug(there are some cases when I don’t want to update the title but just the slug), I wrote the input_object. But this landed me in a new error which I am not able to fix. Invalid argument value.
Gql muation for update
@desc "Update a Post"
field :update_post, :post do
arg(:id, non_null(:string))
arg(:title, :title_input)
arg(:slug, :slug_input)
resolve(&Resolvers.Post.update_post/3)
end
input_object :title_input do
field :title, :string
end
input_object :slug_input do
field :slug, :string
end
Resolver function
def update_post(_root, args, %{context: %{current_user: current_user}}) do
post_id = args.id
post =
Blog.get_post!(post_id)
case Blog.update_post(
post,
args,
current_user.current_tenant
) do
{:ok, post} ->
{:ok, post}
{:error, changeset} ->
{:error,
message: "Could not update post",
details: ChangesetErrors.error_details(changeset)}
end
Mutation test
mutation = """
mutation {
updatePost(id: "#{context.post.id}", title: "New title") {
id
title
slug
}
}
"""
expected_response = %{
"updatePost" => %{
"id" => context.post.id,
"title" => "New title"
}
}
Error message
"message" => "Argument \"title\" has invalid value \"New title\"."
Any help is appreciated.
First Post!
benwilson512
Author of Craft GraphQL APIs in Elixir with Absinthe
Your title argument is an input_object in your schema, not sure why but that’s what you have. Which means that it’s expecting title: {title: "New Title"}.
Popular in Questions
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this
"1000"
What is the ...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work.
Or rather, not char, but a substr...
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Other popular topics
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some projec...
New
I would like to know what is the best IDE for elixir development?
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
by Lance Halvorsen
Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New








