تخطَّ إلى المحتوى

اشتراكات السجلات البسيطة

يمكنك الاشتراك في السجلات التي يتم إنشاؤها وتحديثها وحذفها باستخدام عملية اشتراك GraphQL المُنشأة تلقائيًا بواسطة Archie Core.

في الأمثلة التالية، لدينا جدول يسمى students، والذي يحتوي على حقول وعلاقات مثل id و firstName و email.

اشتراك للاستماع إلى سجلات الجدول التي يتم إنشاؤها.

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"
}
}
}
}

اشتراك للاستماع إلى سجلات الجدول التي يتم تحديثها.

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"
}
}
}
}

اشتراك للاستماع إلى سجلات الجدول التي يتم حذفها.

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