AF
Ash Framework•2mo ago
Dam

Adding new create action produces error in resource schema

I have two resources in the same domain, Container, Image and ImageCredentials. Container has a belongs_to relationship with Image, Image has a has_many relationship with Container and a belongs_to relationship with ImageCredentials, while this last one has a has_many relationship with it. Container has a create action (:create_with_nested), with the purpose of creating a new Image in case of a failed match or lookup. I'm fairly new to Ash, and I tried to add the same logic to Image if it cannot match or lookup a ImageCredentials by adding the following :create_with_nested action to Image:
create :create_with_nested do
accept [:reference]

argument :credentials, :map

change manage_relationship(:credentials,
on_no_match: :create,
on_lookup: :relate,
on_match: :ignore,
use_identities: [:label]
)
end
end
create :create_with_nested do
accept [:reference]

argument :credentials, :map

change manage_relationship(:credentials,
on_no_match: :create,
on_lookup: :relate,
on_match: :ignore,
use_identities: [:label]
)
end
end
and modifying Container's :create_with_nested to use it on a failed match: on_no_match: {:create, :create_with_nested}. In doing so, I come across a compile error that I don't really understand:
== Compilation error in file lib/edgehog_web/schema.ex ==
** (Absinthe.Schema.Error) Compilation failed:
---------------------------------------
## Locations
.../deps/ash_graphql/lib/resource/resource.ex:1554

In field Credentials, :image_create_with_nested_credentials_input is not defined in your schema.

Types must exist if referenced.


(absinthe 1.7.8) lib/absinthe/schema.ex:414: Absinthe.Schema.__after_compile__/2
(stdlib 6.0) lists.erl:2146: :lists.foldl/3
== Compilation error in file lib/edgehog_web/schema.ex ==
** (Absinthe.Schema.Error) Compilation failed:
---------------------------------------
## Locations
.../deps/ash_graphql/lib/resource/resource.ex:1554

In field Credentials, :image_create_with_nested_credentials_input is not defined in your schema.

Types must exist if referenced.


(absinthe 1.7.8) lib/absinthe/schema.ex:414: Absinthe.Schema.__after_compile__/2
(stdlib 6.0) lists.erl:2146: :lists.foldl/3
This error is triggered only if the Container's :create_with_nested is present, but doesn't come up if I revert it to use the default create for Image. Am I doing something wrong? To me the relationship between Container and Image looks no different from the one between Image and ImageCredentials, so I don't see why manage_relationship/3 works for one but not the other
2 Replies
ZachDaniel
ZachDaniel•2mo ago
Hm...this looks like a bug in AshGrapqhl 🤔 Could you work up a production and open an issue?
Dam
DamOP•2mo ago
I should mention the project is using Ash v3.4.53 and AshGraphql v1.5.0 If that makes any difference I'll still try to work on a small reproduction

Did you find this page helpful?