SDK: Make `DotCMSLayoutBody` Support GraphQL Page Response
Nobody has claimed this yet.
- 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
DotCMSLayoutBodyto 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
DotCMSLayoutBodycorrectly handles both response formats.
Implementation Notes
- We can use the existing transformation function in the SDK to normalize GraphQL responses into the expected structure:
- Important: The normalization should be handled inside
DotCMSLayoutBodyand 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
- Analyze the response transformation logic and determine the best approach for normalizing GraphQL containers.
- Implement the normalization inside
DotCMSLayoutBodywithout affecting external API responses. - Test rendering behavior with both API formats to confirm expected functionality.
- Write unit tests to prevent regressions in future updates.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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