Hanums

Hanums

Elixir 1.7.4, Absinthe compilation error: The root query type must be implemented and be a of type Object

I am receiving below error at mix compile. I tried to downgrade but received error on Mac. Help please…

$ brew switch elixir 1.6.6
Error: elixir does not have a version "1.6.6" in the Cellar.
elixir installed versions: 1.7.4

I am at Elixir 1.7.4 and deps are

      {:absinthe, "~> 1.4.0"},
      {:absinthe_plug, "~> 1.4.0"},
      {:absinthe_ecto, "~> 0.1.3"},

The root query type must be implemented and be a of type Object

  #Example
  defmodule MyApp.Schema do
    use Absinthe.Schema

    query do
      #Fields go here
    end
  end

From the graqhql schema specifiation

A GraphQL schema includes types, indicating where query and mutation
operations start. This provides the initial entry points into the type system.
The query type must always be provided, and is an Object base type. The
mutation type is optional; if it is null, that means the system does not
support mutations. If it is provided, it must be an object base type.

Reference: https://facebook.github.io/graphql/#sec-Initial-types

lib/absinthe/schema.ex:271: Absinthe.Schema.__after_compile__/2
(stdlib) lists.erl:1263: :lists.foldl/3
(stdlib) erl_eval.erl:680: :erl_eval.do_apply/6
(elixir) lib/kernel/parallel_compiler.ex:206: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

Marked As Solved

Eiji

Eiji

My bad - this question just reminded me this old issue and I just checked if 1.7-issue branch is still there and it is. I had just took a look at branches details and found:

1.7-issue Updated 6 months ago by benwilson512

Also Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Absinthe absolutely supports Elixir 1.7. However, you need one of the latest versions. @Hanums you should mix deps.update absinthe.

dimitarvp

dimitarvp

That’s why I posted above. Just wanted to add one more voice to the fact that Elixir 1.7.4 and Absinthe 1.3 combo leads to compilation errors. And that upgrading to 1.4 fixes it.

:+1:

dimitarvp

dimitarvp

What Ben recommended to you is not Elixir-specific. It’s a Linux command.

Delete your _build and deps directories (at the root of your project) and then execute this:

mix do deps.get, compile
benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Oh you’re actually on Absinthe 1.3.2? That simply won’t work on 1.7.4. Elixir changed some details about how module attributes worked that absinthe was accidentally relying on. You need to upgrade to 1.4.13.

kokolegorille

kokolegorille

I have been using Absinthe 1.4 with Elixir > 1.7

Here is my dependencies (Do not use 1.4.0, prefer 1.4)

      {:ecto, "~> 3.0", override: true},
      #
      {:absinthe, "~> 1.4"},
      {:absinthe_plug, "~> 1.4"},
      {:absinthe_ecto, "~> 0.1.3"},
      {:absinthe_relay, "~> 1.4"},
      {:absinthe_phoenix, "~> 1.4"},

I am overriding ecto because absinthe_relay requires ecto 2, but that is not required if You don’t use relay.

At least You need one query inside the query block. For example, You can try this…

  query do
    field :hello, :string do
      resolve fn _, _ -> {:ok, "world!"} end
    end
  end

In graphiql, You can query

{
  hello
}

And this would be the result.

{
  "data": {
    "hello": "world!"
  }
}

Do not forget to specify the json encoder in your router…

  scope "/" do
    pipe_through :api

    # Note: downloaded from CDN!
    forward "/graphiql",
      Absinthe.Plug.GraphiQL,
      schema: GraphqlWeb.Schema,
      json_codec: Jason
  end

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
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
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
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
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
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
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement