Skip to content

GraphQL Subscriptions

A GraphQL subscription is a web-socket connection where the client receives an event with data whenever the observed event occurs upstream.

All projects tables can receive subscriptions through the project endpoint using wss protocol.

wss://archie-core.archie-platform.com/subscriptions?project_id=projectID

For the sake of the any examples, let’s consider a scenario where a table called students exists, having expected fields and relations like firstName, email.

To create a new subscription configuration, you use the system { createSubscription } mutation. This operation defines the rules for a subscription, including which tables to watch and what operations (Create, Update, Delete) should trigger an event.

mutation createNewSubscription($input: SubscriptionInput!) {
system {
createSubscription(input: $input) {
id
active
name
}
}
}
{
"input": {
"name": "students_all",
"description": "Subscription all operations",
"active": true,
"tables": [
{
"table": "students",
"operations": ["UPDATE", "CREATE", "DELETE"],
"fields": ["first_name", "email"]
}
]
}
}