Skip to content

fix(druxt): re-hydrate included resources on getCollection cache hit - #782

Open
Decipher wants to merge 3 commits into
druxt:developfrom
Decipher:feature/781-getcollection-included-cache
Open

Decipher wants to merge 3 commits into
druxt:developfrom
Decipher:feature/781-getcollection-included-cache

Conversation

@Decipher

@Decipher Decipher commented Aug 16, 2026

Copy link
Copy Markdown
Member

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

addCollection dehydrated included resources into state.resources but then deleted them from the stored collection. So a second getCollection dispatch for an already-cached query returned included: undefined, and anything resolving an included resource, such as an image or media reference, silently got nothing back on the cache hit.

This keeps the dehydrated included refs on the stored collection and reconstructs them on a cache hit, the same way data already is. Includes a changeset.

Resolves: #781

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

Screenshots/Media

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Fixed cached collections so related included resources are preserved and restored correctly.
    • Ensured cached results match fresh-fetch results, including associated resource data.
    • Cleared stale included-resource references when later collection responses omit them.
    • Improved cached collection retrieval after related resource data is cleared.
    • Added coverage for cache hits, resource flushing, and changes in included-resource data.

@changeset-bot

changeset-bot Bot commented Aug 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ee0d1c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
druxt Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 039fbe64-443f-4c8b-a74b-9b17d6cfac68

📥 Commits

Reviewing files that changed from the base of the PR and between 61cfa79 and ee0d1c8.

📒 Files selected for processing (3)
  • .changeset/lucky-moons-wave.md
  • packages/druxt/src/stores/druxt.js
  • packages/druxt/test/stores/druxt.test.js

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 641af957-31a4-4f77-a10a-a23de3f89ea2

📥 Commits

Reviewing files that changed from the base of the PR and between 24b691b and 98f747d.

📒 Files selected for processing (3)
  • .changeset/lucky-moons-wave.md
  • packages/druxt/src/stores/druxt.js
  • packages/druxt/test/stores/druxt.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/lucky-moons-wave.md

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The Druxt collection cache now preserves dehydrated included resource references and rehydrates them on cache hits. It also clears stale includes and handles flushed resource buckets. Tests and a patch changeset document the behavior.

Changes

Collection cache rehydration

Layer / File(s) Summary
Cache storage and rehydration
packages/druxt/src/stores/druxt.js
addCollection retains dehydrated included references and removes stale references when later data omits included. getCollection rehydrates cached data and included resources and guards missing resource buckets.
Regression coverage and release metadata
packages/druxt/test/stores/druxt.test.js, .changeset/lucky-moons-wave.md
Tests cover retained references, cache-hit rehydration, flushed resources, and removal of stale includes. A patch changeset documents the fix.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 98f74

Cached collection responses retain included resources consistently with initial responses, with no current merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: re-hydrating included resources on getCollection cache hits.
Linked Issues check ✅ Passed The changes address #781. packages/druxt/src/stores/druxt.js retains dehydrated included references in stored collections and rehydrates them on cache hits. The changes also remove stale reference…
Out of Scope Changes check ✅ Passed The reported changes are limited to the cache implementation, related store tests, and a changeset. These changes directly support #781 and its required automated coverage. No unrelated change is iden…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Decipher
Decipher force-pushed the feature/781-getcollection-included-cache branch 4 times, most recently from b73aace to 0413057 Compare September 18, 2026 03:23
@Decipher
Decipher force-pushed the feature/781-getcollection-included-cache branch from 0413057 to ee0d1c8 Compare September 18, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getCollection returns no included data on a cache hit

1 participant