Skip to content

Add semantic introspection#9533

Open
michaelstaib wants to merge 19 commits intomainfrom
mst/semantic-introspection
Open

Add semantic introspection#9533
michaelstaib wants to merge 19 commits intomainfrom
mst/semantic-introspection

Conversation

@michaelstaib
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 12, 2026 04:53
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

Adds “semantic introspection” to HotChocolate by introducing new introspection fields for schema discovery and lookup, backed by a BM25-based in-memory search index and new introspection types/unions across Core and Fusion.

Changes:

  • Introduce __search and __definitions introspection fields (gated via EnableSemanticIntrospection) plus __SearchResult and __SchemaDefinition.
  • Add BM25 indexing/search implementation (SchemaIndexer, BM25Index, BM25SearchProvider, tokenizer) and public abstractions (ISchemaSearchProvider, result/path types).
  • Wire feature into Core and Fusion schema building/execution and update tests/snapshots accordingly.

Reviewed changes

Copilot reviewed 55 out of 55 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/HotChocolate/Primitives/src/Primitives/Types/IntrospectionFieldNames.cs Adds field-name constants/spans for __search and __definitions.
src/HotChocolate/Fusion/src/Fusion.Execution/Text/Json/SourceResultElementBuilder.cs Adds number-writing support (SetNumberValue) for JSON output.
src/HotChocolate/Fusion/src/Fusion.Execution/HotChocolate.Fusion.Execution.csproj Links BM25 search source files into Fusion.Execution build.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/IntrospectionExecutionNode.cs Enhances introspection selection execution to support abstract types (union/interface).
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Introspection/SearchResultData.cs Adds Fusion runtime backing data for __SearchResult.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Introspection/SchemaCoordinateResolver.cs Adds Fusion resolver for schema coordinates and union member type names.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Introspection/Query.cs Adds Fusion resolvers for __search and __definitions (feature-gated).
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Introspection/MemHelper.cs Adds float-number writing helper for introspection JSON output.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Introspection/__SearchResult.cs Adds Fusion interceptor/resolvers for __SearchResult fields.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/FusionRequestExecutorManager.cs Wires semantic introspection option into interceptor registration + DI service registration in Fusion.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/FusionOptions.cs Adds EnableSemanticIntrospection to Fusion options + cloning support.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/IFusionSchemaOptions.cs Exposes EnableSemanticIntrospection on Fusion schema options interface.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/FusionSchemaOptions.cs Propagates EnableSemanticIntrospection into Fusion schema options copy.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Completion/SemanticIntrospectionSchema.cs Adds schema SDL for __SearchResult and __SchemaDefinition (Fusion completion).
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Completion/CompositeSchemaBuilder.cs Adds semantic introspection types/fields to Fusion composite schema based on option.
src/HotChocolate/Core/test/Validation.Tests/IntrospectionRuleTests.cs Pins semantic introspection off to keep existing validation test behavior stable.
src/HotChocolate/Core/test/Types.Tests/Types/Scalars/snapshots/Issue6970ReproTests.Schema_With_IDictionary_String_Object_Output_Field_Builds.snap Snapshot updates due to added introspection/directive surface.
src/HotChocolate/Core/test/Types.Tests/Types/Introspection/Search/SchemaIndexerTests.cs Adds tests for schema indexing and reverse map construction.
src/HotChocolate/Core/test/Types.Tests/Types/Introspection/Search/BM25TokenizerTests.cs Adds tokenizer unit tests (splitting/normalization).
src/HotChocolate/Core/test/Types.Tests/Types/Introspection/Search/BM25SearchProviderTests.cs Adds provider tests (search, pagination, scoring, paths, concurrency).
src/HotChocolate/Core/test/Types.Tests/Types/Introspection/Search/BM25IndexTests.cs Adds BM25 index unit tests (build/search/ranking).
src/HotChocolate/Core/test/Types.Tests/Configuration/snapshots/TypeInitializerTests.Register_SchemaType_ClrTypeExists.snap Snapshot updates for new query introspection fields.
src/HotChocolate/Core/test/Types.Tests/Configuration/snapshots/TypeInitializerTests.Register_ClrType_InferSchemaTypes.snap Snapshot updates for new query introspection fields.
src/HotChocolate/Core/test/Types.Tests/Configuration/snapshots/TypeDiscovererTests.Register_SchemaType_ClrTypeExists.snap Snapshot updates to include new introspection types/scalars.
src/HotChocolate/Core/test/Types.Tests/Configuration/snapshots/TypeDiscovererTests.Register_ClrType_InferSchemaTypes.snap Snapshot updates to include new introspection types/scalars.
src/HotChocolate/Core/test/Types.Tests/snapshots/SchemaFirstTests.Interfaces_Impl_Interfaces_Are_Correctly_Exposed_Through_Introspection.snap Snapshot updates to include new introspection types/unions/scalars.
src/HotChocolate/Core/test/Types.Tests/snapshots/SchemaFirstTests.DescriptionsAreCorrectlyRead.snap Snapshot updates to include new introspection types/unions/scalars.
src/HotChocolate/Core/test/Types.Tests/snapshots/CodeFirstTests.Allow_PascalCasedArguments_Schema.graphql Snapshot updates due to added directive/introspection surface.
src/HotChocolate/Core/test/Execution.Tests/SemanticIntrospectionTests.cs Adds end-to-end execution tests for __search and __definitions.
src/HotChocolate/Core/test/Execution.Tests/Integration/StarWarsCodeFirst/snapshots/StarWarsCodeFirstTests.Ensure_Benchmark_Query_LargeQuery.snap Snapshot updates to include new introspection types/unions/scalars.
src/HotChocolate/Core/test/Execution.Tests/snapshots/IntrospectionTests.ExecuteGraphiQLIntrospectionQuery.snap Snapshot updates to include new introspection types/unions/scalars.
src/HotChocolate/Core/test/Execution.Tests/snapshots/IntrospectionTests.ExecuteGraphiQLIntrospectionQuery_ToJson.snap Snapshot updates to include new introspection types/unions/scalars.
src/HotChocolate/Core/test/Execution.Tests/snapshots/IntrospectionTests.DirectiveIntrospection_SomeDirectives_Internal.snap Snapshot updates due to introspection schema changes.
src/HotChocolate/Core/test/Execution.Tests/snapshots/IntrospectionTests.DirectiveIntrospection_AllDirectives_Public.snap Snapshot updates due to introspection schema changes.
src/HotChocolate/Core/test/Execution.Tests/snapshots/IntrospectionTests.DirectiveIntrospection_AllDirectives_Internal.snap Snapshot updates due to introspection schema changes.
src/HotChocolate/Core/test/Execution.Tests/snapshots/IntrospectionTests.DefaultValueIsInputObject.snap Snapshot updates to include new introspection types/unions/scalars.
src/HotChocolate/Core/src/Validation/Rules/IntrospectionVisitor.cs Expands “introspection not allowed” rule to cover any introspection field on Query (incl. new ones).
src/HotChocolate/Core/src/Types/Types/Introspection/SearchResultInfo.cs Adds Core runtime backing data for __SearchResult.
src/HotChocolate/Core/src/Types/Types/Introspection/Search/SchemaIndexer.cs Walks schema to create BM25 documents + reverse adjacency map.
src/HotChocolate/Core/src/Types/Types/Introspection/Search/BM25Tokenizer.cs Implements tokenization (case/boundary splitting + normalization).
src/HotChocolate/Core/src/Types/Types/Introspection/Search/BM25SearchProvider.cs Implements ISchemaSearchProvider using BM25 index + path-to-root BFS.
src/HotChocolate/Core/src/Types/Types/Introspection/Search/BM25Index.cs Implements immutable BM25 inverted index and scoring search.
src/HotChocolate/Core/src/Types/Types/Introspection/Search/BM25Document.cs Defines index document record (coordinate + text).
src/HotChocolate/Core/src/Types/Types/Introspection/IntrospectionTypeInterceptor.cs Adds __search/__definitions fields to Query when enabled.
src/HotChocolate/Core/src/Types/Types/Introspection/IntrospectionFields.cs Adds descriptors/resolvers for the new semantic introspection fields.
src/HotChocolate/Core/src/Types/Types/Introspection/__SearchResult.cs Adds Core introspection object type for search results.
src/HotChocolate/Core/src/Types/Types/Introspection/__SchemaDefinition.cs Adds Core introspection union for schema definition results.
src/HotChocolate/Core/src/Types/SchemaOptions.cs Adds EnableSemanticIntrospection option (defaults to true).
src/HotChocolate/Core/src/Types/SchemaBuilder.Setup.cs Registers ISchemaSearchProvider in Core DI.
src/HotChocolate/Core/src/Types/IReadOnlySchemaOptions.cs Exposes EnableSemanticIntrospection on schema options interface.
src/HotChocolate/Core/src/Types/Configuration/IntrospectionTypeReferences.cs Ensures semantic introspection types/scalars are enqueued when enabled.
src/HotChocolate/Core/src/Types.Abstractions/SchemaSearchResult.cs Adds public schema search result abstraction.
src/HotChocolate/Core/src/Types.Abstractions/SchemaCoordinatePath.cs Adds public path abstraction for coordinate-to-root traversal.
src/HotChocolate/Core/src/Types.Abstractions/ISchemaSearchProvider.cs Adds public provider interface for semantic schema search/path discovery.
.work/review/review.md Adds a review-verdict markdown file (appears to be a local artifact).

💡 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