Skip to content

Add orderNavigationsByKey option - #1458

Merged
SimonCropp merged 1 commit into
mainfrom
order-navigations-by-key
Nov 4, 2026
Merged

SimonCropp merged 1 commit into
mainfrom
order-navigations-by-key

Conversation

@SimonCropp

Copy link
Copy Markdown
Owner

Adds orderNavigationsByKey to RegisterInContainer and the EfGraphQLService constructor, on by default.

A projected navigation list or connection field with no orderBy argument is ordered by its key, for a deterministic result. For a model with EfOrderBy default ordering that replaced the default, since EfOrderBy leaves a collection that is already ordered as it is. A client that left out orderBy because it matched the model's default got the items in key order instead, which for a Guid key looks random.

With the option off, such a collection is left unordered, and EfOrderBy 1.4 (SimonCropp/EntityFramework.OrderBy#184) orders it by the configured default.

  • An orderBy argument is still applied, and replaces the default
  • On by default, so existing behavior and snapshots are unchanged
  • Only for a model that orders every entity, since an entity with no default is left in whatever order the database returns

Tests run the same parent and child query with the option on, off, and off with an orderBy argument. The test project is on EfOrderBy 1.3.0, which does not order projections, so with the option off the snapshot shows no child ordering. Run against a local build of EfOrderBy 1.4, that snapshot gains c.Property, the child's configured default, and no other test changes.

Documented under configuration. Version bumped to 36.3.0.

A projected navigation list or connection field with no orderBy argument is
ordered by its key. For a model with EfOrderBy default ordering that replaced
the default, since EfOrderBy leaves an already ordered collection as it is, so
a client that left out orderBy got the items in key order.

orderNavigationsByKey, on by default, can now be turned off in
RegisterInContainer and the EfGraphQLService constructor. Off, such a
collection is left unordered, and EfOrderBy 1.4 orders it by the configured
default. An orderBy argument is still applied.

Version bumped to 36.3.0.
@SimonCropp SimonCropp added this to the 36.3.0 milestone Nov 4, 2026
@SimonCropp
SimonCropp merged commit 2daf036 into main Nov 4, 2026
5 checks passed
@SimonCropp
SimonCropp deleted the order-navigations-by-key branch November 4, 2026 00:53
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