RFC X / Superseded

Scalar serialize as built-in scalar type

Opened on
Closed on

At a glance

Project
GraphQL Spec
Identifier
#326
Stage
RFC X / Superseded
Champion
@leebyron
Updated
2025-06-12
Latest activity
Marked as Superseded on
Source

Pull request description

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.

This spec text has a reference implementation here: https://github.com/graphql/graphql-js/pull/914/

Timeline

June 2025

October 2018

September 2018

  • On the agenda for GraphQL WG

    13 listed attendees · 10 agenda items · 7 linked RFCs

    • Opening of the meeting
    • Introduction of attendees
    • Review agenda (5m)
    • Determine volunteers for note taking (5m)
    • Discussion of Allowing singular variables for lists (10m) #509
    • Discussion of Variable Definition Directives (5m) #510
    • Update on #429 - limiting the scope of "Directives Are Unique Per Location" validation. (OI 10m) #470 #471 #472
    • Update on Compatibility Acceptance Tests (CATs). (OI 10m)
    • Proposal to support description on Schema (IG 5m) #466
    • Next steps for "Define custom scalars in terms of built-in scalars" (spec changes, graphql-js) (IG 15m) #326

February 2018

  • On the agenda for GraphQL WG

    15 listed attendees · 14 agenda items · 3 linked RFCs

    • Opening of the meeting
    • Introduction of attendees
    • Review agenda (5m)
    • Determine volunteers for note taking (5m)
    • Discuss upcoming meeting schedule (5m)
    • Share status of Schema Definition Language & Next spec version (10m)
    • Present graphql-import (5m)
    • Next steps for "GraphQL over HTTP" spec (15m)
    • SDL syntax for custom scalars (15m) #326
    • Discuss subscriptions for live queries (15m)
    • Discuss moving connection/global ID specs from Relay into best practices repo (15m) #232
    • Exposing schema metadata (30m)
    • Discuss errors (30m)
    • Discuss interface hierarchies (30m) RFC, POC #373

October 2017

June 2017