Adding well-documented custom scalars
In GraphQL, custom scalars do not necessarily mean a different underlying type. A custom scalar can still be based on types such as Int
or String
. So, why is it worth using a custom scalar? It’s because custom scalars allow us to avoid repetition and have well-documented fields without duplicating documentation.
When we use a custom scalar, we can define a specific name and behavior for a scalar type that suits our needs. For example, we might have a custom scalar called Date
that represents dates in a specific format. Although the underlying type might be String
or even Int
, using a custom scalar allows us to have a clear and consistent representation of dates throughout our schema.
By using a custom scalar, we can also provide a centralized and well-documented definition for that specific type. This means we don’t have to repeat the same description or documentation for every field that uses the custom scalar. Instead, we...