Current Supports dockerSupportsJs run handlers with this argument:
async ({
deep, // instance of DeepClient
gql, // gql string template tag for deep.apolloClient
require, // require in isolation provider context
data: {
oldLink, // available if update or delete
// { id, from_id, to_id, type_id }
newLink, // available if insert or update delete
// { id, from_id, to_id, type_id }
promiseId, // id of promise where handle works
// number
},
}) => {
// your handler code
return {};
}
Create a type for insert instances of which we will handle.
mutation {
insert_links(objects: {
type_id: 1
}) { returning { id } }
}

{
"data": {
"insert_links": {
"returning": [
{
"id": 328
}
]
}
}
}
Create SyncTextFile with script to handle insert event.
We known about types Handler and Supports, and we known about dockerSupportsJs from parent article Handlers .


mutation {
insert_links(objects: {
type_id: 30
string: { data: { value: "() => { return { hello: 'world' } }" } },
in: { data: {
type_id: 35,
from_id: 85
} },
}) { returning { id in { id } } }
}
{
"data": {
"insert_links": {
"returning": [
{
"id": 330,
"in": [{ "id": 331 }]
}
]
}
}
}

Attach Handler to type with HandleInsert
mutation {
insert_links(objects: {
type_id: 49,
to_id: 331 # <== Handler from prev result
from_id: 328 # <== our type
}) { returning { id } }
}
{
"data": {
"insert_links": {
"returning": [
{
"id": 338
}
]
}
}
}

Check handlers works.
mutation {
insert_links(objects: {
type_id: 328,
}) {
returning { id }
}
}
{
"data": {
"insert_links": {
"returning": [
{
"id": 358
}
]
}
}
}

Result:
358 link instance of our 328 type created before
360 link instance of type Then from 358 to 359359 link instance of type Promise symbolise awaiting calculationsSyncTextFile founded by Handler.
362 link instance of type Resolved with other Resolved and Rejected links inserts after code execution. Each of Reserved or Rejected reference by to_id to PromiseResult of each execution.PromiseResult 361 contains object { hello: "world" } because code returns it.