Problems reading types in absinthe

Using Ecto v2.2.6, Phoenix 1.3

I am using absinthe for my blog app. My mix.exs:

      {:absinthe, "~> 1.3.0-rc.0"},
      {:absinthe_plug, "~> 1.3.0-rc.0"},
      {:absinthe_ecto, git: "https://github.com/absinthe-graphql/absinthe_ecto.git"},

My app has two contexts, with several schemas listed in each:

Accounts:
Users,
Following (user-user linking table)

Content:
Posts,
Likes (user-post linking table),
Repost (user-post linking table)

I have a types.ex file and a schema.ex file. Types starts with:

defmodule Blog.Schema.Types do
  use Blog.Schema.Notation
  use Blog.Ecto, repo: Blog.Repo

 object :user do ...

…and lists all of the types. schema.ex starts with:

defmodule Blog.Schema do
  use Absinthe.Schema
  import_types Blog.Schema.Types

 query do ...

My queries/mutations all work, except for the :following. When I try to get a list_of(:following), the console says:

...schema.ex:72: Followings :following is not defined in your schema.

  Types must exist if referenced.

But when I cut the object declaration from types.ex and paste it into schema.ex (plus the appropriate use directives), right before the query directives, it works just fine. It’s only this one object, which seems no different from the others.

How does absinthe read the object declarations? Is it possible that elixir is somehow caching something when I run phx.server?

Hey!

Sorry to hear you’re having troubles. Without a more complete code example it’s a bit hard to diagnose the issue. You don’t even show what type the :following identifier refers to.

As an aside, 1.3.0-rc was released months ago, you should probably upgrade to 1.3.2 or consider the 1.4.0-rc.

1 Like

This is a hard one to represent. Typically I reproduce bugs on a new phoenix app in isolation and then post that, but I can’t reproduce this one. I would fill several screens with code, more than is polite for the forum. It’s working, and I’ll post if I figure out the problem.

Thanks a lot for absinthe, btw!

@benwilson512 Solved it. There was another object called :subscription that was breaking everything due to a naming collision. I think you’re already aware of that one. Is it possible to provide an error message for this issue?

Ah yes, there will be a warning in the next release: https://github.com/absinthe-graphql/absinthe/pull/396

1 Like