In this comment you say that we should be able to optimise the queryset of a manually prefetched field using optimize, however this does not appear to work.
The following code in the demo directory shows that the only optimisation is not applied to my_issues:
@gql.django.type(Milestone, filters=MilestoneFilter, order=MilestoneOrder)
class MilestoneType(relay.Node):
name: gql.auto
due_date: gql.auto
project: ProjectType
issues: List["IssueType"]
@gql.django.field(
prefetch_related=[
lambda info: Prefetch(
"issues",
queryset=optimize(
Issue.objects.filter(
Exists(
Assignee.objects.filter(
issue=OuterRef("pk"),
user_id=info.context.request.user.id,
),
),
),
info,
),
to_attr="_my_issues",
),
],
)
def my_issues(self) -> List["IssueType"]:
return self._my_issues # type: ignore
@gql.django.field
async def async_field(self, value: str) -> str:
await asyncio.sleep(0)
return f"value: {value}"
Is it possible to use optimize in this way?
Thanks for the library!
In this comment you say that we should be able to optimise the queryset of a manually prefetched field using
optimize, however this does not appear to work.The following code in the demo directory shows that the only optimisation is not applied to
my_issues:Is it possible to use
optimizein this way?Thanks for the library!