Skip to content

Bug: Supposedly wrong types in query with filter_fields since 2.4.0 #750

Closed
@lassesteffen

Description

@lassesteffen

Problem

When using filter_fields I get an error about using wrong types which started appearing in 2.4.0.
Variable "startedAtNull" of type "Boolean" used in position expecting type "DateTime". The error does not occur with graphene-django 2.3.2

Context

  • using django-filter 2.2.0
  • django 2.4.0

Schema.py

DATETIME_FILTERS = ['exact', 'isnull', 'lt', 'lte', 'gt', 'gte', 'month', 'year', 'date']

class OrderNode(DjangoObjectType):
    class Meta:
        model = Order
        exclude = ('tenant', )
        filter_fields = {
            'id': ['exact'],
            'start_at': DATETIME_FILTERS,
            'finish_at': DATETIME_FILTERS,
            'finished_at': DATETIME_FILTERS,
            'started_at': DATETIME_FILTERS,
        }
        interfaces = (OrderNodeInterface,)

Query:

ORDERS_QUERY = '''
    query order(
        $tenant: String
        $projectId: ID
        $startedAtNull: Boolean
    ) {
        orders(
            tenant: $tenant
            project_Id: $projectId
            startedAt_Isnull: $startedAtNull
        ) {
            edges {
                node {
                    id,
                    city
                }
            }
        }
    }
'''

Result:
Variable "startedAtNull" of type "Boolean" used in position expecting type "DateTime".

Solution

I am confident it is related to this PR: https://github.com/graphql-python/graphene-django/pull/682/files . In graphene_django/filter/utils.py the way how to retrieve the Type of a field was changed. Or maybe I misunderstood the changelog.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions