Skip to content

StrawberryShake vnext#9977

Open
michaelstaib wants to merge 1 commit into
mainfrom
strawberry-shake
Open

StrawberryShake vnext#9977
michaelstaib wants to merge 1 commit into
mainfrom
strawberry-shake

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 24, 2026 05:59
@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall coverage in the branch remains at 49%, unchanged from the branch.

Show a code coverage summary of the most impacted files.
File 303ba5f a724f9b +/-
/home/runner/wo...ons.Document.cs 78% 66% -12%
/home/runner/wo...SchemaHelper.cs 90% 92% +2%
/home/runner/wo...eiveEndpoint.cs 69% 78% +9%
/home/runner/wo...peDefinition.cs 54% 73% +19%
/home/runner/wo...Ins/BuiltIns.cs 60% 80% +20%
/home/runner/wo.../ErrorHelper.cs 39% 68% +29%
/home/runner/wo...peDefinition.cs 50% 81% +31%
/home/runner/wo...eValueHelper.cs 0% 78% +78%
/home/runner/wo...veDefinition.cs 0% 86% +86%
/home/runner/wo...veDefinition.cs 0% 86% +86%

Code Coverage is in Public Preview. Learn more and provide us with your feedback.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 StrawberryShake code generation to align with “HotChocolate vnext” by switching schema handling from runtime Schema types/interceptors to MutableSchemaDefinition and ISchemaDefinition abstractions, and adjusts tests and generators accordingly.

Changes:

  • Replaced schema construction/annotation via SchemaBuilder + interceptors with mutable schema parsing (SchemaParser) and post-parse annotation in SchemaHelper.
  • Updated analyzers/mappers/generators to use I*TypeDefinition / ISchemaDefinition APIs and updated directive/value extraction.
  • Refactored tests to share StarWars schema creation and updated assertions impacted by new type/ordering behaviors.

Reviewed changes

Copilot reviewed 50 out of 50 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/SchemaHelperTests.cs Updates scalar lookup to IScalarTypeDefinition against the new schema model.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Utilities/QueryDocumentRewriterTests.cs Uses shared test schema factory instead of building the schema inline.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/TestSchemaHelper.cs Adds helper to build StarWars schema and apply SDL extensions consistently across tests.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Mappers/TestDataHelper.cs Uses shared StarWars schema helper for client model setup.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Analyzers/InterfaceTypeSelectionSetAnalyzerTests.cs Migrates schema creation and adjusts implementation assertions affected by ordering changes.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Analyzers/FragmentHelperTests.cs Migrates schema creation to shared helper.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Analyzers/FieldCollectorTests.cs Migrates schema creation and updates type/variant assertions for the mutable schema model.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Tests/Analyzers/DocumentAnalyzerTests.cs Migrates schema creation to shared helper and simplifies schema extension setup.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/StrawberryShake.CodeGeneration.Razor.Tests.csproj Adds DI package reference needed by compiler pinning.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.Razor.Tests/CSharpCompiler.cs Pins DI extension type to ensure it’s present during compilation tests.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/StrawberryShake.CodeGeneration.CSharp.Tests.csproj Adds DI package reference needed by compiler pinning.
src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/CSharpCompiler.cs Pins DI extension type to ensure it’s present during compilation tests.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/TypeNameQueryRewriter.cs Replaces custom ordinal helper with string.Equals(..., Ordinal).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/SchemaHelper.cs Replaces SchemaBuilder approach with mutable schema parsing and manual introspection/annotation.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/RemoveClientDirectivesRewriter.cs Replaces custom ordinal helper with string.Equals(..., Ordinal).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/OperationDocumentHelper.cs Generalizes validation schema parameter to ISchemaDefinition.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/LeafTypeInterceptor.cs Removes interceptor-based leaf type annotation (superseded by mutable schema annotation).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/FragmentRewriter.cs Replaces custom ordinal helper with string.Equals(..., Ordinal).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/EntityTypeInterceptor.cs Removes interceptor-based entity feature annotation (superseded by mutable schema annotation).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/StrawberryShake.CodeGeneration.csproj Replaces single Core reference with targeted abstraction/mutable/validation references.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/ScalarNames.cs Adds centralized scalar name constants used across codegen/schema parsing.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Mappers/TypeDescriptorMapper.InputTypes.cs Updates name comparisons to string.Equals(..., Ordinal).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Mappers/TypeDescriptorMapper.cs Updates type checks to I*TypeDefinition interfaces and ordinal comparisons.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Mappers/OperationDescriptorMapper.cs Uses NamedType().Name and ordinal comparison to resolve argument types.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Mappers/EntityIdFactoryDescriptorMapper.cs Uses IsLeafType() semantics rather than concrete leaf type interfaces.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Mappers/DataTypeDescriptorMapper.cs Migrates unions/objects to IUnionTypeDefinition / IObjectTypeDefinition APIs.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Extensions/TypeExtensions.cs Moves leaf type helpers to ITypeDefinition based feature access.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/ErrorHelper.cs Switches schema error mapping to SchemaInitializationException-based path.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/Types/SerializationTypeDirectiveType.cs Removes runtime directive type registration (no longer used with mutable parsing).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/Types/RuntimeTypeDirectiveType.cs Removes runtime directive type registration (no longer used with mutable parsing).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/Types/RenameDirectiveType.cs Removes runtime directive type registration (no longer used with mutable parsing).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/Types/EnumValueDirectiveType.cs Removes runtime directive type registration (no longer used with mutable parsing).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/Models/OperationModel.cs Replaces ObjectType with IObjectTypeDefinition in the analyzed model.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/Models/InputObjectTypeModel.cs Replaces InputObjectType with IInputObjectTypeDefinition in the analyzed model.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/Models/EnumValueModel.cs Replaces concrete enum value type with IEnumValue.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/Models/ClientModel.cs Switches analyzed schema to MutableSchemaDefinition.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/InputObjectTypeUsageAnalyzer.cs Generalizes schema dependency to ISchemaDefinition and interfaces.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/IDocumentAnalyzerContext.cs Updates operation type to IObjectTypeDefinition.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/FragmentHelper.cs Updates ordinal comparisons to string.Equals(..., Ordinal).
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/FieldCollector.cs Updates __typename handling and comparisons for abstraction/mutable-type environment.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/EnumTypeUsageAnalyzer.cs Generalizes schema dependency and migrates to I*TypeDefinition interfaces.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/DocumentAnalyzerContext.cs Switches schema to MutableSchemaDefinition and updates leaf-type registration logic.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/DocumentAnalyzer.cs Switches stored schema type to MutableSchemaDefinition.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/DocumentAnalyzer.CollectOutputTypes.cs Updates type checks to interface-based definitions.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/DocumentAnalyzer.CollectInputObjectTypes.cs Switches directive value extraction to string-arg helper and interface-based types.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/DocumentAnalyzer.CollectEnumTypes.cs Switches directive value extraction to string-arg helper and interface-based types.
src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/DirectiveValueHelper.cs Adds helper to read string directive arguments from IReadOnlyDirectiveCollection.
src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/JsonResultBuilderGenerator_DeserializeDataType.cs Updates ordinal comparisons to string.Equals(..., Ordinal).
src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/DataTypeGenerator.cs Updates ordinal comparisons to string.Equals(..., Ordinal).
src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs Migrates schema creation to mutable schema path and updates schema error handling types.

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

