tfoxy / graphene-django-optimizer

Optimize database access inside graphene queries
MIT License
428 stars 84 forks source link

Nested queries are not properly optimized in graphene-django v3.0.0 (but are in v3.0.0b7) #86

Closed sjdemartini closed 1 year ago

sjdemartini commented 2 years ago

graphene-django just released a non-beta version of v3 last month (https://github.com/graphql-python/graphene-django/releases/tag/v3.0.0), and graphene-django-optimizer does not appear to optimize queries properly with the new graphene-django release unfortunately.

The latest version of graphene-django-optimizer (0.9.1) appears to work properly with graphene-django v3.0.0b7 (a beta version released a couple years ago, which is listed in the dev-env-requirements.txt for this repo). But when bumping that, SQL-optimization no longer works in many cases, such as with nested fields requiring prefetch_related.

See branch here with version bumps and failing tests: https://github.com/tfoxy/graphene-django-optimizer/pull/85

sjdemartini commented 1 year ago

I've tested the graphene-django PR here https://github.com/graphql-python/graphene-django/pull/1401 and confirmed that it fixes the failing query-optimization tests mentioned above and should resolve this issue.

firaskafri commented 1 year ago

@sjdemartini I believe you could close this issue now as your fix was released in graphene-django v3.0.2?

sjdemartini commented 1 year ago

Yep, confirmed this is working with 3.0.2! Thanks for merging and releasing @firaskafri! 🙌

One quick minor side note: I saw in the release notes for https://github.com/graphql-python/graphene-django/releases/tag/v3.0.2 that it says "Just a heads up for folks who use get_queryset as an auth layer. If you need that, you can stick with versions between >=3.0.0b9 and <3.1.0 for now" but I think it should probably say "between >=3.0.0b9 and <3.0.2".

firaskafri commented 1 year ago

@sjdemartini yes you are right!