Skip to content

Remove a resolver's query splitting when the projection loads no collection - #1422

Merged
SimonCropp merged 2 commits into
mainfrom
remove-unused-query-splitting
Sep 28, 2026
Merged

SimonCropp merged 2 commits into
mainfrom
remove-unused-query-splitting

Conversation

@SimonCropp

Copy link
Copy Markdown
Owner

A resolver can call AsSplitQuery() for the collections a request might select. When the request selects none, the select projection loads no collection, so the split does nothing. Verify.EntityFramework 16 throws for that:

AsSplitQuery() is ignored, since the query loads no collection.

For example, a connection field whose resolver is Commitments.AsSplitQuery()... failed for any request that selected only scalars.

ApplyProjection now checks whether the projection loads a collection at any depth, including derived-type navigations. If it doesn't, AsSplitQuery() and AsSingleQuery() are removed from the query (new QuerySplitting). The query is left alone when a collection is selected, and when projection falls back to includes, since a collection can then come from a resolver Include or an AutoInclude.

Tests: a splitParentEntitiesConnection field whose resolver calls AsSplitQuery().

  • Selecting only scalars used to throw. It now runs one page query.
  • Selecting children still splits them into a second query.

…ection

A resolver can call AsSplitQuery for the collections a request might select. When
the request selects none, the select projection loads no collection, so the split
does nothing, and Verify.EntityFramework 16 throws for it. ApplyProjection now
removes AsSplitQuery and AsSingleQuery in that case. With a collection selected,
or when projection falls back to includes, the query is left alone.
Child ids are random guids and the children were ordered by id, so the snapshot
matched only when the database returned them in the verified order.
@SimonCropp
SimonCropp merged commit 887b74f into main Sep 28, 2026
2 checks passed
@SimonCropp
SimonCropp deleted the remove-unused-query-splitting branch September 28, 2026 11:06
@SimonCropp SimonCropp added this to the 35.3.3 milestone Sep 28, 2026
SimonCropp added a commit that referenced this pull request Sep 28, 2026
…#1424)

#1422 removed a resolver's AsSplitQuery only when the projection could be
built as a select. When it cannot, as for a type with derived types,
ApplyProjection falls back to includes and left the split in place, so a
connection over such a type that selected no collection still threw under
Verify.EntityFramework 16. The includes come from the same projection, so the
check now runs before either path.
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.

1 participant