'Omit base resolver edge resolution in an aggregation query

I'm returning aggregate data for a model, I have:

Objects {
  byColor {
    red
    blue
  }
}

As my query, then in graphene I have:

class ObjectsQuery(DjangoObjectType):
  class Meta:
    model = Objects

  def resolve_by_color(self, _):
    return self.iterable.aggregate(...)

I'm having a performance issue because it looks like a query for all Objects is being executed, even though the results of that query aren't included in any edges. Is there a way to avoid this Objects.objects.all() query from running?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source