Skip to content

Simple Record Subscriptions

You can subscribe to records being created, updated, and deleted using Archie Core’s auto-generated GraphQL subscription operation.

In the following examples, we have a table called students, which contains fields and relations like id, firstName, email.

Subscription for listening to table records being created.

mutation createSubscription($input: SubscriptionInput!) {
system {
createSubscription(input: $input) {
id
active
name
}
}
}
{
"input": {
"name": "students_create",
"description": "Subscription - students table, operation create",
"active": true,
"tables": [
{
"table": "students",
"operations": ["CREATE"],
"fields": ["id", "first_name", "email"]
}
]
}
}
{
"data": {
"system": {
"createSubscription": {
"id": "id_subscription",
"active": true,
"name": "students_create"
}
}
}
}

Subscription for listening to table records being updated.

mutation updateSubscription ($input: SubscriptionInput!) {
system {
updateSubscription( input: $input ) {
id
name
description
}
}
}
{
"input": {
"id": "id_subscription",
"name": "students_create",
"description": "Subscription - students table, operation create",
"active": true,
"tables": [
{
"table": "students",
"operations": ["UPDATE", "CREATE", "DELETE"],
"fields": ["id", "first_name"]
}
]
}
}
{
"data": {
"system": {
"updateSubscription": {
"id": "id_subscription",
"name": "students_create",
"description": "Subscription - students table, operation create"
}
}
}
}

Subscription for listening to table records being deleted.

mutation deleteSubscription($id: String!) {
system {
deleteSubscription(id: $id)
}
}
{
"id": "id_subscription"
}
{
"data": {
"system": {
"deleteSubscription": true
}
}
}