graphql-python / graphql-python/graphene-django
`in` filters don't decode IDs
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 760
- PR merge metrics
- No merged PRs in 30d
Description
**Note: for support questions, please use stackoverflow**. This repository's issues are reserved for feature requests and bug reports.
* **What is the current behavior?**
Using django-filter for filtering an exact ID match functions well, while filtering for an id `in` some set of IDs does not.
For AutoFields and ForeignKeys and the like, when specifying `"id": ["exact", "in"]` as part of a node's `filter_fields`, the `exact` filter works well, while the `in` filter raises exceptions resulting from not decoding global ids.
* **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem**
> via a github repo, https://repl.it or similar (you can use this template as a starting point: https://repl.it/@jkimbo/Graphene-Django-Example).
If you'd like, I can setup a repl.it example, but for now I'll just illustrate here:
```python
class Apple(models.Model):
colour = models.CharField(max_length=7)
class AppleType(DjangoObjectType):
class Meta:
model = Apple
fields = ("id", "colour")
filter_fields = {"id": ["exact", "in"]}
interfaces = (graphene.relay.Node,)
class Query(graphene.ObjectType):
apples = DjangoFilterConnectionField(AppleType)
```
And then a query like
```graphql
query getApples($id: ID) {
apples(id: $id) {
id
colour
}
}
```
works fine, while
```graphql
query getApplesIn($id__in: [ID]) {
apples(id__in: $id__in) {
id
colour
}
}
```
does not.
* **What is the expected behavior?**
The latter query should return the objects that match the specified list of IDs.
* **What is the motivation / use case for changing the behavior?**
I think this is a bug/oversight.
* **Please tell us about your environment:**
- Version: 3.2.2
- Platform: macOS 15.3 (but I've also experienced this on manjaro, this is not OS specific)
* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
If this is the type of bug you would fix, I can provide a reproducible example.
Contributor guide
Assessment
This issue has not been assessed yet.