feat: add resource metadata to Ash.NotLoaded struct#2653
Merged
zachdaniel merged 1 commit intoash-project:mainfrom Mar 31, 2026
Merged
feat: add resource metadata to Ash.NotLoaded struct#2653zachdaniel merged 1 commit intoash-project:mainfrom
resource metadata to Ash.NotLoaded struct#2653zachdaniel merged 1 commit intoash-project:mainfrom
Conversation
91ac4c7 to
1d4ab88
Compare
1d4ab88 to
dab7918
Compare
There was a problem hiding this comment.
Pull request overview
Adds resource metadata to Ash.NotLoaded so callers can identify which resource a not-loaded field belongs to, while keeping resource record inspect/1 output uncluttered.
Changes:
- Added
:resourcefield to%Ash.NotLoaded{}and updated itsInspectimplementation to optionally display it. - Populated
resourcewhen constructing%Ash.NotLoaded{}in resource struct defaults (relationships/aggregates/calculations) and attribute select masks. - Updated resource record inspection to mark nested inspection as
in_resource?soAsh.NotLoadedcan hideresourcein that context, and added tests covering defaults + inspect behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lib/ash/not_loaded.ex |
Adds resource to the struct/typespec and conditionally renders it in Inspect. |
lib/ash/resource/schema.ex |
Ensures struct default %Ash.NotLoaded{} values include resource: __MODULE__ for relationships/aggregates/calculations. |
lib/ash/actions/helpers.ex |
Includes resource in %Ash.NotLoaded{} created for unselected attributes in select masks. |
lib/ash/resource.ex |
Sets Inspect custom option in_resource?: true when inspecting resource fields so nested NotLoaded hides resource. |
test/not_loaded_test.exs |
Adds unit tests for the new resource field and inspect behavior (standalone vs inside resource). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zachdaniel
approved these changes
Mar 31, 2026
Contributor
|
🚀 Thank you for your contribution! 🚀 |
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.
Contributor checklist
Leave anything that you believe does not apply unchecked.
Summary
resourcefield toAsh.NotLoadedstruct so consumers can identify which resource a not-loaded field belongs toresourcein all places whereAsh.NotLoadedis constructed: struct defaults (relationships, aggregates, calculations) and action helpers (attributes)resourcein standaloneAsh.NotLoadedinspect output, but hide it inside resource record inspect to keep output cleanCloses #885