barnabasJ

barnabasJ

Ash Core Team

Stop Subscription resolver without returning a value

I’m trying to add support for subscriptions to AshGraphql and I got a simple subscription working but now I’m a bit stuck.

So far I have added a way to add a new subscription and closed the loop by providing the needed notifications and resolver.

But so far it just works for plain subscriptions without some arguments.

e.g.

subscription {
  bucketCreated {
    id
    name
  }
}

What I’m trying to do is make it possible to add a filter argument to the subscription to allow the subscriber to select which resources he wants to be notified about.

Something like this

subscription {
  bucketCreated(filter: {name: {eq: "test}}}) {
    id
    name
  }
}

Now, I’m a bit stuck on how to configure the topics/context_ids. The problem is at the time a subscription is created, I could potentially serialize the filter and use it as the topic, but then I don’t really have a good way to notify the subscription when a change occurs because there are too many possible filters.

On the other hand, if I use a generic topic, the resolver is called for all the subscriptions. In the resolver, I could potentially check if the resource that triggered the change matches the filter and return in that case, but at that point, I haven’t found a way to stop the resolution without returning a value.

Another thing I looked at was if there was a way to see what subscriptions are currently active in the trigger and use that information to trigger the respective topics, but I also didn’t find a way to do this.

Does someone know of a way to achieve this?

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New