Ash FrameworkAF
Ash Framework3y ago
88 replies
\ ឵឵឵

Raw actions

CFE:
defmodule App.Echo do
  use Ash.Resource,
    extensions: [AshJsonApi.Resource, AshGraphql.Resource]

  actions do
    raw :echo, fn input ->
      {:ok, input}
    end
  end

  graphql do
    # ...
    mutations do
      create :echo, :echo
    end
  end

  json_api do
    # ...
    post :echo
  end
end


Would there be room for something like this in core? One of the big strengths of Ash is being able to package up business logic once and expose it over several channels, but sometimes the plumbing that makes things that fit the model so easy makes other things that don't quite fit tough.

I'm not married to the specific syntax, rather food for thought regarding the functionality. It would be great to have a layer in the middle between the JSON:API/GraphQL/etc. frontend transformers and the underlying CRUD, Query and Changeset wiring.

Is there already a way folks are accomplishing this besides manually adding plug routers/absinthe resolvers? Has there been any discussion of something like this?
Was this page helpful?