wolfiton
Hi everyone,
Can’t find any error map in wormwood
My test works but I can’t test an error
describe "GetMenuItems.gql == error" do
test "Should return error Menu items (0 of them)" do
result = query_gql(variables: %{"matching" => "123"})
IO.inspect(result)
assert {:ok, %{data: %{"MenuItems" => menu_items}}} = result
IO.inspect(menu_items)
assert length(menu_items) == 0
end
end
This all I have
{:ok, %{data: %{"MenuItems" => []}}}
Am I missing something?
Thanks
Trending in Chat/Questions
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
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
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 just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
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
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
Why should that return an error? 0 results isn’t an error. Additionally, a graphql query will only return an error if there is a syntax / validation issue with the query itself, or if you return an error from the resolver. If you aren’t doing that, it won’t error.
wolfiton
Thank you
I was trying to rewrite this test in Wormwood:
And i don’t see any possibilities at the moment to do so.
benwilson512
You didn’t pass in the same value. You passed in
"123"(a string), but the wormwood example uses123(an integer).wolfiton
You are right. Now I will match it with the error I am getting. Thanks
benwilson512
FYI this line doesn’t do anything. You’re just binding a value to a variable, which cannot fail.
wolfiton
So now after rewriting this test
I don’t get a pass
I was trying to pattern match on the error message like in the previous tests but no luck.
Stack trace:
benwilson512
I’m happy to keep helping you, but there are some Elixir basics here you seem to be struggling with that are making this a lot harder than it needs to be. Look carefully at the error message. Look at the exact data types between what you have what you are asserting on the left, and what the value of
resultis on the right. In particular, pay attention to what values are strings and what values are atoms.Based on the content of your error messages, it looks like you’re working through the Absinthe book. This is a great way to learn absinthe. However, since you’re very new to this, I don’t think it’s a good idea to try to BOTH work through a new book AND utilize a testing library that isn’t used in the book. There are subtle but important differences between how wormwood tests work and how regular ExUnit test work, and those differences will only increase as you go further into the book and start handling things like authentication headers. I would ditch wormwood for now, and revisit it later after you have a solid grasp of how Absinthe and Elixir testing works.
wolfiton
I appreciate the recommendation but when i used the tests in the book I run only into errors and erratas like this one
#84808
PDF page: 36
@query “”"
{
menuItems(matching: 123) {
name
}
}
“”"
test “menuItems field returns errors when using a bad value” do
response = get(build_conn(), “/api”, query: @query)
assert %{
“errors” => [
%{“message” => message}
]
} = json_response(response, 400)
assert message == “Argument "matching" has invalid value 123.”
end
$ mix test test/plate_slate_web/schema/query/menu_items_test.exs
..
test/plate_slate_web/schema/query/menu_items_test.exs:76
** (RuntimeError) expected response with status 400, got: 200, with body:
{“errors”:[{“message”:“Argument "matching" has invalid value 123.”,“locations”:[{“line”:2,“column”:0}]}]}
code: } = json_response(response, 400)
stacktrace:
(phoenix) lib/phoenix/test/conn_test.ex:373: Phoenix.ConnTest.response/2
(phoenix) lib/phoenix/test/conn_test.ex:419: Phoenix.ConnTest.json_response/2
test/plate_slate_web/schema/query/menu_items_test.exs:83: (test)
Finished in 0.2 seconds
3 tests, 1 failure–Conrad Taylor
Ben Wilson says: This happened because you upgraded absinthe_plug which has slightly different behaviour with respect to status codes. Using the version specified in the book lock file will ensure that the book code works.
I don’t ewnat to complain i just searched for a solution for myself.
Thank you a lot for all the suport and patience in guiding me with this.
benwilson512
The answer I supply in the errata is the correct one to solve your problem. Did you try using the exact
mix.lockfile from the book code?wolfiton
I wanted to use the latest, because that is what i will use in production and wormwood helped me to use the latest until now.