refactor: load elements through core's shared element repository - #199
Merged
Merged
Conversation
Build the page's element set via Alchemy::PageVersion#element_repository instead of instantiating Alchemy::ElementsRepository directly. This routes json_api through the same element-loading seam the rest of the Alchemy ecosystem uses, so it inherits core's behaviour automatically — the repository memoization today, and a shared element preloader once core provides one — rather than maintaining a parallel construction here. The change is behaviour-preserving: element_repository still wraps the version's (eager-loaded) elements and applies the same visible filter.
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
Collaborator
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
tvdeyen
added a commit
that referenced
this pull request
Sep 29, 2026
…pository (#199) (#216) # Backport This will backport the following commits from `main` to `8.2-stable`: - [refactor: load elements through core's shared element repository (#199)](#199) <!--- Backport version: 12.0.4 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)
Merged
tvdeyen
added a commit
that referenced
this pull request
Sep 29, 2026
## Release v8.2.1 <!-- Release notes generated using configuration in .github/release.yml at 8.2-stable --> ## What's Changed ### Bug Fixes * [8.2-stable] fix(IngredientPictureSerializer): Use picture_url (#214) by @alchemycms-ci-bot in #217 ### Performance Improvements * [8.2-stable] Route element visibility through ElementsRepository (#196) by @alchemycms-ci-bot in #215 * [8.2-stable] refactor: load elements through core's shared element repository (#199) by @alchemycms-ci-bot in #216 ## New Contributors * @alchemycms-ci-bot made their first contribution in #215 **Full Changelog**: v8.2.0...v8.2.1 --- This PR was automatically created by the prepare-release workflow. Once merged, the gem will be automatically published to RubyGems.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this pull request for?
Alchemy::JsonApi::Pagecurrently builds its element set by instantiatingAlchemy::ElementsRepository.new(page_version.elements)directly. Core already exposes that same set throughAlchemy::PageVersion#element_repository, so this reuses the shared seam instead of a parallel construction.The motivation is upcoming performance work in alchemy_cms core. Core is introducing a shared element-loading path (repository memoization now, and a shared element preloader to eliminate the ingredient/tag N+1 later). By routing json_api through
page_version.element_repository, this gem inherits those improvements automatically as they land in core, rather than having to mirror each change here.The change is behaviour-preserving:
element_repositorystill wraps the version's (eager-loaded) elements and applies the samevisiblefilter, so serialization output and the controller's existingincludesare unaffected.Checklist