strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
MIT License
391 stars 115 forks source link

Broken interfaces with optimiser extension #550

Closed ManiacMaxo closed 1 week ago

ManiacMaxo commented 2 weeks ago

Querying interfaces crashes when using the optimiser extension caused by #537.

Describe the Bug

Any field that is an interface will raise an assertion error when queried. disable_optimizations=True has no effect. This is caused by the new implementation which uses schema.schema_converter.from_object that only supports concrete objects - not interfaces.

System Information

Upvote & Fund

Fund with Polar

ManiacMaxo commented 2 weeks ago

I've implemented a possible solution here. Another possibility is to ignore interface types altogether during optimisation

bellini666 commented 2 weeks ago

Hey @ManiacMaxo ,

Thanks for that!

I think your solution is great! Would you like to open a PR for that?

bellini666 commented 2 weeks ago

Hey @ManiacMaxo ,

I tried writing a test using interfaces, but everything passed: https://github.com/strawberry-graphql/strawberry-django/pull/554

What should we do to reproduce the issue to go together with your fix to make sure that doesn't regress in the future?

ManiacMaxo commented 2 weeks ago

Hi @bellini666,

Unfortunately I couldn't recreate the issue without using django-polymorphic (which is why I'm using interfaces) since it returns the interface type's model which can be cast into all concrete types