Skip to content

Empty value for Decimal scalar #927

Closed
@hgylfason

Description

Is empty string considered an invalid value for Decimal scalar?

If so then how do we represent an empty value for a Decimal?

I've tried to fix this by parsing empty string to None but that results in an error. The error happens in graphql.utils.is_valid_value (see below).

"""
This part of the code from `graphql.utils.is_valid_value` returns errors 
when None value is returned from Decimal scalar
"""
parse_result = type.parse_value(value)
    if parse_result is None:
        return [u'Expected type "{}", found {}.'.format(type, json.dumps(value))]

UPDATE:
I dug my head out of the sand and realised that using null on the client is the obvious thing to do for clearing a value.

Activity

changed the title Decimal scalar and empty values Empty value for Decimal scalar on Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Empty value for Decimal scalar · Issue #927 · graphql-python/graphene