barnabasJ

barnabasJ

Ash Core Team

You can now add subscriptions using the DSL.

subscriptions do
  pubsub YourAppWeb.Endpoint

  subscribe :something_changed do
    action_types [:create, :update, :destroy]
  end
end

Right now, you still need to add the dependency from github. A release will follow soon.
I created a small demo video showing the setup.

Showing Posts 1 to 5

sezaru

sezaru

Amazing work! I will try it out asap!

Off-topic: I noticed that around 6:10 of the video, you saved a Ash resource and the formatter changed the resource code blocks order. How did you do that?

sezaru

sezaru

Also, another question.

Can you somehow add logic to filter out data based on some criteria?

For example, let’s say I have a resource that contains data for multiple organizations, I want to subscribe to that resource actions, but I don’t want it to allow an me to subscribe to all data from all organizations for that resource, only for the ones that are from my own organization.

zachdaniel

zachdaniel

Creator of Ash

What you subscribe to is a query built for a read action, so that read action can contain filters. Additionally, if you have policies that filter the data, they will be applied to all data before a notification is sent.

zachdaniel

zachdaniel

Creator of Ash

That is the Spark.Formatter plugin. You can configure it to set a section order for any Spark DSL including Ash.Resource.

bastiW

bastiW

Minimal Reproduction example

Including

  • AshGraphql
  • AshSqlite

https://github.com/bastiW/my_subscription_app_sqlite

In the meanwhile you can skip most steps shown in the Video. As the CLI is doing that for you. You just need to run some cli commands and then modify the resource

If you want to start from scratch you can run:

Setup new project (I think the commands provide on the ash-hq site would also work)

mix igniter.new my_subscription_app_sqlite --with phx.new --install ash,ash_sqlite,ash_graphql,absinthe_phoenix

Create a resource

mix ash.gen.resource MySubscriptionApp.Posts.Post --uuid-v7-primary-key id --attribute title:string:required:public --attribute text:string:required:public --extend graphql,sqlite

Modify the post resource:
https://github.com/bastiW/my_subscription_app_sqlite/blob/main/lib/my_subscription_app/posts/post.ex

Switch from simple GraphQL interface to playground - as the simple seem to not support the subscriptions:
https://github.com/bastiW/my_subscription_app_sqlite/commit/5542ffc7770475b4443a60792ba886fbeb2a7b86

— All posts loaded —

Where Next? Top

Trending in News & Updates Top

sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
kip
I’m a bit excited to announce that Localize and friends are now at release 1.0. Even though it’s a 1.0 release, it stands on 8 years of w...
New
bartblast
Hologram v0.11 is out! Two headline features this release. First, Elixir regexes now run in the browser. They were server-only until now,...
New
nseaSeb
Just published search_ash 0.5.0 (with search_core 0.4.0) on Hex. What’s new: synonyms You can now declare a synonym dictionary per lang...
New
mudasobwa
MdexMultilineCells is an MDEx plugin enabling multi-line cells in Markdown tables with full inline/block Markdown rendering and automati...
New
sorenone
This release unifies configuration for queues, repos, and services, swaps opaque timing integers for readable durations, and backports pe...
New
jvoegele
Bond brings Design by Contract to Elixir: preconditions, postconditions and invariants as executable specifications, checked at runtime a...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews