Skip to content

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

@sprhawk

Description

@sprhawk

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions