sangria-graphql / sangria

Scala GraphQL implementation
https://sangria-graphql.github.io
Apache License 2.0
1.96k stars 226 forks source link

ScalarAlias description #408

Open diversit opened 6 years ago

diversit commented 6 years ago

Could you please add a function to ScalarAlias which allows overriding the description just like rename overrides the name?

When creating simple aliases like PositiveInt or NotBlankString I would also like to update the description to better document the api.

Since ScalarAlias is a case class it is not possible to extend it and because InputType is sealed I also cannot create my own ScalarAlias.

OlegIlyenko commented 6 years ago

I afraid it would not be possible to override description for ScalarAlias since it is purely scala-based mechanism to make interaction with more generic scalar values more type safe. This information is not exposed via introspection API - on API level they are seen as normal scalar values.

If you would like to expose this information, I would suggest using custom scalars (Although I would also recommend to use them conservatively since custom scalars in the current form are opaque to the client, there are RFCs that are trying to improve on this though). When you are defining custom scalar type, you can also provide the description.