Cherry pick upgrade Hot Chocolate to version 16.0.0#3603
Merged
Conversation
## Why make this change? Closes #3448 Hot Chocolate has released stable v16.0.0 and we upgrade DAB to that version. ## What is this change? ### Update deps Bump 6 HC packages to 16.0.0 in Directory.Packages.props: HotChocolate, HotChocolate.AspNetCore, HotChocolate.AspNetCore.Authorization, HotChocolate.Types.NodaTime, HotChocolate.Utilities.Introspection, HotChocolate.Diagnostics. ### Breaking changes (GraphQL schema) HC v16 forces / motivates two schema-type renames. Wire formats and runtime values are unchanged for both. REST and CLI surface area is unchanged. Scalar: Byte -> UnsignedByte Filter input: ByteFilterInput -> UnsignedByteFilterInput HC v16 split the legacy `ByteType` into a signed `ByteType` (sbyte, -128..127) and a new `UnsignedByteType` (byte, 0..255). SQL Server `tinyint` is unsigned, so DAB must bind to `UnsignedByteType`. Scalar: ByteArray -> Base64String Filter input: ByteArrayFilterInput -> Base64StringFilterInput HC v16 marked `ByteArrayType` as [Obsolete] in favor of `Base64StringType`. Both serialize byte[] as a base64-encoded JSON string (identical wire format), but the GraphQL scalar name is now `Base64String`. DAB targets the new name so the generated schema does not depend on a deprecated scalar. Inline literal filters continue to work for both renames. Clients that declare typed variables of `ByteFilterInput` or `ByteArrayFilterInput`, or that regenerate code from the schema (graphql-codegen, Strawberry Shake, etc.), must update the type names. ### Refactor scalar APIs v16 renamed scalar overrides (`ParseLiteral`/`ParseValue` -> `OnCoerceInputLiteral`/`OnCoerceInputValue`/`OnCoerceOutputValue`/ `OnValueToLiteral`) and call-site helpers (`ParseValue`/`ParseResult` -> `ValueToLiteral`). `DateTimeType.ValueToLiteral` only accepts `DateTimeOffset`, so we convert at the boundary. HC v16 also elides trailing zero fractional seconds on DateTime output (`...:54.000Z` -> `...:54Z`), which surfaced in several test assertion updates. ### Refactor resolver/execution APIs `ISelection` was removed (use concrete `Selection`); `Selection.SyntaxNode` became a `ReadOnlySpan<FieldSelectionNode>` (`SyntaxNodes`) to support field-merging; `TimeSpanType` was replaced by `DurationType` (ISO-8601, parsed via `XmlConvert.ToTimeSpan`); `OperationResult.WithContextData` is gone (set `singleResult.ContextData` directly). ### Refactor request interceptor and status middleware `IntrospectionInterceptor` now has a no-arg constructor (schema services are isolated from request services in v16) and implements the new four-arg `OnCreateAsync(HttpContext, IRequestExecutor, OperationRequestBuilder, CancellationToken)` signature; `RuntimeConfigProvider` is resolved from `context.RequestServices` at request time. `DetermineStatusCodeMiddleware` was updated for the unified `OperationResult` type. Status codes are now propagated via context-data (`ExecutionContextData.HttpStatusCode`) using an `ImmutableDictionary` builder rather than mutating the response directly. ### Adopt lazy schema initialization (LazyInitialization = true) HC v16 builds the schema eagerly during host startup by default. DAB supports a "hosted" scenario where the runtime config is supplied after the host starts (POST `/configuration`), so eager construction races with our placeholder fallback. We opt back into the v15 default (`options.LazyInitialization = true`) so the schema is built on the first GraphQL request, by which time the runtime config and metadata provider are ready. ### Drop ModifyOptions(o => o.EnableOneOf = true) OneOf is on by default in v16. ### Refactor startup `DateTimeType(disableFormatCheck: bool)` is obsolete (replaced by `DateTimeOptions { ValidateInputFormat = ... }`, polarity flipped); `WithOptions` only accepts `Action<GraphQLServerOptions>` (per-request); `MapNitroApp().WithOptions(GraphQLToolOptions)` was removed. Nitro is now served by the same `/graphql` endpoint and is governed by `options.Tool.Enable` on the per-request server options. ### Harden Selection.SyntaxNodes access HC v16's `Selection.SyntaxNodes` is a `ReadOnlySpan<FieldSelectionNode>`, so direct `SyntaxNodes[0].Node` indexing would surface as `IndexOutOfRangeException` at request time if the span were ever empty. Added `Selection.RequireFieldNode()` in `SelectionExtensions.cs` (`IsEmpty` check, return `SyntaxNodes[0].Node`, throw targeted `DataApiBuilderException` otherwise). Adopted at all call sites in `SqlQueryStructure`, `CosmosQueryStructure`, and `ExecutionHelper`. ### Test updates Adopt v16 `OperationResultData` / `ResultDocument` / `ResultElement` / `ResultProperty` traversal in `MultiSourceQueryExecutionUnitTests`. Update `TestNoConfigReturnsServiceUnavailable` to recognize that lazy `WithOptions` resolution surfaces "no runtime config" as `DataApiBuilderException(ServiceUnavailable)` rather than a 503 response or `ApplicationException`. Update DateTime literal assertions and filter input name references in affected test files. Decouple the GraphQL-scalar name from the test database column name in `GraphQLSupportedTypesTestsBase` and the My/Pg test classes so the `Byte`/`UnsignedByte` and `ByteArray`/`Base64String` renames do not require renaming `byte_types`/`bytearray_types` columns. ## How was this tested? Run against current test suite. --------- Co-authored-by: Souvik Ghosh <souvikofficial04@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Cherry-picks the DAB upgrade to Hot Chocolate v16.0.0 and applies the required API, schema, and test updates to keep GraphQL behavior consistent (or intentionally adjusted) across hosted/CLI scenarios.
Changes:
- Upgrades Hot Chocolate packages to 16.0.0 and updates DAB integrations for v16 API changes (lazy schema init, selection syntax nodes, scalar APIs).
- Updates GraphQL scalar/type mappings (UnsignedByte, Base64String, Duration) and default-value literal generation.
- Adjusts and adds tests to match v16 result traversal and DateTime serialization changes; adds upgrade design notes.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service/Startup.cs | Enables lazy schema initialization, adds placeholder schema fallback, and updates GraphQL endpoint tool options for HC v16. |
| src/Service.Tests/UnitTests/MultiSourceQueryExecutionUnitTests.cs | Updates result traversal/assertions for HC v16 ResultDocument APIs. |
| src/Service.Tests/SqlTests/GraphQLSupportedTypesTests/PostgreSqlGQLSupportedTypesTests.cs | Adjusts bytearray column formatting detection post Base64String rename. |
| src/Service.Tests/SqlTests/GraphQLSupportedTypesTests/MySqlGQLSupportedTypesTests.cs | Updates DateTime expected output formatting and bytearray detection. |
| src/Service.Tests/SqlTests/GraphQLSupportedTypesTests/GraphQLSupportedTypesTestsBase.cs | Centralizes test field name mapping to handle scalar renames. |
| src/Service.Tests/SqlTests/GraphQLMutationTests/GraphQLMutationTestBase.cs | Updates DateTime expected output due to HC v16 formatting changes. |
| src/Service.Tests/GraphQLBuilder/MultiSourceBuilderTests.cs | Adds unit tests for Query placeholder field injection logic. |
| src/Service.Tests/Configuration/ConfigurationTests.cs | Adjusts “no config” behavior assertions for HC v16 request pipeline changes. |
| src/Service.GraphQLBuilder/Sql/SchemaConverter.cs | Moves to ValueToLiteral APIs and updates DateTime/byte[] scalar handling for v16. |
| src/Service.GraphQLBuilder/SelectionExtensions.cs | Adds Selection.RequireFieldNode() helper for v16 SyntaxNodes span API. |
| src/Service.GraphQLBuilder/Queries/StandardQueryInputs.cs | Updates filter input scalar names (UnsignedByte/Base64String) to match schema. |
| src/Service.GraphQLBuilder/GraphQLTypes/SupportedTypes.cs | Updates scalar name constants for UnsignedByte and Base64String. |
| src/Service.GraphQLBuilder/GraphQLTypes/DefaultValueType.cs | Binds default value inputs to UnsignedByteType/Base64StringType. |
| src/Service.GraphQLBuilder/GraphQLStoredProcedureBuilder.cs | Updates default-value literal creation and invariant-culture parsing. |
| src/Service.GraphQLBuilder/CustomScalars/SingleType.cs | Updates custom scalar coercion/serialization overrides to HC v16 APIs. |
| src/Directory.Packages.props | Bumps Hot Chocolate package versions to 16.0.0. |
| src/Core/Services/GraphQLSchemaCreator.cs | Injects placeholder Query field to satisfy HC v16 eager schema validation. |
| src/Core/Services/ExecutionHelper.cs | Updates scalar runtime conversions (UnsignedByte/Base64String/Duration) and selection node access. |
| src/Core/Services/DetermineStatusCodeMiddleware.cs | Updates context data setting to match HC v16 result API changes. |
| src/Core/Resolvers/Sql Query Structures/SqlQueryStructure.cs | Uses RequireFieldNode() replacing removed Selection.SyntaxNode. |
| src/Core/Resolvers/CosmosQueryStructure.cs | Uses concrete Selection + RequireFieldNode() for HC v16 selection APIs. |
| src/Core/Parsers/IntrospectionInterceptor.cs | Resolves runtime config from HttpContext.RequestServices due to v16 DI scoping changes. |
| docs/design/HC16-upgrade.md | Adds design rationale and migration notes for HC v16 upgrade. |
Aniruddh25
approved these changes
May 19, 2026
Collaborator
Aniruddh25
left a comment
There was a problem hiding this comment.
Approving since its a pure cherry pick. Make sure the comments from copilot are not concerning.
souvikghosh04
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why make this change?
Cherry pick PR for upgrading DAB to Hot Chocolate v16.0.0
closes #3604
What is this change?
Cherry pick this PR: #3480
How was this tested?
Test against current test suite.