Absinthe Compilation error

Hi there!

I got some problem when develop graphql api.
I followed absinthe schema rule and built an api.
And it’s running well by using iex -S mix phx.server
But after I run mix compile

I got the error below:

== Compilation error in file lib/rock_store_web/schema.ex ==
** (Absinthe.Schema.Error) Invalid schema:
Elixir.RockStoreWeb.Schema:0: 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:258: Absinthe.Schema.after_compile/2
(stdlib) lists.erl:1263: :lists.foldl/3
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
(elixir) lib/kernel/parallel_compiler.ex:202: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

Version informations
elixir version : 1.7.0

{:absinthe, “~> 1.4”},
{:absinthe_plug, “~> 1.4”},
{:absinthe_ecto, “~> 0.1.3”}

Am I doing something wrong?

mix phx.server should already run mix compile

Or do you mean MIX_ENV=prod mix compile (or any other environment not beeing dev)?

Also you need to provide at least parts of your RockStore.Schema module I think.

This has not been released yet. Please check if it works using 1.6.5.

As noted by @NobbZ, Absinthe is not tested on unreleased, development versions of the language. Please downgrade to 1.6.x

1 Like

Thanks!
I resolved it!

Elixir 1.7.0 has been release and this same error came up. Works great on 1.6 but not on 1.7

I checked with some older playground code of mine, and it worked.

$ cat mix.lock | grep \"absinthe\"
  "absinthe": {:hex, :absinthe, "1.4.13", "81eb2ff41f1b62cd6e992955f62c22c042d1079b7936c27f5f7c2c806b8fc436", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},

I’ve not checked any older version of absinthe.

To tell more, we need to see some actual code.

That fixes it I was using 1.4.12.

Always check with the latest version. At the time 1.4.12 was released there was no RC available, and only RCs can be considered stable (enough) to be worth the effort :wink:

Trying to keep up master can become very tedious at times, so I understand the stance to support only released versions and only test/implement against them once the first RC has been published.

2 Likes