hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
30.95k stars 2.74k forks source link

Event trigger payload should support session variables for MS SQL Server #9128

Open Aiden0 opened 1 year ago

Aiden0 commented 1 year ago

Version Information

v2.13.0

Environment

OSS

What is the current behaviour?

Currently the event trigger returns the payload:

{
  "event": {
      "op": "<op-name>",
      "data": {
          "old": <column-values>,
          "new": <column-values>
      }
  },

What is the expected behaviour?

It should include the session variable as described here:

{
  "event": {
      "session_variables": <session-variables>,
      "op": "<op-name>",
      "data": {
          "old": <column-values>,
          "new": <column-values>
      }
  },

How to reproduce the issue?

  1. Create trigger
  2. Activate Trigger
  3. Look at payload

Please provide any traces or logs that could help here.

I think this is related to the payload not containing the session variable. In the DDL code here it calls the payload in the file src-rsr/mssql/mssql_insert_trigger.sql.shakespeare but the payload I don't think has the context of the active user. Not sure if can inject the current active user.

In the postgres version the current user is injected into the payload using the setting hasura.user as seen here.

tirumaraiselvan commented 1 year ago

The first version of SQL Server Event Triggers did not have session-variables intentionally. We are going to add this enhancement very soon.