Skip to main content
GraphQL errors follow the standard GraphQL error format with additional extensions for error codes.

Error Format

Common Error Codes

CodeHTTP StatusDescription
NOT_FOUND404Resource not found
UNAUTHORIZED401Invalid or missing API key
FORBIDDEN403Insufficient permissions
BAD_REQUEST400Invalid query or variables
INTERNAL_ERROR500Server error

Preview-Specific Error Codes

CodeDescription
INVALID_PREVIEW_TOKENInvalid or expired preview token
PREVIEW_NOT_FOUNDPreview resource not found or deleted
VERSION_NOT_FOUNDComponent version not found
MISSING_PREVIEW_TOKENPreview token required but not provided

Error Examples

Resource Not Found

Unauthorized

Invalid Preview Token

Version Not Found

Validation Error

Client-Side Error Handling

JavaScript

Apollo Client

React Hook

Subscription Error Handling

Best Practices

  1. Always check for errors: GraphQL can return partial data with errors
  2. Use error codes: Check extensions.code for programmatic error handling
  3. Handle NOT_FOUND gracefully: Resources may be deleted or unpublished
  4. Implement retry logic: Network errors may be transient
  5. Log errors: Include path and extensions for debugging
  6. Differentiate preview errors: Preview tokens can expire independently of API keys