'Graphene using auto-generated type instead of defined DjangoObjectType

I think this may have happened after updating graphene-django a few months back, but I can't find the relevant notes in the changelog.

I have a type defined like this;

class PrimaryGroupType(DjangoObjectType):
    users = graphene.List("graphy.data.base.types.UserType")
    users_count = graphene.Int()
    investigations_count = graphene.Int()
    action_programs_count = graphene.Int()
    action_plans_count = graphene.Int()
    adjustments_count = graphene.Int()
    notes_count = graphene.Int()

    class Meta:
        model = SchedulePrimaryGroup

    def resolve_users(self, *args, **kwargs):
        return self.users.all()

    def resolve_users_count(self, *args, **kwargs):
        return self.users.count()

    def resolve_investigations_count(self, *args, **kwargs):
        if hasattr(self, "investigations_count"):
            return self.investigations_count
        user_ids = self.users.values_list("id")
        return Investigation.objects.filter(user__in=user_ids).count()

    def resolve_notes_count(self, *args, **kwargs):
        if hasattr(self, "notes_count"):
            return self.notes_count
        user_ids = self.users.values_list("id")
        return Note.objects.filter(user__in=user_ids).count()

    def resolve_action_programs_count(self, *args, **kwargs):
        if hasattr(self, "action_programs_count"):
            return self.action_programs_count
        user_ids = self.users.values_list("id")
        return ActionProgram.objects.filter(user__in=user_ids).count()

    def resolve_action_plans_count(self, *args, **kwargs):
        if hasattr(self, "action_plans_count"):
            return self.action_plans_count
        user_ids = self.users.values_list("id")
        return ActionPlan.objects.filter(user__in=user_ids).count()

    def resolve_adjustment_count(self, *args, **kwargs):
        if hasattr(self, "adjustments_count"):
            return self.adjustments_count
        user_ids = self.users.values_list("id")
        return UserAdjustment.objects.filter(user__in=user_ids).count()

From graphene-django-extras I use DjangoListObjectType, and that list type is defined like this;


class PrimaryGroupListType(DjangoListObjectType):
    class Meta:
        model = SchedulePrimaryGroup
        pagination = CustomPageGraphqlPagination(
            page_size=25, page_size_query_param="page_size"
        )
        filterset_class = SearchFilter

Although, unlike in all my other list types, the PrimaryGroupType is not picked up by the list and a generic type is instead created Auto generated Type for SchedulePrimaryGroup model.

Why?!



Sources

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

Source: Stack Overflow

Solution Source