Logo
NeoArc Studio

Real-Time Collaboration API Example

GraphQL API for a collaborative document editor demonstrating multiple subscriptions, WebSocket configuration, trigger descriptions, and complexity hints for rate limiting.

This example demonstrates a real-time collaborative document editing API. It showcases multiple subscription types, detailed trigger descriptions, WebSocket server configuration, and complexity hints for managing high-frequency events.

API Overview

The Collaboration API enables:

  • Document Editing - Real-time collaborative text editing
  • Cursor Tracking - Live cursor positions for all participants
  • Presence - User join/leave notifications
  • Comments - Inline comments and discussions

Server Configuration

The API requires both HTTP and WebSocket endpoints:

{
  "id": "api-collab-001",
  "name": "Collaboration API",
  "description": "Real-time collaborative document editing with presence, cursors, and comments.",
  "version": "1.0.0",
  "servers": [
    {
      "id": "production",
      "url": "https://collab.example.com/graphql",
      "wsUrl": "wss://collab.example.com/graphql",
      "description": "Production environment with global CDN",
      "healthCheckUrl": "https://collab.example.com/health",
      "introspectionEnabled": false
    },
    {
      "id": "regional-eu",
      "url": "https://eu.collab.example.com/graphql",
      "wsUrl": "wss://eu.collab.example.com/graphql",
      "description": "European region for lower latency",
      "introspectionEnabled": false
    }
  ],
  "tags": ["collaboration", "real-time", "documents"]
}

Subscriptions

The API provides four subscription types for different real-time events:

Complexity and Rate Limiting

Subscription complexity values help manage server resources:

SubscriptionComplexityTypical Event RateResource Impact
documentEdited510-50 events/second during active editingModerate bandwidth
cursorMoved25-10 events/second per active userLow bandwidth, high frequency
userPresenceChanged11-2 events/minuteMinimal impact
commentAdded3OccasionalLow frequency, moderate payload

Authentication

The API uses Bearer token authentication with WebSocket connection parameters:

{
  "authSchemes": [
    {
      "id": "bearer",
      "type": "bearer",
      "description": "JWT token for user authentication. Pass as 'Authorization' header for HTTP or in connection_init payload for WebSocket.",
      "bearerFormat": "JWT"
    }
  ],
  "defaultAuthRequirements": [
    [{ "schemeId": "bearer" }]
  ]
}

For WebSocket connections, pass the token in the connection initialisation:

{
  "type": "connection_init",
  "payload": {
    "Authorization": "Bearer eyJhbGciOiJIUzI1NiIs..."
  }
}

Query and Mutation Examples

What This Example Demonstrates

FeatureHow It's Used
Multiple SubscriptionsFour distinct subscription types for different event streams
Trigger DescriptionsDetailed explanations of when events fire and what they contain
WebSocket ConfigurationwsUrl on servers for subscription connections
Regional ServersMultiple server entries for geographic distribution
Complexity HintsDifferent values based on event frequency and payload size
Event ThrottlingDocumented throttling rates (50ms for edits, 100ms for cursors)
Connection AuthenticationBearer token in WebSocket connection_init

Related Content