Skip to content

[question] Authorization/Queryset filtering #490

@cocochepeau

Description

@cocochepeau

First of all, thanks for the amazing work!

By using this: http://docs.graphene-python.org/projects/django/en/latest/authorization/#queryset-filtering-on-lists
How can I achieve the same thing with relay queries. For example with:

class ProjectNode(DjangoObjectType):
    class Meta:
        model = Project
        interfaces = (relay.Node, )


class ProjectFilter(django_filters.FilterSet):
    class Meta:
        model = Project
        fields = [
            'id', 'published',
        ]


class Query(object):
    project = relay.Node.Field(ProjectNode)
    projects = DjangoFilterConnectionField(
        ProjectNode,
        filterset_class=ProjectFilter
    )

    def resolve_projects(self, args, info): # It does not work
        return Project.objects.filter(published=True)

Basically, I want to limit the queryset to only published projects.

Thanks again.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions