Skip to content

[Fusion] Support coercing number without decimals to Float#9491

Merged
tobias-tengler merged 3 commits intomainfrom
tte/fix-fusion-float-coercion-issue
Mar 31, 2026
Merged

[Fusion] Support coercing number without decimals to Float#9491
tobias-tengler merged 3 commits intomainfrom
tte/fix-fusion-float-coercion-issue

Conversation

@tobias-tengler
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings March 31, 2026 11:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates HotChocolate Fusion and the OpenAPI adapter to better handle GraphQL Float inputs provided as whole numbers (e.g., 500), aligning behavior across JSON variable coercion and HTTP query parameter parsing.

Changes:

  • Allow IntValue literals to be treated as compatible when the target scalar expects Float in Fusion variable coercion.
  • Correct spec scalar serialization types in Fusion composite schema building (e.g., Float => ScalarSerializationType.Float).
  • Add OpenAPI adapter coverage for Float query parameters with and without decimals, and make numeric parsing culture-invariant.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/VariableCoercionTests.cs Adds tests verifying Float variables accept whole numbers, 500.0, and fractional values.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/FusionScalarTypeDefinition.cs Treats IntValue literals as compatible when a scalar’s value kind includes Float.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Completion/CompositeSchemaContext.cs Assigns correct ScalarSerializationType for built-in spec scalars instead of always String.
src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/TestSchema.cs Adds a query field used by new OpenAPI HTTP query parameter tests.
src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/Endpoints/HttpEndpointIntegrationTestBase.cs Adds integration tests for Float query params (500 and 500.99).
src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/Endpoints/snapshots/HttpEndpointIntegrationTestBase.Http_Get_With_Query_Parameter_Float_Value.snap Snapshot for whole-number float query parameter case.
src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/Endpoints/snapshots/HttpEndpointIntegrationTestBase.Http_Get_With_Query_Parameter_Float_Value_With_Decimals.snap Snapshot for decimal float query parameter case.
src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/Execution/DynamicEndpointMiddleware.cs Uses InvariantCulture when parsing int/double from query/route string values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/HotChocolate/Adapters/test/Adapters.OpenApi.Tests/TestSchema.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants