bar65

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

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

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lastday4you
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
freewebwithme
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
ashish173
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
shahryarjb
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
johnnyicon
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
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; someth...
New
Fl4m3Ph03n1x
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
wernerlaude
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
siddhant3030
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 Top

yurko
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
shahryarjb
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
senggen
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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
William
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
gshaw
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
JorisKok
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
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
fireproofsocks
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
minhajuddin
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

We're in Beta

About us Mission Statement