It'd be nice to have predefined types ship with Hasura. One practical use case for justification is creating webhooks using Zeit's micro where it'd be nice to have typing for the event-trigger payload, headers etc.
For example, this is an example payload:
{
"event": {
"session_variables": {
"x-hasura-role": "admin"
},
"op": "INSERT",
"data": {
"old": null,
"new": {
"data": {
"args": [
123
],
"func": "dosomething"
},
"id": 2
}
}
},
"created_at": "2019-09-26T05:59:40.568009Z",
"id": "8ff13b13-7892-4d3c-888a-f637074b660f",
"delivery_info": {
"max_retries": 0,
"current_retry": 0
},
"trigger": {
"name": "testtrigger"
},
"table": {
"schema": "public",
"name": "test_table"
}
}
Like this ?
export interface Payload<T = any> {
event: {
session_variables: { [x: string]: string }
op: 'INSERT' | 'UPDATE' | 'DELETE' | 'MANUAL'
data: {
old: T | null
new: T | null
}
}
created_at: string
id: string
delivery_info: {
max_retries: number
current_retry: number
}
trigger: {
name: string
}
table: {
schema: string
name: string
}
}
Most helpful comment
Like this ?