Skip to content

SDK: Refactor page.get() to Always Use GraphQL with Stable Response #31965

Description

@rjvelazco

Background

dotClient.page.get() switches between the Page REST API and GraphQL depending on the incoming params.
This causes two key pain points:

  • Unpredictable response shapes – the same call can return different keys/types.
  • Debug & performance overhead – engineers must inspect which endpoint fired, slowing troubleshooting and tuning.

For clarity and future‑proofing, we’ll route every page.get() call through GraphQL and return one stable object shape.

Task

Refactor dotClient.page.get() to always use GraphQL, no matter what params are passed. The method must consistently return to the same typed object:

const { pageAsset, navigation,  content, params } = response;

Note:
The params object is the same that the method receive.

Proposed Objective

Same as Parent Issue

Proposed Priority

Priority 2 - Important

Acceptance Criteria

Acceptance Criteria

  • GraphQL only : every fecth should hit our graphql endpoint
  • Stable response : method always returns the same object.
  • Generic flexibility : dev can supply their own generics: <PageAssetBase<T>, PageAssetBase<T>, TContent> to override the default types.
  • Extensible bases: expose interfaces PageAssetBase<T> and PageAssetBase<T> that consumers can extend.
  • Cleanup unused code: Remove all the code related to the page API.
  • Documentation updated: Mark it as a breaking change for those who were expecting the object to be like this:
    const page = reponse

Pseudo-code:

async function getPage () {
  const params = {
    graphql: {
     page: ``,
      navigation: `navigation(path: '/', depth: 1) {
        title,
        href,
      }`,
      content: {
        blog: `blogCollection('+contentType:BlogPosting') {
          inode,
          title,
          body,
          contentType,
          publishDate,
          tags,
          categories,
        }`
      }
    }
  }

  const response = await dotcms.page.getStable("/api/v1/content/title/test", params)

  return response
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions