Howtographql: Update docs for Elixir-Absinthe: Invalid schema The root query type must be implemented and be a of type Object

Created on 23 Apr 2019  路  5Comments  路  Source: howtographql/howtographql

The version numbers in the Elixir/Absinthe/GraphQL docs are out of date and might throw this error when trying to compile for the first time:

== Compilation error in file lib/community_web/schema.ex ==
** (Absinthe.Schema.Error) Invalid schema:
Elixir.CommunityWeb.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:230: 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:208: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

Running: mix.deps.update --all fixed the issue for me.

Most helpful comment

I'm still quite new to the Elixir ecosystem so I'm not entirely sure what was causing the issue, however I fixed it by adding the following dependencies:

      {:absinthe_plug, "~> 1.4.0"},
      {:dataloader, "~> 1.0.0"}

Also make sure to remove the absinthe_ecto dependency, it was deprecated in favor of dataloader

All 5 comments

Additionally, I needed {:poison, "~> 3.1"} in my mix.exs to get the GraphiQL endpoint to work

@rossvz do you know of any other fix? I executed mix deps.update --all to no avail.

I'm still quite new to the Elixir ecosystem so I'm not entirely sure what was causing the issue, however I fixed it by adding the following dependencies:

      {:absinthe_plug, "~> 1.4.0"},
      {:dataloader, "~> 1.0.0"}

Also make sure to remove the absinthe_ecto dependency, it was deprecated in favor of dataloader

986

@burrelle Looks like your PR is approved. However, I still got the error. I had to update my absinthe versions as following

{:absinthe_ecto, "~> 0.1.3"},
{:absinthe_plug, "~> 1.4.0"},
Was this page helpful?
0 / 5 - 0 ratings