Skip to content

Conversation

Cyberboss
Copy link
Contributor

@Cyberboss Cyberboss commented Aug 15, 2025

The following query will create two branches in a data loader when used with QueryContext<> and IDataLoader.With() and thus result in two identical database queries being executed despite both selecting the exact same columns of the exact same entity.

query TestQuery {
  usersById(id: "VXNlcjoxMDAwMg==") {
    name
    enabled
  }
  node(id: "VXNlcjoxMDAwMg==") {
    ... on User {
      enabled
      name
    }
  }
}

This is purely because the order of the assignments differ in the MemberInit expressions when the ISelection is converted to an Expression<Func<TResult, TResult>>. This change ensures fields are always processed alphabetically to minimize hash differences where possible.

Made these changes exclusively against v15. I assume they will be merged into main somehow?

@michaelstaib michaelstaib self-requested a review August 15, 2025 23:39
@michaelstaib michaelstaib changed the base branch from main-version-15 to main August 15, 2025 23:40
@michaelstaib michaelstaib changed the base branch from main to main-version-15 August 15, 2025 23:40
@michaelstaib
Copy link
Member

michaelstaib commented Aug 15, 2025

hey @Cyberboss can you redo it against main ... we always fix main than cherry pick it onto main-version-15.

Copy link
Member

@michaelstaib michaelstaib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be retargeted to main.

@Cyberboss Cyberboss changed the base branch from main-version-15 to main August 16, 2025 01:34
This helps prevent differences when the expression hash is later used to branch data loaders if queries only differ in the order their fields are listed in.
@Cyberboss Cyberboss force-pushed the FixExpressionHashDifferences branch from 9ed148c to f2c888a Compare August 16, 2025 01:36
@michaelstaib michaelstaib merged commit 8a83c99 into ChilliCream:main Aug 18, 2025
3 checks passed
@Cyberboss Cyberboss deleted the FixExpressionHashDifferences branch August 18, 2025 22:12
@michaelstaib michaelstaib added the 🍒 cherry-pick Consider cherry-picking these changes into the previous major version. label Aug 19, 2025
michaelstaib added a commit that referenced this pull request Aug 27, 2025
Co-authored-by: Michael Staib <michael@chillicream.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒 cherry-pick Consider cherry-picking these changes into the previous major version. 🌶️ hot chocolate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants