graphql-python / graphql-python/graphene-django

Field for Postgres RangeField not work on Django 2.2.x( at least)

Open
#675 6 comments 0 reactions 0 assignees View on GitHub
🐛bug
Dominant language
Python
Stars
4.4k
Forks
760
PR merge metrics
No merged PRs in 30d

Description

I'm using Django 2.2.x, graphene-django 2.3.0

I use a Postgres DateTimeRangeField, but GraphQL reports error ""User Error: expected iterable, but did not find one for field XXX"

I digged in, and found in `graphql`: `execution/executor.py`
```
586 assert isinstance(result, Iterable), (
587 "User Error: expected iterable, but did not find one " + "for field {}.{}."
588 ).format(info.parent_type, info.field_name)
```

where result is NonNull, inside is DateTimeTZRange. which is not declared List(DateTime) declared inside graphene-django converter.py
```
233 @convert_django_field.register(RangeField)
234 def convert_posgres_range_to_string(field, registry=None):
235 inner_type = convert_django_field(field.base_field)
236 if not isinstance(inner_type, (List, NonNull)):
237 inner_type = type(inner_type)
238 return List(inner_type, description=field.help_text, required=not field.null)
```

I want to define a data type to show structure for Range like:
```
{
lower
upper
bounds
}
```
which will introduce break changes to current API.

is it OK to do this. or what else better solution to this?

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.