Skip to content

allow coercing's parseLiteral to return null  #1362

Closed

Description

@HenryLauu

I am implementing a custom scalar called LocalDateTime which parse a string input to java.time.LocalDateTime. when I accept a null or empty string, I want to interpret it as a null LocalDateTime, but Coercing interface doesn't allow me to return a null value.

a possible solution is to provide a config to ScalarType

Activity

  1. deleted a comment from HenryLauu on Dec 26, 2018
  2. andimarek commented on Dec 26, 2018

    @andimarek
    Member

    I would need to check the spec again, but I am not sure this is allowed: you will not get null as argument in a scalar, because null means null and no coercing is needed. The question is now if you are allowed to return null, and I don't think so (but I maybe wrong): A non null scalar value must result in a non null coerced value.

  3. bbakerman commented on Dec 28, 2018

    @bbakerman
    Member
  4. andimarek commented on Jan 21, 2019

    @andimarek
    Member

    After looking more into this issues we agree: we should allow returning null values from a Scalar for serialize.

    graphql-js also added it explicitly: graphql/graphql-js@daa7759

  5. andimarek commented on Jan 21, 2019

    @andimarek
    Member

    @HenryLauu do you need it for parserLiteral or serialize?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs PRWe need to create a PR for it

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions