fix: use create generators for embedded types

This commit is contained in:
Zach Daniel 2022-12-19 11:06:53 -05:00
parent c4b2701d65
commit 6a5543e291

View file

@ -267,10 +267,15 @@ defmodule Ash.Type do
Code.ensure_compiled!(type)
if function_exported?(type, :generator, 1) do
type.generator(constraints)
if Ash.Type.embedded_type?(type) do
action = constraints[:create_action] || Ash.Resource.Info.primary_action!(type, :create)
Ash.Generator.action_input(type, action)
else
raise "generator/1 unimplemented for #{inspect(type)}"
if function_exported?(type, :generator, 1) do
type.generator(constraints)
else
raise "generator/1 unimplemented for #{inspect(type)}"
end
end
end