tomwang57
And very odd error when passing arguments in graphql query
In a unit test, i launched a query which needs 3 parameters as follows:
@query """
query ($container_type: String!, $container_id: UUID!, $limit: Int) {
messages_for_container(container_type: $container_type, container_id: $container_id, limit: $limit) {
messages {
id
}
}
}
"""
test "returns a limited number of messages", %{conn: conn, user: user} do
...
conn =
get(conn, "/graphql2",
query: @query,
variables: %{
container_type: room.container_type,
container_id: room.container_id,
limit: 1
}
)
assert %{"data" => data} = json_response(conn, 200)
...
end
It failed with the following error:
%{"errors" => [%{"locations" => [...], "message" => "Argument \"limit\" has invalid value $limit."}] }
That mean limit parameter didn’t get the right value from what was passed.
What confused me most is that if i directly set limit to 1 and remove $limit totally, it passed:
@query """
query ($container_type: String!, $container_id: UUID!) {
messages_for_container(container_type: $container_type, container_id: $container_id, limit: 1) {
messages {
id
}
}
}
"""
test "returns a limited number of messages", %{conn: conn, user: user} do
...
conn =
get(conn, "/graphql2",
query: @query,
variables: %{
container_type: room.container_type,
container_id: room.container_id,
}
)
assert %{"data" => data} = json_response(conn, 200)
...
end
So there is no problem with the schema. Anybody has some hints:
phoenix version: 1.7.7
absinthe version: 1.7.5
First Post!
benwilson512
Author of Craft GraphQL APIs in Elixir with Absinthe
Hi @tomwang57 can you show the schema you have for that query field?
Popular in Questions
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
can someone please explain to me how Enum.reduce works with maps
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
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Student & New to elixir. Nice language.
I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Other popular topics
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
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
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
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
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New







