Skip to content

Null value from non-required enum field raises exception #201

Closed
@picturedots

Description

@picturedots

I've been searching for the underlying cause of the error in graphene-django that breaks Django choice fields when the value is blank: graphql-python/graphene-django#474 . This is a regression, new since graphql-core 2.1.

The validation for an enum value new in version 2.1 doesn't seem to take into account whether or not the field is allowed to have a null value before raising an exception.

From https://github.com/graphql-python/graphql-core/blob/fa4eeda36029680205e20059379e89189b946032/graphql/execution/executor.py#L605

if serialized_result is None:
    raise GraphQLError(
        ('Expected a value of type "{}" but ' + "received: {}").format(
            return_type, result
        ),
        path=path,
    )

Should this exception be the exception shouldn't be raised unconditionally? The graphql source has the same pattern in it but perhaps catches the error ... https://github.com/graphql/graphql-js/blob/master/src/execution/execute.js#L967

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions