barnabasJ
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?
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









