Hi I’ve recently been working on an Ash 3.0 migration.
== Compilation error in file lib/dentallog_web/schema.ex ==
** (Protocol.UndefinedError) protocol Enumerable not implemented for nil of type Atom
(elixir 1.16.1) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.16.1) lib/enum.ex:166: Enumerable.reduce/3
(elixir 1.16.1) lib/enum.ex:4399: Enum.reduce/3
(ash_graphql 1.0.0-rc.3) lib/resource/resource.ex:2785: anonymous fn/5 in AshGraphql.Resource.define_map_types/5
(elixir 1.16.1) lib/enum.ex:4329: Enum.flat_map_list/2
(ash_graphql 1.0.0-rc.3) lib/resource/resource.ex:2766: anonymous fn/4 in AshGraphql.Resource.map_definitions/3
(elixir 1.16.1) lib/enum.ex:4329: Enum.flat_map_list/2
(ash_graphql 1.0.0-rc.3) lib/resource/resource.ex:1685: AshGraphql.Resource.type_definitions/4
However, during the migration, I get the above error.
I think it’s probably related to Ash.Type.NewType.
Here are the types I’m using
types.ex
defmodule Dentallog.DentalDiary.Types.GroupByDateDiary do
use Ash.Type.NewType,
subtype_of: :map
use AshGraphql.Type
@impl AshGraphql.Type
def graphql_type(_), do: :group_by_date_diary
end
schema.ex
defmodule DentallogWeb.Schema do
use Absinthe.Schema
@domains [
Dentallog.Accounts,
Dentallog.DentalDiary,
Dentallog.QuestionAnswer,
Dentallog.DentalLab
]
use AshGraphql, domains: @domains
query do
end
mutation do
end
object :group_by_date_diary do
field :visited_date, :string
field :diaries, list_of(:dental_diary)
end
object :cancel_thumb_up_response do
field :count_of_thumb_up, :integer
end
end
I saw the above documentation and realised that it no longer supports the :map type.
defmodule Dentallog.DentalDiary.Types.GroupByDateDiary do
use Ash.Type.NewType,
subtype_of: :union, constraints: [
types: [
visited_date: [
type: :string
],
diaries: [
type: {:array, :dental_diary}
]
],
]
use AshGraphql.Type
@impl AshGraphql.Type
def graphql_type(_), do: :group_by_date_diary
end
Actually, I still don’t know, and it would be great if you could shed some light on this.