Skip to content

Fix parent requirements being dropped from paged projections - #10701

Merged
michaelstaib merged 2 commits into
mainfrom
mst/fix-paged-parent-requires
Oct 26, 2026
Merged

michaelstaib merged 2 commits into
mainfrom
mst/fix-paged-parent-requires

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

When a field uses [Parent(requires: ...)] on a list with [UsePaging] or [UseOffsetPaging] and [UseProjection], the required property was not loaded, so the resolver saw a default value. Paging builds the database query from a hidden internal field, and since #9978 every field below it is internal too. The requirements optimizer skipped all internal fields, so it never saw the fields the client selected. It now only skips the hidden requirement fields it adds itself.

public int GetNameLength([Parent(requires: nameof(Item.Name))] Item item)
    => item.Name.Length;

[UsePaging]
[UseProjection]
public IQueryable<Item> GetItems() => ...;
{
  items {
    nodes {
      nameLength
    }
  }
}

For an item named abc, nameLength was 0 before this fix and is 3 now.

@michaelstaib
michaelstaib merged commit 76adbf2 into main Oct 26, 2026
6 of 7 checks passed
@michaelstaib
michaelstaib deleted the mst/fix-paged-parent-requires branch October 26, 2026 19:25
@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (1/1)

File Covered Changed Patch %
…/Optimizers/QueryableRequirementsProjectionOptimizer.cs 1 1 100.0% 🟢

Project coverage: 59.4% (317091/533687 lines)

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.

1 participant