-
Couldn't load subscription status.
- Fork 1.2k
RFC: Scalar serialize as built-in scalar type #521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Currently, Custom Scalars only describe their name and no other behavior about them can be programmatically determined. However in practice most custom scalar types are specializations of one of the existing built-in scalar types (String, Int, Float, etc.). This proposes adding one additional piece of metadata to custom scalars, a "serializes as" type which must be a built-in scalar type. This serialize as type describes what kinds of values are allowed to be provided as input to that type and what kind of value is expected to serialize from that type. This metadata is useful for code-generation systems which expect to generate code in well typed environments. It can also improve the validation accuracy and IDE ergonomics by providing a similar level of information about custom scalars as exist for the built-in scalars. To provide this metadata to those kinds of tools, this also extends the introspection system to return the serialize as type in the `ofType` field.
e5d241d to
6c81ed8
Compare
|
I've removed the "Next stage?" label from this as it hasn't been updated in about 7 years. If someone intends to represent this at an upcoming WG, let me know and I'll add it back 👍 |
|
I'm interested in this. In Apollo Kotlin, we currently have Having it in the spec would be helpful but I have zero time to dive into this right now. This is FYI only 😄 |
As @leebyron suggested during last WG I'm adopting #326 and rebasing it on top of current master.
Currently, Custom Scalars only describe their name and no other behavior about them can be programmatically determined. However in practice most custom scalar types are specializations of one of the existing built-in scalar types (String, Int, Float, etc.).
This proposes adding one additional piece of metadata to custom scalars, a "serializes as" type which must be a built-in scalar type. This serialize as type describes what kinds of values are allowed to be provided as input to that type and what kind of value is expected to serialize from that type. This metadata is useful for code-generation systems which expect to generate code in well typed environments. It can also improve the validation accuracy and IDE ergonomics by providing a similar level of information about custom scalars as exist for the built-in scalars.
To provide this metadata to those kinds of tools, this also extends the introspection system to return the serialize as type in the
ofTypefield.