Skip to content

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

Open
@HaroldH76

Description

@HaroldH76

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/

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions