Skip to main content
Subscription types represent the payloads received when subscribing to real-time updates via WebSocket.

ContentUpdate

Payload for content subscription updates.
type ContentUpdate {
  contentId: ID!
  content: Content
  resolvedRef: ResolvedPackageRef!
  action: String!
  timestamp: DateTime!
}
FieldTypeDescription
contentIdID!ID of the updated content
contentContentFull content object (null if exceeds 128KB)
resolvedRefResolvedPackageRef!Package IDs for caching
actionString!“update” or “delete”
timestampDateTime!When the update occurred

Handling ContentUpdate

subscription.on('data', (update) => {
  if (update.action === 'delete') {
    removeContent(update.contentId);
    return;
  }

  // Content may be null if payload exceeds 128KB
  if (update.content) {
    refreshContent(update.content, update.resolvedRef);
  } else {
    // Fetch separately
    fetchContent(update.contentId).then(content => {
      refreshContent(content, update.resolvedRef);
    });
  }
});

PreviewUpdate

Payload for preview subscription updates.
type PreviewUpdate {
  preview: PreviewResult!
  action: String!
  timestamp: DateTime!
}
FieldTypeDescription
previewPreviewResult!Component or content preview
actionString!“update” or “delete”
timestampDateTime!When the update occurred

PreviewResult Union

union PreviewResult = ComponentPreview | ContentPreview

ComponentPreview

Preview data for a component.
type ComponentPreview {
  componentId: ID!
  component: Component
  resolvedRef: ResolvedPackageRef!
}
FieldTypeDescription
componentIdID!Component ID
componentComponentComponent data (null if exceeds 128KB)
resolvedRefResolvedPackageRef!Package IDs for caching

ContentPreview

Preview data for content.
type ContentPreview {
  contentId: ID!
  content: Content
  resolvedRef: ResolvedPackageRef!
}
FieldTypeDescription
contentIdID!Content ID
contentContentContent data (null if exceeds 128KB)
resolvedRefResolvedPackageRef!Package IDs for caching

Handling Preview Updates

subscription.on('data', (update) => {
  const { preview, action } = update;

  if (action === 'delete') {
    if (preview.__typename === 'ComponentPreview') {
      removeComponentPreview(preview.componentId);
    } else {
      removeContentPreview(preview.contentId);
    }
    return;
  }

  // Handle component preview
  if (preview.__typename === 'ComponentPreview') {
    if (preview.component) {
      refreshComponentPreview(preview.component, preview.resolvedRef);
    } else {
      fetchComponent(preview.componentId).then(component => {
        refreshComponentPreview(component, preview.resolvedRef);
      });
    }
  }

  // Handle content preview
  if (preview.__typename === 'ContentPreview') {
    if (preview.content) {
      refreshContentPreview(preview.content, preview.resolvedRef);
    } else {
      fetchContent(preview.contentId).then(content => {
        refreshContentPreview(content, preview.resolvedRef);
      });
    }
  }
});

128KB Payload Limit

AWS WebSocket has a 128KB payload limit. When data exceeds this limit:
  1. The content or component field will be null
  2. The resolvedRef field is always included
  3. Use the ID to fetch the full data separately
if (!update.content) {
  // Payload exceeded 128KB, fetch separately
  const content = await fetchContent(update.contentId);
  refreshContent(content, update.resolvedRef);
}