Open cansin opened 3 years ago
import graphene_django_optimizer as gql_optimizer
class Query(graphene.ObjectType):
category = graphene.Field(CategoryNode, slug=graphene.String(required=True))
@classmethod
def resolve_category(cls, root, info, slug):
return gql_optimizer.query(CategoryDefinition.objects.get_queryset().filter(slug=slug), info).first()
You should wrap the queryset in the query
method, then call get
(or first
, I believe get
didn't work as expected) on the result.
(Also see related discussion in https://github.com/tfoxy/graphene-django-optimizer/issues/46)
We are trying to get
graphene-django-optimizer
to work with our setup. Most of our queries start from aquery { me { ... } }
root. As such the implementation of theQuery
is:or another example:
We are not able to figure out how to get the subtree of such an entry point to optimize. Simply extending
UserNode
fromOptimizedDjangoObjectType
does not make any difference in the queries being run. Any idea on how we could utilizegraphene-django-optimizer
?