@@ -123,6 +123,11 @@ create your own ``FilterSet``. You can pass it directly as follows:
123123 class AnimalFilter (django_filters .FilterSet ):
124124 # Do case-insensitive lookups on 'name'
125125 name = django_filters.CharFilter(lookup_expr = [' iexact' ])
126+ # Allow multiple genera to be selected at once
127+ genera = django_filters.MultipleChoiceFilter(field_name = ' genus' ,
128+ choices = ((' Canis' , ' Canis' ),
129+ (' Panthera' , ' Panthera' ),
130+ (' Seahorse' , ' Seahorse' )))
126131
127132 class Meta :
128133 model = Animal
@@ -135,6 +140,22 @@ create your own ``FilterSet``. You can pass it directly as follows:
135140 all_animals = DjangoFilterConnectionField(AnimalNode,
136141 filterset_class = AnimalFilter)
137142
143+
144+ If you were interested in selecting all dogs and cats, you might query as follows:
145+
146+ .. code ::
147+
148+ query {
149+ allAnimals(genera: ["Canis", "Panthera"]) {
150+ edges {
151+ node {
152+ id,
153+ name
154+ }
155+ }
156+ }
157+ }
158+
138159 You can also specify the ``FilterSet `` class using the ``filterset_class ``
139160parameter when defining your ``DjangoObjectType ``, however, this can't be used
140161in unison with the ``filter_fields `` parameter:
@@ -162,6 +183,7 @@ in unison with the ``filter_fields`` parameter:
162183 animal = relay.Node.Field(AnimalNode)
163184 all_animals = DjangoFilterConnectionField(AnimalNode)
164185
186+
165187 The context argument is passed on as the `request argument <http://django-filter.readthedocs.io/en/master/guide/usage.html#request-based-filtering >`__
166188in a ``django_filters.FilterSet `` instance. You can use this to customize your
167189filters to be context-dependent. We could modify the ``AnimalFilter `` above to
0 commit comments