strawberry-graphql / strawberry-django

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

Bug: "AttributeError 'list' object has no attribute '_result_cache'" when using pagination and optimizer #532

Closed jacobwegner closed 1 month ago

jacobwegner commented 1 month ago

Thanks for the excellent library! Below is a bug report which I'll link to a forthcoming pull request.

Describe the Bug

When using the DjangoOptimizerExtension, I hit an error where adding pagination to a subquery (where the optimizer correctly uses prefetch_related) raises an AttributeError.

My suggested fix is to short-circuit when processing the prefetched results, but if there are alternate approaches or other concerns with this approach, I'd be happy to implement the fix another way.

Upvote & Fund

Fund with Polar