hasura / hasura/graphql-engine

Event trigger payload should support session variables for MS SQL Server

Open
#9,128 1 comment 0 reactions 0 assignees View on GitHub
a/eventing/data-triggers t/gql-services
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information
v2.13.0

### Environment

OSS

### What is the current behaviour?

Currently the event trigger returns the payload:

```
{
"event": {
"op": "",
"data": {
"old": ,
"new":
}
},
```

### What is the expected behaviour?

It should include the session variable as described [here](https://hasura.io/docs/latest/event-triggers/payload/):

```
{
"event": {
"session_variables": ,
"op": "",
"data": {
"old": ,
"new":
}
},
```

### 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](https://github.com/hasura/graphql-engine/blob/5c774cf839f28d7138b88dc6a6387732942441b1/server/src-lib/Hasura/Backends/MSSQL/DDL/EventTrigger.hs#L749) 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](https://github.com/hasura/graphql-engine/blob/db710d38b7e1c69918fb007e7a09644baf1f8fab/server/src-rsr/init_pg_source.sql#L85).

Contributor guide

Open the contributing guide

Research direction

Start with server/src-lib/Hasura/Backends/MSSQL/DDL/EventTrigger.hs and the referenced src-rsr/mssql/mssql_insert_trigger.sql.shakespeare payload. Compare the MSSQL path with server/src-rsr/init_pg_source.sql, which the issue identifies as the PostgreSQL precedent. Done means MSSQL event-trigger payloads include session_variables as documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.