Skip to content

Default QuerySet for DjangoObjectType has no effect with graphene.List #925

Open
@pors

Description

@pors

The documentation describes the use of a default QuerySet on ObjectType level.

The unit test for this functionality makes use of DjangoConnectionField.

Using graphene.List instead ignores the existence of the default QuerySet.

class CurrencyType(DjangoObjectType):
    class Meta:
        model = Currency

    @classmethod
    def get_queryset(cls, queryset, info):
        print(cls)
        print(queryset)
        return queryset.filter(symbol__isnull=False)
all_currencies = graphene.List(CurrencyType)

def resolve_all_currencies(self, info):
    return Currency.objects.all()

The get_queryset method is never called, and the filter is not applied.

Please refer to graphql-python/graphene#698 for some history on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Docs enhancementIssues that can be resolved with better docs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions