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 100KB)
resolvedRefResolvedPackageRef!Package IDs for caching
actionString!"CREATED", "UPDATED", or "DELETED"
timestampDateTime!When the update occurred

Handling ContentUpdate

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

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

ComponentUpdate

Payload for component subscription updates.
type ComponentUpdate {
  componentId: ID!
  component: Component
  resolvedRef: ResolvedPackageRef!
  action: String!
  timestamp: DateTime!
}
FieldTypeDescription
componentIdID!ID of the updated component
componentComponentFull component object (null if exceeds 100KB)
resolvedRefResolvedPackageRef!Package IDs for caching
actionString!"CREATED", "UPDATED", "PUBLISHED", or "DELETED"
timestampDateTime!When the update occurred

PackageUpdate

Payload for package subscription updates.
type PackageUpdate {
  packageId: ID!
  resolvedRef: ResolvedPackageRef!
  action: String!
  timestamp: DateTime!
}
FieldTypeDescription
packageIdID!ID of the updated package
resolvedRefResolvedPackageRef!Package IDs for caching
actionString!"CREATED", "UPDATED", "PUBLISHED", or "DELETED"
timestampDateTime!When the update occurred

PreviewUpdate

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

PreviewResult Union

union PreviewResult = ComponentPreview | ContentPreview

ComponentPreview

Preview data for a component.
type ComponentPreview {
  componentId: ID!
  componentName: String!
  component: Component
  resolvedRef: ResolvedPackageRef!
}
FieldTypeDescription
componentIdID!Component ID
componentNameString!Component name for display/recents
componentComponentComponent data (null if exceeds 100KB)
resolvedRefResolvedPackageRef!Package IDs for caching

ContentPreview

Preview data for content.
type ContentPreview {
  contentId: ID!
  contentName: String!
  contentTypeName: String!
  content: Content
  resolvedRef: ResolvedPackageRef!
}
FieldTypeDescription
contentIdID!Content ID
contentNameString!Content name for display/recents
contentTypeNameString!Content type name for display/recents
contentContentContent data (null if exceeds 100KB)
resolvedRefResolvedPackageRef!Package IDs for caching

Handling Preview Updates

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

  if (action === 'DELETED') {
    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);
      });
    }
  }
});

100KB Payload Limit

AWS WebSocket has a payload limit. When data exceeds 100KB:
  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 100KB, fetch separately
  const content = await fetchContent(update.contentId);
  refreshContent(content, update.resolvedRef);
}