But I can’t figure out how to do the same with a relationship load.
Would it be hard to have some helper in Ash to do the same thing that Repo.to_sql does but within Ash so it works all the time and also returns a list of queries in case the action will run more than one (loads, calculations, etc)?
Yes, that would be quite difficult unfortunately. At the moment there is no good helper to get the data layer query for related data, you’ll have to do that manually, i.e filtering the other resource by ids before calling Ash.Query.data_layer_query on it.
My suggestion would be to look at the logs in that case. Ecto logs all queries at debug level, so you could set your log level to debug and see all the queries being run.
Thank you so much for that suggestion, that library is amazing! I always hated that in the end the generated sql query would still need manual changes to make it a real query. That library will help a ton!!