wagtail-grapple
wagtail-grapple copied to clipboard
[WIP] Add Query Optimizer that selects fields from query AST
This is the initial code for optimizing GraphQL queries to reduce the number of database calls. The gist of this PR is that it analyses from the queries' AST what fields of what models it needs and then appends that to the Queryset object, further along the line when a .specific()
call is applied these field selects are called on the Queryset using .only(..)
, .select_related(..)
& .prefetch_related(..)
.
More accurate data will follow...
What do you think @zerolab??
Why not consider using https://github.com/tfoxy/graphene-django-optimizer ?
Hi @fabienheureux , I did try GDQ but it doesn't work with stream field and that's a big issue for us. Instead of hack GDQ into Grapple, I decided to create our own way of doing it that can be fine tuned and expanded in the future.
@NathHorrigan any chance you can bring this to the finish line?
@NathHorrigan any chance you can bring this to the finish line?
@NathHorrigan any news on this PR? I'm going to fix the merge conflicts 🙂 .
I started a PR on the graphene_django
project to bring async resolvers support out of the box https://github.com/graphql-python/graphene-django/pull/1256
It is still very much a work in progress, but I might be interested in restarting the work on optimizing queries with the addition of dataloaders to avoid n+1 queries once it has been merged 🤞