Skip to content

Add MapGraphQLSemanticNonNullSchema#9604

Merged
tobias-tengler merged 5 commits intomainfrom
tte/semantic-non-null-schema-endpoint
Apr 27, 2026
Merged

Add MapGraphQLSemanticNonNullSchema#9604
tobias-tengler merged 5 commits intomainfrom
tte/semantic-non-null-schema-endpoint

Conversation

@tobias-tengler
Copy link
Copy Markdown
Member

No description provided.

@tobias-tengler tobias-tengler marked this pull request as ready for review April 27, 2026 17:41
Copilot AI review requested due to automatic review settings April 27, 2026 17:41
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 adds an ASP.NET Core endpoint that serves a “semantic non-null” variant of the schema SDL by rewriting non-null wrappers (!) into @semanticNonNull directives, and updates the HTTP response formatting pipeline to support producing this output. In parallel, it removes the previous runtime semantic non-null feature (schema option + type interceptor + directive type + tests) from HotChocolate Core.

Changes:

  • Add MapGraphQLSemanticNonNullSchema and supporting middleware/formatter logic to expose a rewritten SDL at /graphql/semantic-non-null-schema.graphql.
  • Introduce SemanticNonNullSchemaRewriter to strip non-null wrappers from output fields and attach @semanticNonNull(levels: ...), plus tests and snapshots for the new behavior.
  • Remove Core’s EnableSemanticNonNull option + interceptor/directive implementation and associated test coverage/snapshots.

Reviewed changes

