Hi!
Any thoughts on how to get the above 2 to work together?
Best,
Terry
Hi!
Any thoughts on how to get the above 2 to work together?
Best,
Terry
Right now AFAIK Phoenix.Sync essentially maps an Ecto query to a shape, and those Ecto queries are quite limited at the moment, so there isn’t a way to take an arbitrary ash query and turn it into a shape etc.
What kind of integration are you looking for?
I have lambda functions that compute on the db and modifies the tables accordingly.
On the app side, of course its a LV → business logic → Ash → DB stack. So trying to cook up a design that lets the LV update when the data tables have been changed (by the lambda functions)
Yeah it’s an interesting question You could definitely set something up with
Phoenix.Sync
treating your Ash resources as Ecto schemas. How you actually hook that up to do useful things is kind of its own question I’ve had some chats with them about making something that works directly w/ Ash but nothing has materialized as of yet.
Sorry for revive this post, but I though it would be better than create a new one..
Do we have some news regarding Phoenix.Sync integration with Ash? I was looking at the presentation of the tech from James Arthur here https://www.youtube.com/watch?v=4IWShnVuRCg and I would love to be able to use it in my backend.
More specifically, the part that I was more interested was the integration with LiveView via sync_stream
, but instead of using Ecto schemas/queries, I would love to be able to use Ash queries from resource actions.
Is there some plan or conversation about adding some support for it?
PS. I did find kinda ironic and funny that James was using an Ash t shirt during the presentation but at the same time the library didn’t have any support for Ash haha
I’ve explored it, and have a POC, but there are some challenges. One of the main ones is the lack of multi-table shapes. however, we have added a utility that would allow you to roll your own here.
Resource
|> Ash.Query.for_read(....)
|> Ash.data_layer_query()
with returns something like {:ok, %{query: ecto_query}}
. You could then use that ecto_query
with Phoenix.Sync, in the case that it is compatible. That Ecto query will include policies, filters, calculations etc.
I don’t know if that changed, but, last time that I tried data_layer_query, it would generate a wrong query if the resource uses a custom schema, is that still the case?
they are different, you’re thinking of Ash.Query.data_layer_query, this is new, it’s Ash.data_layer_query and it should be exactly the query the data layer will run.
Ah, sorry, I didn’t realize that. I will try that out thanks!
Ash T-shirt? Where can I lay my hands on one?!
There will be a method to acquire Ash tshirts soon