Skip to content
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

Rebase of "Schema scalar of type" #1173

Closed

Commits on Dec 20, 2017

  1. RFC: Define custom scalars in terms of built-in scalars.

    This proposes an additive change which allows custom scalars to be defined in terms of the built-in scalars. The motivation is for client-side code generators to understand how to map between the GraphQL type system and a native type system. As an example, a `URL` custom type may be defined in terms of the built-in scalar `String`. It could define additional serialization and parsing logic, however client tools can know to treat `URL` values as `String`. Presently, we do this by defining these mappings manually on the client, which is difficult to scale, or by giving up and making no assumptions of how the custom types serialize.
    
    Another real use case of giving client tools this information is GraphiQL: this change will allow GraphiQL to show more useful errors when a literal of an incorrect kind is provided to a custom scalar. Currently GraphiQL simply accepts all values.
    
    To accomplish this, this proposes adding the following:
    
    * A new property when defining `GraphQLScalarType` (`ofType`) which asserts that only built-in scalar types are provided.
    
    * A second type coercion to guarantee to a client that the serialized values match the `ofType`.
    
    * Delegating the `parseLiteral` and `parseValue` functions to those in `ofType` (this enables downstream validation / GraphiQL features)
    
    * Exposing `ofType` in the introspection system, and consuming that introspection in `buildClientSchema`.
    
    * Adding optional syntax to the SDL, and consuming that in `buildASTSchema` and `extendSchema` as well as in `schemaPrinter`.
    
    * Adding a case to `findBreakingChanges` which looks for a scalar's ofType changing.
    leebyron authored and IvanGoncharov committed Dec 20, 2017
    Configuration menu
    Copy the full SHA
    61ed701 View commit details
    Browse the repository at this point in the history
  2. Replace = with as

    leebyron authored and IvanGoncharov committed Dec 20, 2017
    Configuration menu
    Copy the full SHA
    4f72c13 View commit details
    Browse the repository at this point in the history