graphql-python / graphql-python/graphene-django

Filtering based off of ManyToManyField

Open
#1,071 0 comments 0 reactions 0 assignees View on GitHub
✨enhancement
Dominant language
Python
Stars
4.4k
Forks
760
PR merge metrics
No merged PRs in 30d

Description

I'm trawling through the documentation and looking up what I know regarding Django Filters and Django, but there doesn't seem to be a way of filtering a `Node` object on a `ManyToMany` instance attribute ... e.g., RelatedName.name doesn't seem to be filterable within `filter_fields = {}` e.g.:

```
filter_fields = {
'categories__name': ['exact', 'icontains', 'istartswith'],
}
```

I just seem to get the following error when attempting to query by `category.name`:

```
{
"errors": [
{
"message": "Unknown argument \"categoriesName\" on field \"allIngredients\" of type \"Query\".",
"locations": [
{
"line": 149,
"column": 15
}
]
}
]
}
```

What would be the best way to achieve filtering based on a ManyToManyField instance attribute?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.