Skip to content

Polymorphic models with fields with optimizer hints aren't resolved correctly #733

@ManiacMaxo

Description

@ManiacMaxo

Describe the Bug

When using an annotated field with any optimizer hints, the optimizer attempts to load the fields with a prefix app_label__ModelName___ (here). This works perfectly for related field resolution, however it does not work for the hints. They are resolved like this:

app_label__ModelName_____someField (note that there are 5 underscores)

This causes django to try to prefetch an empty field and crashes.

System Information

  • Operating system: Any
  • Strawberry django version: 0.58.0

Additional Context

I've created a small reproduction here with the file in question: graphql.py

I'll continue trying to find the cause and might open a PR with a fix. Not sure if I'll be able to though...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions