In Rootquerytype, ... is not defined in your schema

This is a really simple example but I have no idea why it’s not working, I triple checked that I have everything setup as described in the docs.

I am trying to import fields, here’s my root schema

defmodule AuctionBackendGraphql.Schema do
  use Absinthe.Schema

  import_types(__MODULE__.ItemTypes)

  query do
    import_fields(:item_queries)
  end
end

And I am trying to import queries from here

defmodule AuctionBackendGraphql.Schema.ItemQueries do
  use Absinthe.Schema.Notation
  alias AuctionBackendGraphql.Resolver

  object :item_queries do
    field :list_items, &Resolver.Item.list_items/3
  end
end

And I am getting an error as such

In Rootquerytype, :item_queries is not defined in your schema.

Types must exist if referenced.

This is my project structure

https://imgur.com/a/WaAWQoU

New to absinthe and phoenix as a whole, so this is probably something really stupid

The error message you are getting isn’t very good at pointing to the real issue, but this code here is at least definitely wrong. You don’t have a type defined for this field, it should look something like:

field :list_items, list_of(:item) do
  resolve &Resolver.Item.list_items/3
end
2 Likes

Oh, missed that, but still getting the same error, its a small project so I just pushed it to git and here is the graphql part

I think you also need to add import_types __MODULE__.ItemQueries since you :item_queries object is defined there.

2 Likes

Yeah that was the case, didn’t know I needed both the types and the fields for a single object. Thank you both