Skip to content

Prepare Release vnull - #5

Closed
github-actions[bot] wants to merge 6 commits into
mainfrom
release-preview
Closed

Prepare Release vnull#5
github-actions[bot] wants to merge 6 commits into
mainfrom
release-preview

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This PR is a preview of the release that release-plan has prepared. To release you should just merge this PR 👍


jsonApi.query() preloads the include tree for you, so a developer cannot reach those relation queries to scope them. withPreloadScopes(), a query builder macro, closes that: a map keyed by relation name constrains each included relation's preload query, at any depth, using callbacks that are the exact shape of Lucid's withScopes(), so a related model's own named scopes are reused rather than redefined.

It composes after jsonApi.query() with Lucid's own withScopes() for the root. The map is read when the preload runs (execution), so chain order does not matter. applyIncludes keeps its old two-argument form working; the new model and preload-scope arguments are optional.

Docs and a real end-to-end example test are included.
The scope map is keyed by the model's relation names, and each callback's scopes argument is the related model's scope bag, matching withScopes(): a wrong relation name or an undefined scope is a compile error. Deeper includes are constrained by nesting a preload of their own, typed to the next model down.

This replaces the flat, any-depth-by-name shape (which could not be typed, and could apply a scope to a same-named relation on another branch) with a structural tree walked alongside the include tree. applyIncludes stays backward compatible.
Add withPreloadScopes to constrain included relations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant