Ash GraphQL Subscriptions
Do AshGraphQL subscriptions fire when resources are updated via code interface or only when updated through GraphQL mutations?
Having some trouble with getting my subscriptions to fire on my frontend when updating changes on my backend as part of a workflow
10 Replies
it uses Ash notifiers, so as long as it goes through a configured action it should fire, doesn't matter if gql or not
Would this also be true if im triggering an update action through an iex session?
Should work as long as you called an ash action
Thanks for confirming! im still running into issues that ive been trying to solve for a couple days now
I'm updating via code interface like:
I can see the subscription being made via sockets on my react frontend but the messages never come thru
weirdly its working for all my other resources but this one
could it be something with permissions, we filter results that a subscribed client isn't allowed to see, and not send that over the wire
I would start looking around here https://github.com/ash-project/ash_graphql/blob/d724c46d7d44cd516e26155d144ee7fe3f569867/lib/subscription/batcher.ex#L287-L287
maybe add some IO.inspects here to see what's going on
GitHub
ash_graphql/lib/subscription/batcher.ex at d724c46d7d44cd516e26155d...
The extension for building GraphQL APIs with Ash. Contribute to ash-project/ash_graphql development by creating an account on GitHub.
ill take a look, could it be because this resource doenst have multitenacy enabled while the others working do?
🤔 could be. Definitely a case I haven't thought of before. If you can reproduce it in a test or in a separate repo. I can talk a look directly
sounds good
OK!
took your advice here
Always seems to pass tenant from changeset:
https://github.com/ash-project/ash_graphql/blob/3fe8b4ce467995875873fb3d8c0e57a99b281cf3/lib/subscription/notifier.ex#L27
Here as well:
https://github.com/ash-project/ash_graphql/blob/3fe8b4ce467995875873fb3d8c0e57a99b281cf3/lib/subscription/config.ex#L49
GitHub
ash_graphql/lib/subscription/config.ex at 3fe8b4ce467995875873fb3d8...
The extension for building GraphQL APIs with Ash. Contribute to ash-project/ash_graphql development by creating an account on GitHub.
GitHub
ash_graphql/lib/subscription/notifier.ex at 3fe8b4ce467995875873fb3...
The extension for building GraphQL APIs with Ash. Contribute to ash-project/ash_graphql development by creating an account on GitHub.
going to try and test out adding multi tenancy to this same resource see if it works - but the resource shoudln't have tenancy its always global
yeah confirmed it was the issue 🙂