improvement: error if relationship.api is not an Ash.Api

This commit is contained in:
Zach Daniel 2023-04-30 22:51:12 -04:00
parent 7f460009af
commit 9b323c84ed

View file

@ -14,6 +14,12 @@ defmodule Ash.Registry.ResourceValidations.Verifiers.ValidateRelatedResourceIncl
for resource <- resources do for resource <- resources do
for relationship <- Ash.Resource.Info.relationships(resource) do for relationship <- Ash.Resource.Info.relationships(resource) do
if relationship.api && !Spark.Dsl.is?(relationship.api, Ash.Api) do
raise """
Api #{inspect(relationship.api)} referenced by #{inspect(resource)}.#{relationship.name} is not a valid api
"""
end
message = message =
if relationship.api do if relationship.api do
"is not accepted by api `#{inspect(relationship.api)}`" "is not accepted by api `#{inspect(relationship.api)}`"