Hasura Subscriptions - 1 User receiving everyone else's notifications

44 Views Asked by At

I'm running a Hasura 2.32 Server on-prem via Docker container. The backend is MSSQL 2019.

Background:
We have a Hasura Subscription to a notification table in MSSQL. The notification table has a user_id column which applies to a client logged into our front-end application (Vue2/Node). Any changes to the table will be streamed to the client which the requite User ID.

This works when a single user is logged in. And the user is able to see the table changes being streamed to them.

The Problem:

Suppose three users are logged in. There are table changes that pertain to three separate users via a single transaction. All three users should receive a notification. However, we have observed the notifications are sent to only one person. And it contains the data pertaining to all three of them. We believe this is an issue with the Hasura configuration.

It would be greatly appreciated if someone has any tips on how to troubleshoot this? Or if there's any other suggestions on how we can tackle this.

For context here's the GraphQL Query we're using:

subscription getNotification($for_user: String) { v_coverage_notification(where: { for_user: { _eq: $for_user } }, order_by: { created_dt: desc }) { read_dt coverage_notification_id coverage_id coverage_edit_history_id notification_type_cd for_user created_dt created_by_nm created_by } }

We're honestly lost on how to proceed on this. Any help would be greatly appreciated!

1

There are 1 best solutions below

1
On

Some suggestions:

  1. Verify the data in the notification table: Ensure that the for_user field in the table contains the correct user IDs for each notification. Double-check if the data is correctly inserted into the table.

  2. Can you verify that your subscriptions work in the Hasura Console with the same query?

  3. Check the subscription payload: When a notification is triggered, examine the payload received by the clients. Ensure that the for_user field in the payload corresponds to the user ID for whom the notification is intended. It's possible that the issue lies in how the payload is constructed or delivered to the clients.

  4. Test with different user scenarios: Try testing the subscription with different user scenarios, such as having only one user logged in, two users logged in, and all three users logged in simultaneously. This can help identify if the issue is specific to certain user scenarios.

  5. Check for any custom logic or middleware: If you have any custom logic or middleware in the client of your application that interacts with the Hasura subscription, review it to ensure it is not causing any unintended behavior or filtering of the notifications.

Hopefully the bug is somewhere with one of these things. Please let me know if it is sorted.