Skip to content

Improve error handling for page GraphQL query #35351

@fmontes

Description

@fmontes

Description

Enhance error handling for page GraphQL queries to provide structured, programmatic error codes and better error context for API consumers.

Current Issues

  • Error messages lack structure (no error codes)
  • Difficult for clients to handle specific error cases
  • Missing HTTP status hints from backend
  • Inconsistent error handling between GraphQL errors and data transformations

Solution

Implement structured error handling with:

  1. Standardized error codes (NOT_FOUND, PERMISSION_DENIED, BAD_REQUEST, INVALID_LANGUAGE)
  2. HTTP status codes in error responses
  3. Proper distinction between query failures (bad GraphQL) and missing resources
  4. Support for partial errors in successful responses
  5. Enhanced error context (resourceType, resourceId)

Acceptance Criteria

  • Backend throws structured GraphQL exceptions with error codes and status
  • Frontend SDK extracts and exposes error codes and status
  • DotErrorPage includes status and code properties
  • Partial errors in successful responses are captured in response.errors
  • All error handling tests pass with new error structure
  • Error codes properly map to HTTP status codes
  • Backward compatible with existing error handling

Files Changed

  • Backend: PageDataFetcher.java, PermissionDeniedGraphQLException.java
  • Frontend: page-api.ts, page-api.spec.ts
  • Types: public.ts (DotErrorPage, DotCMSGraphQLError)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions