DjangoOptimizerExtension not optimizing when fragments are used and field is queried twice #144
Comments
@edomora97
How does this work for you? |
Hey @edomora97 , thanks for reporting this. The optimizer does take fragments into consideration, but your example might be hitting a corner case that it is not considering. The code that inspects the query is
I'll try to take a look at that by the end of the week, but if you have time to take a look at this, feel free to open a PR that fixes it and I'll glagly review it :) @blueyed this lib provides a fix to the toolbar to make it work, even with async views. Try using it: https://blb-ventures.github.io/strawberry-django-plus/debug-toolbar/ |
feat: link JSONField to strawberry.scalars.JSON
@bellini666 Did you ever get a chance to look at this one? I'm running into the same issue. |
Still seeing issues with *nested* fragments. Probably an extension of blb-ventures/strawberry-django-plus#144 Try to make a minified repro and file a ticket?
Given this schema (simplified from the demo):
schema.py
And given these two equivalent queries:
slow.graphql
fast.graphql
(obtained by clicking on "Merge fragments into query" in GraphiQL)Initializing the database with this queries:
Details
Slow is experiencing the N+1 queries problem, while Fast is not.
Using GraphiQL and the Django toolbar I can see that Fast is making 3 queries:
While Slow is making 11:
Note that moving the field
name
fromissueList
into the fragmentA
doesn't trigger the issue.The text was updated successfully, but these errors were encountered: