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

RFC Nesting scalars #42

Open
SerafimArts opened this issue Dec 19, 2017 · 2 comments
Open

RFC Nesting scalars #42

SerafimArts opened this issue Dec 19, 2017 · 2 comments

Comments

@SerafimArts
Copy link
Member

Add inheritance scalars syntax:

scalar Email extends String

In this case, all behavior is completely inherited from the parent. In the absence of a parent, the behavior is reduced to type Any: https://railt.org/docs/sdl/scalar/any

@fesor
Copy link

fesor commented Dec 22, 2017

Maybe instead of inheritance (extends keyword) provide something like aliasing?

type Email as String

@SerafimArts
Copy link
Member Author

SerafimArts commented Dec 22, 2017

@fesor
By creating this offer, I wanted to:

  1. To legalize that scheme for the redefinition of scalars, which is already present.
type A { field: Any }
extend type A { field: String } # <<< "field" type override
  1. Simplify the casting system (serialization).

Having the same row as the parent, we will know that the value is converted to a string with the ability to override this behavior with the help of, for example, directives, like here: https://railt.org/docs/sdl/scalar/custom

At the moment, each scalar has a strictly wired inheritance scheme and the permissibility of overriding. Right in the code: https://github.com/railt/railt/blob/master/src/Railt/Reflection/Standard/Scalars/StringType.php#L17

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

No branches or pull requests

2 participants