I was doing the Absinthe tutorial for Elixir using the howtographql.com website. At some point (https://www.howtographql.com/graphql-elixir/2-queries/), when running the last step of running the graphql server, I get an error.
Command executed:
$ iex -S mix phx.server
Output:
Erlang/OTP 22 [erts-10.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]
warning: found quoted keyword "test" but the quotes are not required. Note that keywords are always atoms, even when quoted. Similar to atoms, keywords made exclusively of Unicode letters, numbers, underscore, and @ do not require quotes
mix.exs:57
Compiling 4 files (.ex)
== Compilation error in file lib/community_web/schema.ex ==
** (CompileError) lib/community_web/schema.ex:17: undefined function field/3
(elixir) lib/kernel/parallel_compiler.ex:229: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7
This is how my lib/community_web/schema.ex
looks like:
1 defmodule CommunityWeb.Schema do
2 use Absinthe.Schema
3
4 alias CommunityWeb.NewsResolver
5
6 object :link do
7 field :id, non_null(:id)
8 field :url, non_null(:string)
9 field :description, non_null(:string)
10 end
11
12 query do
13 field :all_links, non_null(list_of(non_null(:link)))
14 end
15 end
16
17 field :all_links, non_null(list_of(non_null(:link))) do
18 resolve &NewsResolver.all_links/3
19 end
This is how my lib/community_web/resolvers/news_resolver.ex
looks like:
1 defmodule CommunityWeb.NewsResolver do
2 alias Community.News
3
4 def all_links(_root, _args, _info) do
5 links = News.list_links()
6 {:ok, links}
7 end
8 end
I was expecting that the server will get executed, as the tutorial states, but only the error message is shown.
Thanks!