It doesn't seem possible from a cursory glance of the code, and I haven't spent enough time to see if it's an easy patch so I figured I'd ask the experts here first.
Is it possible to optimize across model relationship boundaries, for instance let's presume we wanted to make some things available at the top level resolver to avoid lots of nesting (the pseudo example below is not a particularly good one, but the question still stands):
class OrganizationType:
def resolve_parent_organization(root, info):
return root.parent_organization
def resolve_accounts(root, info):
return root.accounts.all()
class UserType:
@gql_optimizer.resolver_hints(model_field="organization__parent_organization")
def resolve_parent_organization(root, info):
return root.organization.parent_organization
and then we'd like to be able to optimize queries according to a pattern such as this:
user {
parentOrganization {
accounts
}
}
The hacky approach we're taking at the moment is to prefetch downstream data when we access the parentOrganization resolver because this is ultimately better than N+1 queries but it still results in lots of overfetching. For instance, let's say that instead of accounts we only want the parentOrganization name.
It doesn't seem possible from a cursory glance of the code, and I haven't spent enough time to see if it's an easy patch so I figured I'd ask the experts here first.
Is it possible to optimize across model relationship boundaries, for instance let's presume we wanted to make some things available at the top level resolver to avoid lots of nesting (the pseudo example below is not a particularly good one, but the question still stands):
and then we'd like to be able to optimize queries according to a pattern such as this:
The hacky approach we're taking at the moment is to prefetch downstream data when we access the
parentOrganization
resolver because this is ultimately better than N+1 queries but it still results in lots of overfetching. For instance, let's say that instead of accounts we only want the parentOrganization name.