ash-project / ash

A declarative, extensible framework for building Elixir applications.
https://www.ash-hq.org
MIT License
1.63k stars 220 forks source link

Extension Proposal: ash_twirp #49

Open zachdaniel opened 4 years ago

zachdaniel commented 4 years ago

What is the purpose of the extension? twirp is an RPC framework. Ash resources ought to be capable of generating the protobuf definitions that twirp runs off of.

** How would it extend the DSL? *** I haven't looked into how we'd leverage it, but it was recommended by @keathley as a potentially good fit for Ash.

bcksl commented 1 year ago

To preserve some of the discussion on Discord: probably the first attempt at tackling anything related to a gRPC frontend for Ash would be writing a Protobuf schema builder akin to Absinthe.Blueprint that can be used to create and output Protobuf schemas programmatically from Ash resources.

As of yet, I haven't found anything that does this in the Erlang/Elixir ecosystem, though there are plenty of tools that go the other direction (Protobuf schema -> Elixir) which could potentially be leveraged against the generated schema as a stopgap, though the end goal would probably be to generate the Elixir side of things directly from the Ash resources as well.

Note that Protobuf is very sensitive to field reordering and removal, meaning that reducing schema breakage where possible involves tracking state in a way similar to the AshPostgres migration generator. Ongoing efforts to simplify this process for extensions by moving the stateful diffing logic into core would undoubtedly ease this work significantly.

Since many of the other extensions which would consume such resource change tracking information are mostly or entirely insensitive to field ordering, I wanted to point this out again so it can be under consideration while this new functionality is being developed.