dotCMS / dotCMS/core

SDK: Make `DotCMSLayoutBody` Support GraphQL Page Response

Open
#31,513 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Priority : 2 High Team : Scout Type : Task
Dominant language
Java
Stars
970
Forks
486
Avg merge
3d 33m
Merged PRs (30d)
170

Description

Parent Issue

#30943

Problem Statement

The DotCMSLayoutBody component does not support rendering pages fetched via GraphQL due to differences in the container structure format between the Page API and GraphQL API.

Format Differences
Page API (Existing Support)

The containers are structured as an object with identifiers as keys, making them easy to reference:

{
  "containers": {
    "//demo.dotcms.com/application/containers/default/": {
      "containerStructures": [],
      "rendered": {},
      "contentlets": {},
      "container": {}
    }
  }
}
GraphQL API (Not Supported)

The containers are structured as an array of objects, making direct access more complex:

{
  "containers": [
    {
      "path": "//demo.dotcms.com/application/containers/default/",
      "identifier": "69b3d24d-7e80-4be6-b04a-d352d16493ee",
      "maxContentlets": 25,
      "containerStructures": [],
      "containerContentlets": []
    }
  ]
}
Task

Modify DotCMSLayoutBody to support both Page API and GraphQL API responses without requiring modifications to the GraphQL response format.

Proposed Objective

Same as Parent Issue

Proposed Priority

Priority 2 - Important

Acceptance Criteria
  • [ ] Update DotCMSLayoutBody to correctly process both Page API and GraphQL API responses.
  • [ ] Implement logic to normalize the GraphQL response format inside DotCMSLayoutBody (without modifying the original GraphQL response).
  • [ ] Ensure that existing functionality for Page API remains unchanged.
  • [ ] Validate that all containers and their contentlets are properly rendered regardless of the API source.
  • [ ] Write unit tests to verify that DotCMSLayoutBody correctly handles both response formats.
Implementation Notes
  • We can use the existing transformation function in the SDK to normalize GraphQL responses into the expected structure:

https://github.com/dotCMS/core/blob/78ac4589738e55412df42fcc5e98629c5ba0d445/core-web/libs/sdk/client/src/lib/utils/graphql/transforms.ts#L50-L74

  • Important: The normalization should be handled inside DotCMSLayoutBody and not by modifying the GraphQL API response itself.

Quality Assurance Notes & Workarounds

  • Test cases should cover:
    • Rendering a page fetched via Page API (to confirm no regressions).
    • Rendering a page fetched via GraphQL API (to confirm the fix works).
    • Handling cases where containers may be empty or missing.

Sub-Tasks & Estimates

  1. Analyze the response transformation logic and determine the best approach for normalizing GraphQL containers.
  2. Implement the normalization inside DotCMSLayoutBody without affecting external API responses.
  3. Test rendering behavior with both API formats to confirm expected functionality.
  4. Write unit tests to prevent regressions in future updates.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with DotCMSLayoutBody and the existing normalization logic in core-web/libs/sdk/client/src/lib/utils/graphql/transforms.ts, especially lines 50-74. Compare the Page API and GraphQL container shapes, then inspect the component's existing tests or test entry point. Done means both response formats render containers and contentlets, empty or missing containers are handled, and the GraphQL response remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.