Comment on lines +83 to +86
AddIntrospectionFields(schema);
AnnotateSchema(schema, leafTypes, globalEntityPatterns, typeEntityPatterns);

return schema;
Comment on lines +450 to +456
private static void TryAddScalarDefinition(MutableSchemaDefinition schema, string typeName)
{
if (!schema.Types.TryGetType(typeName, out _))
{
schema.Types.Add(new MutableScalarTypeDefinition(typeName) { IsSpecScalar = true });
}
}
Comment on lines +387 to +394
private static void AddBuiltInDirectiveDefinitions(MutableSchemaDefinition schema)
{
TryAddDirectiveDefinition(schema, BuiltIns.Include.Create(schema));
TryAddDirectiveDefinition(schema, BuiltIns.Skip.Create(schema));
TryAddDirectiveDefinition(schema, BuiltIns.Deprecated.Create(schema));
TryAddDirectiveDefinition(schema, BuiltIns.SpecifiedBy.Create(schema));
TryAddDirectiveDefinition(schema, BuiltIns.OneOf.Create());
}
Comment on lines 72 to 76
Assert.Collection(
context.GetImplementations(result),
model => Assert.Equal("IGetHero_Hero_Human", model.Name),
model => Assert.Equal("IGetHero_Hero_Droid", model.Name));
model => Assert.Equal("IGetHero_Hero_Droid", model.Name),
model => Assert.Equal("IGetHero_Hero_Human", model.Name));

Comment on lines 160 to 164
Assert.Collection(
context.GetImplementations(result),
model => Assert.Equal("IGetHero_Hero_Human", model.Name),
model => Assert.Equal("IGetHero_Hero_Droid", model.Name));
model => Assert.Equal("IGetHero_Hero_Droid", model.Name),
model => Assert.Equal("IGetHero_Hero_Human", model.Name));

Comment on lines +88 to +92
Assert.Equal("Droid", selectionSetVariants.Variants[0].Type.Name);
Assert.Equal("Human", selectionSetVariants.Variants[1].Type.Name);

Assert.Collection(
selectionSetVariants.Variants[1].FragmentNodes,
selectionSetVariants.Variants[0].FragmentNodes,
Comment on lines +378 to +384
foreach (var scalarName in scalarNames)
{
if (!declaredTypeNames.Contains(scalarName))
{
TryAddScalarDefinition(schema, scalarName);
}
}
Comment on lines +509 to +516
foreach (var complexType in complexTypes)
{
if (globalEntityPatterns.FirstOrDefault(
pattern => DoesPatternMatch(complexType, pattern)) is { } matchedPattern)
{
complexType.Features.Set(new EntityFeature(matchedPattern));
}
}
parentRuntimeTypeName = GetInterfaceName(outputType.Type.Name);
break;
case InterfaceType when (implementedBy?.Any(t => t.IsEntity()) == true):
case IInterfaceTypeDefinition when (implementedBy?.Any(t => t.IsEntity()) == true):
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