dotCMS / dotCMS/core

[SPIKE] SDK: Use Axios GET for `getPage()` GraphQL calls

Open
#31,982 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

 Background

We want page requests to hit GraphQL with HTTP GET so edge caches/CDNs can key off the full URL and improve hit‑rates. While GET normally disallows a body, Axios supports data on GET, sending it as the request body without breaking semver for browsers that ignore it. This lets callers pass GraphQL variables while still reaping CDN benefits.

Task

Replace the current fetch/POST implementation in dotClient.page.get() with Axios GET, sending GraphQL query + variables like so:

axios.get('/api/v1/graphql', {
  params: { query: buildQuery(path) },   // goes into URL for cache key
  data:   { variables }                  // Axios puts this in the body
});
Proposed Objective

Same as Parent Issue

Proposed Priority

Priority 2 - Important

Acceptance Criteria
  • [ ] client.get.page() uses axios.get()
  • [ ] Devs may pass { variables: { foo: 'bar' } }; Axios sends it in the request body even with GET.
  • [ ] Full GraphQL query string appears in the URL, enabling cache hits.
  • [ ] Let the user bypass the cache sending custom headers
Cache with Get Method
   export const getGraphqlResults = async (query) => {
    const queryHash = crypto.createHash('sha256').update(query).digest('hex');
    const cacheKey = `?qid=${queryHash}`;
    const url = new URL(GRAPHQL_ENPOINT + cacheKey, Config.DotCMSHost);

    try {
        const res = await fetch(url, {
            method: "GET",
            headers: Config.Headers,
            body: JSON.stringify({ query }),
        });
        const { data } = await res.json();
        return data;
        ...

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 at the dotClient.page.get() SDK entry point and compare its current fetch/POST behavior with the proposed axios.get('/api/v1/graphql') request. Verify how query, variables, and custom headers are passed, then confirm the acceptance criteria: the full query is in the URL, variables can be sent in the GET body, and cache bypass headers work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
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.