Flattening Polymorphic Relationships in Ash GraphQL
Hey folks 
I’m working with polymorphic relationships in Ash and followed the guide here: https://hexdocs.pm/ash/polymorphic-relationships.html. I tried exposing it through the GraphQL API, and I’m a bit unsure if there’s a way to shape the schema the way I want.
Right now, when I query
So BankAccount gives me the shared fields, and the account-specific fields are nested under implementation.
What I’d like instead is something more “flattened,” where the
That way, the shared fields (
In my mind, this seems like it could involve creating a custom type and resolver, but I wasn’t sure if I should dive down that path or if there’s a simpler/standard way in Ash to achieve this.
Is there a way to configure Ash GraphQL to expose polymorphic relationships like this, or is the nested implementation structure the standard/only approach?
Thanks a lot!
I’m working with polymorphic relationships in Ash and followed the guide here: https://hexdocs.pm/ash/polymorphic-relationships.html. I tried exposing it through the GraphQL API, and I’m a bit unsure if there’s a way to shape the schema the way I want.
Right now, when I query
bankAccounts, I get something like this:So BankAccount gives me the shared fields, and the account-specific fields are nested under implementation.
What I’d like instead is something more “flattened,” where the
bankAccounts field itself is the union/interface, so I can query like this:That way, the shared fields (
id, name) and the resource-specific fields (overdraftLimit or interestRate) all come back directly, without the extra implementation wrapper.In my mind, this seems like it could involve creating a custom type and resolver, but I wasn’t sure if I should dive down that path or if there’s a simpler/standard way in Ash to achieve this.
Is there a way to configure Ash GraphQL to expose polymorphic relationships like this, or is the nested implementation structure the standard/only approach?
Thanks a lot!
Solution
no that would be graphql interfaces IIRC and we don't really have anything for this at the moment
