콘텐츠로 이동

GraphQL 구독

GraphQL 구독은 관찰된 이벤트가 업스트림에서 발생할 때마다 클라이언트가 데이터가 포함된 이벤트를 수신하는 웹 소켓 연결입니다.

모든 프로젝트 테이블은 wss 프로토콜을 사용하여 프로젝트 엔드포인트를 통해 구독을 받을 수 있습니다.

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

모든 예제를 위해 firstName, email과 같은 예상 필드 및 관계를 포함하는 students라는 테이블이 존재하는 시나리오를 고려해 보겠습니다.

새 구독 구성을 생성하려면 system { createSubscription } 뮤테이션을 사용합니다. 이 작업은 감시할 테이블과 이벤트를 트리거해야 하는 작업(생성, 업데이트, 삭제)을 포함하여 구독에 대한 규칙을 정의합니다.

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