Copilot reviewed 74 out of 74 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/HotChocolate/Primitives/src/Primitives/ErrorCodes.cs Removes the execution error code for semantic non-null violations (runtime feature removal).
src/HotChocolate/Mutable/src/Types.Mutable/Serialization/SchemaFormatter.cs Fixes/cleans up SDL string formatting by delegating through FormatAsDocument.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Serialization/SchemaFormatter.cs Same SDL string formatting cleanup for Fusion schema formatter.
src/HotChocolate/Core/test/Types.Tests/snapshots/SemanticNonNullTests.Pagination.snap Removes snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Types.Tests/snapshots/SemanticNonNullTests.Object_With_Id_Field.snap Removes snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Types.Tests/snapshots/SemanticNonNullTests.MutationConventions.snap Removes snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Types.Tests/snapshots/SemanticNonNullTests.Interface_With_Id_Field.snap Removes snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Types.Tests/snapshots/SemanticNonNullTests.Derive_SemanticNonNull_From_ImplementationFirst_With_GraphQLType_As_Type.snap Removes snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Types.Tests/snapshots/SemanticNonNullTests.Derive_SemanticNonNull_From_ImplementationFirst_With_GraphQLType_As_String.snap Removes snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Types.Tests/snapshots/SemanticNonNullTests.Derive_SemanticNonNull_From_ImplementationFirst.snap Removes snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Types.Tests/snapshots/SemanticNonNullTests.Derive_SemanticNonNull_From_CodeFirst.snap Removes snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Types.Tests/snapshots/SemanticNonNullTests.Apply_SemanticNonNull_To_SchemaFirst.snap Removes snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Types.Tests/SemanticNonNullTests.cs Deletes Core type-system semantic non-null tests (feature removed).
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Query_With_NullableConnectionNodes.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Query_With_Connection.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Scalar_Throwing_Should_Null_And_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Scalar_Returns_Null_Should_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Scalar_List_Throwing_Should_Null_And_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Scalar_List_Returns_Null_Should_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Scalar_List_Item_Throwing_Should_Null_And_Error_Item.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Scalar_List_Item_Returns_Null_Should_Error_Item.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Scalar_ListOfList_Nullable_Outer_And_Inner_Middle_Returns_Null_Should_Null_And_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Scalar_ListOfList_Nullable_Middle_Item_Outer_And_Inner_Return_Null_Should_Null_And_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Object_Throwing_Should_Null_And_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Object_Returns_Null_Should_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Object_List_Throwing_Should_Null_FAnd_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Object_List_Returns_Null_Should_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Object_List_Item_Throwing_Should_Null_And_Error_Item.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Object_List_Item_Returns_Null_Should_Error_Item.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Nullable_Scalar_Returns_Null_Should_Null_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Nullable_Scalar_List_Returns_Null_Should_Null_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Nullable_Scalar_List_Item_Returns_Null_Should_Null_Item_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Nullable_Object_Returns_Null_Should_Null_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Nullable_Object_List_Returns_Null_Should_Null_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Pure_Nullable_Object_List_Item_Returns_Null_Should_Null_Item_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Mutation_With_MutationConventions.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Scalar_Throwing_Should_Null_And_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Scalar_Returns_Null_Should_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Scalar_List_Throwing_Should_Null_And_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Scalar_List_Returns_Null_Should_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Scalar_List_Item_Throwing_Should_Null_And_Error_Item.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Scalar_List_Item_Returns_Null_Should_Error_Item.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Object_Throwing_Should_Null_And_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Object_Returns_Null_Should_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Object_List_Throwing_Should_Null_FAnd_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Object_List_Returns_Null_Should_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Object_List_Item_Throwing_Should_Null_And_Error_Item.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Object_List_Item_Returns_Null_Should_Error_Item.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Nullable_Scalar_Returns_Null_Should_Null_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Nullable_Scalar_List_Returns_Null_Should_Null_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Nullable_Scalar_List_Item_Returns_Null_Should_Null_Item_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Nullable_Object_Returns_Null_Should_Null_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Nullable_Object_List_Returns_Null_Should_Null_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/snapshots/SemanticNonNullTests.Async_Nullable_Object_List_Item_Returns_Null_Should_Null_Item_Without_Error.snap Removes execution snapshots tied to the removed Core runtime semantic non-null feature.
src/HotChocolate/Core/test/Execution.Tests/SemanticNonNullTests.cs Deletes Core execution semantic non-null tests (feature removed).
src/HotChocolate/Core/src/Types/Types/Directives/SemanticNonNullDirective.cs Removes the Core directive type implementation (feature removed).
src/HotChocolate/Core/src/Types/SemanticNonNullTypeInterceptor.cs Removes the Core interceptor that applied semantic non-null behavior (feature removed).
src/HotChocolate/Core/src/Types/SchemaOptions.cs Removes EnableSemanticNonNull option (breaking API/behavior change).
src/HotChocolate/Core/src/Types/SchemaBuilder.cs Stops registering the semantic non-null interceptor by default.
src/HotChocolate/Core/src/Types/IReadOnlySchemaOptions.cs Removes EnableSemanticNonNull from the public options contract.
src/HotChocolate/Core/src/Types/Configuration/BuiltInDirectiveTypeReferences.cs Stops conditionally enqueuing the semantic non-null directive type.
src/HotChocolate/Core/src/Abstractions/WellKnownMiddleware.cs Removes the semantic non-null middleware key constant.
src/HotChocolate/AspNetCore/test/AspNetCore.Tests/snapshots/HttpGetSemanticNonNullSchemaMiddlewareTests.Download_GraphQL_SemanticNonNull_Schema_Explicit_Pattern.snap Adds snapshot for the rewritten semantic non-null SDL output.
src/HotChocolate/AspNetCore/test/AspNetCore.Tests/snapshots/HttpGetSemanticNonNullSchemaMiddlewareTests.Download_GraphQL_SemanticNonNull_Schema.md Adds full HTTP snapshot for semantic non-null schema download behavior/headers.
src/HotChocolate/AspNetCore/test/AspNetCore.Tests/SemanticNonNullSchemaRewriterTests.cs Adds unit tests for SDL rewriting logic (levels computation, skip rules, directive placement).
src/HotChocolate/AspNetCore/test/AspNetCore.Tests/HttpGetSemanticNonNullSchemaMiddlewareTests.cs Adds integration tests for the new GET endpoint (default + custom pattern + disabled scenarios).
src/HotChocolate/AspNetCore/test/AspNetCore.Tests.Utilities/ServerTestBase.cs Maps the semantic non-null schema endpoint in the StarWars test server setup.
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/MiddlewareFactory.cs Adds factory method to wire the new semantic non-null schema middleware.
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/HttpGetSemanticNonNullSchemaMiddleware.cs New middleware that serves the semantic non-null schema SDL on GET requests.
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Formatters/SemanticNonNullSchemaRewriter.cs New SDL rewriter that converts ! nullability into @semanticNonNull(levels: ...).
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Formatters/IHttpResponseFormatter.cs Extends the formatter contract to add semantic non-null schema formatting.
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Formatters/DefaultHttpResponseFormatter.cs Implements caching/output for semantic non-null schema downloads.
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/Extensions/EndpointRouteBuilderExtensions.cs Adds MapGraphQLSemanticNonNullSchema endpoint mapping API and default route.
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/ExecutorSession.cs Adds session helper for writing the semantic non-null schema via the response formatter.
Comments suppressed due to low confidence (1)

src/HotChocolate/Core/src/Types/SchemaOptions.cs:110

  • PR title focuses on adding a semantic-non-null schema endpoint, but this change set also removes the EnableSemanticNonNull option (and related interceptor/behavior) from the core schema options. That’s a breaking change for consumers who enabled the experimental feature. If this removal is intentional, it should be clearly called out in the PR description/release notes and/or kept behind an opt-in/back-compat switch; otherwise, consider restoring the option/interceptor and making the new endpoint independent of runtime semantic-non-null execution.
    /// <inheritdoc cref="IReadOnlySchemaOptions.EnableDefer"/>
    public bool EnableDefer { get; set; }

    /// <inheritdoc cref="IReadOnlySchemaOptions.EnableStream"/>
    public bool EnableStream { get; set; }

    /// <inheritdoc cref="IReadOnlySchemaOptions.StripLeadingIFromInterface"/>
    public bool StripLeadingIFromInterface { get; set; }

    /// <inheritdoc cref="IReadOnlySchemaOptions.EnableTag"/>

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

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