bar65
Asbsinthe graphql api schema.ex error
I created a project on this site step by step, I got such an error
lib/community_web/resolvers/news_resolver.ex my file
defmodule CommunityWeb.NewsResolver do
alias Community.News
def all_links(_root, _args, _info) do
{:ok, News.list_links()}
end
end
lib/community_web/schema.ex my file
defmodule CommunityWeb.Schema do
use Absinthe.Schema
alias CommunityWeb.NewsResolver
object :link do
field :id, non_null(:id)
field :url, non_null(:string)
field :description, non_null(:string)
end
query do
@desc "Get all links"
field :all_links, non_null(list_of(non_null(:link)))
resolve(&NewsResolver.all_links/3)
end
end
error
C:\Users\baris\community>iex -S mix phx.server
Compiling 4 files (.ex)
== Compilation error in file lib/community_web/schema.ex ==
** (Absinthe.Schema.Notation.Error) Invalid schema notation: `resolve` must only be used within `field`. Was used in `object`.
(absinthe 1.7.0) lib/absinthe/schema/notation.ex:2076: Absinthe.Schema.Notation.recordable!/3
(absinthe 1.7.0) expanding macro: Absinthe.Schema.Notation.resolve/1
lib/community_web/schema.ex:15: CommunityWeb.Schema (module)
(absinthe 1.7.0) expanding macro: Absinthe.Schema.query/1
lib/community_web/schema.ex:12: CommunityWeb.Schema (module)
Most Liked
al2o3cr
(note: I edited your post to use triple-backticks to format code)
This line is the problem:
field :all_links, non_null(list_of(non_null(:link)))
when the tutorial wires this up under “Query Resolver”, it passes a do block to field:
query do
@desc "Get all links"
field :all_links, non_null(list_of(non_null(:link))) do # <========= this is important
resolve(&NewsResolver.all_links/3)
end
end
3
Popular in Questions
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
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 am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
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
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> someth...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New
In AR this is so simple
@articles = current_user.articles
How to do in Ecto?
def index(conn, _params) do
current_user = conn.assig...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Other popular topics
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persi...
New
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
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
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 a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
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







