ash-project / ash-project/ash_graphql
Subscription DSL filter causes filtered events to become errors
- Dominant language
- Elixir
- Stars
- 97
- Forks
- 101
- Avg merge
- 12h 51m
- Merged PRs (30d)
- 5
Description
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
### AI Policy
- [x] I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.
### Versions
Elixir - 1.18.4
Erlang - 28.0.2
Ash - 3.5.34
AshGraphql - 1.8.2
Absinthe - 1.7.10
### Operating system
MacOS 15.6
### Current Behavior
When using the subscription DSL filter, when a filter is applied, the events that out to be excluded are still sent with a `nil` payload and an error `code: not_found`.
Example:
```gql
subscription($filter: TestResourceFilterInput) {
testResourceCreated(filter:$filter) {
created {
id
choice
}
}
}
```
```elixir
%Phoenix.Socket.Message{
topic: "__absinthe__:doc:unRcSrcuHkiBCReefuo40W42GErDK62KmQKrtqYnwyU=:1E9C1D467CBCCEB83F768CA9C9AD88068931E40CF6C347A4D1FB07F29F3762C0",
event: "subscription:data",
payload: %{result: %{data: %{"testResourceCreated" => nil},
errors: [%{code: "not_found", message: "could not be found", path: ["testResourceCreated"], fields: [], vars: [], short_message: "could not be found", locations: [%{line: 2, column: 3}]}]},
subscriptionId: "__absinthe__:doc:unRcSrcuHkiBCReefuo40W42GErDK62KmQKrtqYnwyU=:1E9C1D467CBCCEB83F768CA9C9AD88068931E40CF6C347A4D1FB07F29F3762C0"}, ref: nil, join_ref: nil
}
```
In the gql playground, this results in just a `null` event without the included error message which is particularly unhelpful.
```json
{
"data": {
"testResourceCreated": null
}
}
```
### Reproduction
[Reproduction Repo](https://github.com/justin-m-morgan/ash_gql_sub_bug)
### Expected Behavior
When a filter is applied to a subscription, excluded events should not be sent to the subscriber as error events with no data payload.
Contributor guide
Research direction
Start with the linked ash_gql_sub_bug reproduction repo and the subscription DSL filter behavior shown in the issue. Verify that a filtered-out event produces no subscription event or error, while an included event still carries its payload; use the reported GraphQL subscription and Phoenix socket message as the observable result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir, graphql
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100