diff --git a/website/src/docs/hotchocolate/v16/building-a-schema/scalars.md b/website/src/docs/hotchocolate/v16/building-a-schema/scalars.md index 86bce8f6a07..5bac79fd370 100644 --- a/website/src/docs/hotchocolate/v16/building-a-schema/scalars.md +++ b/website/src/docs/hotchocolate/v16/building-a-schema/scalars.md @@ -234,16 +234,32 @@ Beyond the five spec scalars, Hot Chocolate provides these scalars out of the bo ## DateTime Configuration -The `DateTime` scalar defaults to UTC. You can configure the precision and format using `DateTimeOptions`: +`HotChocolate.Types.DateTimeOptions` configures the built-in BCL-backed `DateTime`, `LocalDateTime`, and `LocalTime` scalars: + +- `InputPrecision` controls how many fractional second digits are accepted during parsing, up to `9`. +- `OutputPrecision` controls how many fractional second digits are written during serialization, up to `7`. +- `ValidateInputFormat` controls whether input is validated against the expected scalar format before parsing. + +Although the built-in scalars can parse up to 9 fractional second digits, the underlying BCL types only preserve up to 7 digits (100-nanosecond precision), so additional digits are rounded during parsing. + +To customize the built-in scalars, register configured scalar instances explicitly: ```csharp // Program.cs builder.Services .AddGraphQLServer() - .ModifyOptions(o => + .AddType(new DateTimeType(new DateTimeOptions { - o.DateTimeOptions.DateTimePrecision = DateTimePrecision.Milliseconds; - }); + OutputPrecision = 3 + })) + .AddType(new LocalDateTimeType(new DateTimeOptions + { + OutputPrecision = 3 + })) + .AddType(new LocalTimeType(new DateTimeOptions + { + OutputPrecision = 3 + })); ```