Skip to content

refactor(contentful): move operations onto cacheable typed fields AD-476 - #7259

Merged
emuvente merged 3 commits into
mainfrom
feature/AD-476-contentful-cacheable-fields
Sep 15, 2026
Merged

emuvente merged 3 commits into
mainfrom
feature/AD-476-contentful-cacheable-fields

Conversation

@emuvente

Copy link
Copy Markdown
Collaborator

Why

Every Contentful response this app fetches today passes through Stellate uncached. Stellate caches by GraphQL type, but the contentful.entries and contentful.entry fields return the untyped JSONObject scalar, so no rule can match them. ContentfulEntry and ContentfulEntryCollection have a cacheLongTerm rule in stellate-config, so using the contentful.searchEntries and contentful.entryById fields that return those types allows the requests to be cached.

What changed

Every Contentful operation now selects the typed replacements. entries(…) becomes searchEntries(…), with searchPreviewEntries for preview mode, and the search arguments carry over unchanged. That covers:

  • the shared documents under src/graphql/query
  • the GlobalPromoFragment behind the promo banner and footer disclaimers
  • the inline operations in the borrower profile hero, the categories, monthly good, auto deposit, corporate campaign, instant action, and thanks pages, and the impact dashboard education post
  • the sitemap generator (though the call site for this is commented out)

The two queries that declare $preview, contentfulEntries.graphql and lenderProfileBadgeData.graphql, declare it as Boolean = false and select both the published and the preview field behind @skip / @include.

Responses shift one level. items[n] is now a ContentfulEntry wrapper, so readers go through items[n].entry. A new getContentfulEntries helper in contentfulUtils.js does that unwrapping, prefers the preview collection when present, and drops null entries. The readers that used to reach into contentful.entries.items call it instead, and the remaining aliased reads unwrap inline. The helper has its own spec.

I deleted checkout/donationData.graphql, which had no importers.

This has been verified locally against the staging environment. See the ticket for more details and QA steps https://kiva.atlassian.net/browse/AD-476

donationData.graphql had no importers.

AD-476
The deprecated contentful.entry and contentful.entries fields return the
untyped JSONObject scalar, so no Stellate cache rule could match them and
every Contentful response passed through uncached. The operations now select
searchEntries and searchPreviewEntries, which return ContentfulEntryCollection
and fall under the existing cacheLongTerm rule. Readers unwrap the
ContentfulEntry envelope through a shared getContentfulEntries helper, and the
two documents supporting preview select both fields behind `@skip`/`@include`.

AD-476
@emuvente
emuvente requested a review from a team September 15, 2026 19:48
@emuvente
emuvente merged commit 873d509 into main Sep 15, 2026
5 checks passed
@kiva-robot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 3.95.0-rc.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@kiva-robot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 3.95.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants