Skip to content

Specifying the literal value type of a custom scalar #1139

Open
@mindplay-dk

Description

@mindplay-dk

I was surprised to find there is no way to declare a custom scalar type with it's actual value type?

When declaring something like:

scalar Date

It's all down to run-time type-checking for actual Date literal values.

I was expecting something like:

scalar Date : String

vs

scalar Date : Int

I understand we can't statically verify the actual contents of e.g. a Date beyond the fact that it's a String or Int, but a literal could at least be validated (statically) for the correct literal value type, which would be better than nothing, wouldn't it?

At run-time, of course, there would be further validatio - but statically, a scalar is almost like a type alias, and could at least be validated as such, I think?

(Sorry if this has already been asked - it seems like this would be a common question for someone learning GraphQL, but I've read through dozens of issues and I couldn't find this question asked or answered.)

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