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
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
- #elixirconf-us
- #ai
- #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)
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.