Skip to content

Union types: EF Core exception: The client projection contains a reference to a constant expression... #8252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
HaroldH76 opened this issue Apr 18, 2025 · 0 comments

Comments

@HaroldH76
Copy link

HaroldH76 commented Apr 18, 2025

Product

Hot Chocolate

Version

15.1.3

Link to minimal reproduction

https://github.com/HaroldH76/Hotchocolate-8252/

Steps to reproduce

The issue looks like the one of: #4318

But it might be slightly different. We are experiencing this issue with union types. I have downloaded the reproduction case of 4318 and upgraded it to the latest HotChocolate version 15.1.3. And that one worked ok.

Next I have updated it to use union types. And I have simplified the example and the database models and used some models of the HotChocolate documentation. And I have added support for in memory database.

What is expected?

When I query not the complete set of union types but a subset then I expect only that subset to be returned. For example when my union type consists of 2 types and I specify only one then only that one should be returned.

{
  contents {
    items {
      ... on TextContent {
        text
      }
    }
  }
}

What is actually happening?

Depending on the query and depending if I use the in memory database or a real database I get:

  • null as result or
  • Exception of EF Core:

The client projection contains a reference to a constant expression of 'Reproduction.ImageContent'. This could potentially cause a memory leak; consider assigning this constant to a local variable and using the variable in the query instead.

Additional context

Se the readme of the reproduction case for more information and more example graphql queries:
https://github.com/HaroldH76/Hotchocolate-8252/

@HaroldH76 HaroldH76 changed the title Regression bug: Unable to spread fragment on inheritance hierarchy added as a union or interface type when deferred to Entity Framework Union types: EF Core exception: The client projection contains a reference to a constant expression... Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant